Skip to content

Commit 656f584

Browse files
author
git apple-llvm automerger
committed
Merge commit 'ad8f6b44be14' from llvm.org/main into next
2 parents 15cd15f + ad8f6b4 commit 656f584

File tree

5 files changed

+24
-22
lines changed

5 files changed

+24
-22
lines changed

llvm/include/llvm/CodeGen/TargetLowering.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3623,10 +3623,7 @@ class LLVM_ABI TargetLoweringBase {
36233623
return RTLIB::RuntimeLibcallsInfo::getLibcallImplName(Call);
36243624
}
36253625

3626-
const char *getMemcpyName() const {
3627-
// FIXME: Return StringRef
3628-
return Libcalls.getMemcpyName().data();
3629-
}
3626+
RTLIB::LibcallImpl getMemcpyImpl() const { return Libcalls.getMemcpyImpl(); }
36303627

36313628
/// Check if this is valid libcall for the current module, otherwise
36323629
/// RTLIB::Unsupported.

llvm/include/llvm/IR/RuntimeLibcalls.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,13 @@ struct RuntimeLibcallsInfo {
134134

135135
/// Return a function name compatible with RTLIB::MEMCPY, or nullptr if fully
136136
/// unsupported.
137-
StringRef getMemcpyName() const {
137+
RTLIB::LibcallImpl getMemcpyImpl() const {
138138
RTLIB::LibcallImpl Memcpy = getLibcallImpl(RTLIB::MEMCPY);
139139
if (Memcpy != RTLIB::Unsupported)
140-
return getLibcallImplName(Memcpy);
140+
return Memcpy;
141141

142142
// Fallback to memmove if memcpy isn't available.
143-
return getLibcallName(RTLIB::MEMMOVE);
143+
return getLibcallImpl(RTLIB::MEMMOVE);
144144
}
145145

146146
bool isAvailable(RTLIB::LibcallImpl Impl) const {

llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,7 @@ llvm::createMemLibcall(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI,
776776
break;
777777
case TargetOpcode::G_MEMCPY:
778778
RTLibcall = RTLIB::MEMCPY;
779-
Name = TLI.getMemcpyName();
779+
Name = TLI.getLibcallImplName(TLI.getMemcpyImpl()).data();
780780
Args[0].Flags[0].setReturned();
781781
break;
782782
case TargetOpcode::G_MEMMOVE:

llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ static bool canEmitMemcpy(const TargetMachine *TM, Function *F) {
244244
if (!TM)
245245
return true;
246246
const TargetLowering *TLI = TM->getSubtargetImpl(*F)->getTargetLowering();
247-
return TLI->getMemcpyName() != nullptr;
247+
return TLI->getMemcpyImpl() != RTLIB::Unsupported;
248248
}
249249

250250
// Return a value appropriate for use with the memset_pattern16 libcall, if

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9257,21 +9257,22 @@ SDValue SelectionDAG::getMemcpy(
92579257
// FIXME: pass in SDLoc
92589258
TargetLowering::CallLoweringInfo CLI(*this);
92599259
bool IsTailCall = false;
9260-
const char *MemCpyName = TLI->getMemcpyName();
9260+
RTLIB::LibcallImpl MemCpyImpl = TLI->getMemcpyImpl();
92619261

92629262
if (OverrideTailCall.has_value()) {
92639263
IsTailCall = *OverrideTailCall;
92649264
} else {
9265-
bool LowersToMemcpy = StringRef(MemCpyName) == StringRef("memcpy");
9265+
bool LowersToMemcpy = MemCpyImpl == RTLIB::impl_memcpy;
92669266
IsTailCall = isInTailCallPositionWrapper(CI, this, LowersToMemcpy);
92679267
}
92689268

92699269
CLI.setDebugLoc(dl)
92709270
.setChain(Chain)
92719271
.setLibCallee(
9272-
TLI->getLibcallCallingConv(RTLIB::MEMCPY),
9272+
TLI->getLibcallImplCallingConv(MemCpyImpl),
92739273
Dst.getValueType().getTypeForEVT(*getContext()),
9274-
getExternalSymbol(MemCpyName, TLI->getPointerTy(getDataLayout())),
9274+
getExternalSymbol(TLI->getLibcallImplName(MemCpyImpl).data(),
9275+
TLI->getPointerTy(getDataLayout())),
92759276
std::move(Args))
92769277
.setDiscardResult()
92779278
.setTailCall(IsTailCall);
@@ -9361,22 +9362,24 @@ SDValue SelectionDAG::getMemmove(SDValue Chain, const SDLoc &dl, SDValue Dst,
93619362
// FIXME: pass in SDLoc
93629363
TargetLowering::CallLoweringInfo CLI(*this);
93639364

9365+
RTLIB::LibcallImpl MemmoveImpl = TLI->getLibcallImpl(RTLIB::MEMMOVE);
9366+
93649367
bool IsTailCall = false;
93659368
if (OverrideTailCall.has_value()) {
93669369
IsTailCall = *OverrideTailCall;
93679370
} else {
9368-
bool LowersToMemmove =
9369-
TLI->getLibcallName(RTLIB::MEMMOVE) == StringRef("memmove");
9371+
bool LowersToMemmove = MemmoveImpl == RTLIB::impl_memmove;
93709372
IsTailCall = isInTailCallPositionWrapper(CI, this, LowersToMemmove);
93719373
}
93729374

93739375
CLI.setDebugLoc(dl)
93749376
.setChain(Chain)
9375-
.setLibCallee(TLI->getLibcallCallingConv(RTLIB::MEMMOVE),
9376-
Dst.getValueType().getTypeForEVT(*getContext()),
9377-
getExternalSymbol(TLI->getLibcallName(RTLIB::MEMMOVE),
9378-
TLI->getPointerTy(getDataLayout())),
9379-
std::move(Args))
9377+
.setLibCallee(
9378+
TLI->getLibcallImplCallingConv(MemmoveImpl),
9379+
Dst.getValueType().getTypeForEVT(*getContext()),
9380+
getExternalSymbol(TLI->getLibcallImplName(MemmoveImpl).data(),
9381+
TLI->getPointerTy(getDataLayout())),
9382+
std::move(Args))
93809383
.setDiscardResult()
93819384
.setTailCall(IsTailCall);
93829385

@@ -9492,8 +9495,10 @@ SDValue SelectionDAG::getMemset(SDValue Chain, const SDLoc &dl, SDValue Dst,
94929495
TLI->getPointerTy(DL)),
94939496
std::move(Args));
94949497
}
9495-
bool LowersToMemset =
9496-
TLI->getLibcallName(RTLIB::MEMSET) == StringRef("memset");
9498+
9499+
RTLIB::LibcallImpl MemsetImpl = TLI->getLibcallImpl(RTLIB::MEMSET);
9500+
bool LowersToMemset = MemsetImpl == RTLIB::impl_memset;
9501+
94979502
// If we're going to use bzero, make sure not to tail call unless the
94989503
// subsequent return doesn't need a value, as bzero doesn't return the first
94999504
// arg unlike memset.

0 commit comments

Comments
 (0)