Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9012,6 +9012,18 @@ static void checkAddrSpaceIsValidForLibcall(const TargetLowering *TLI,
}
}

static bool isInTailCallPositionWrapper(const CallInst *CI,
const SelectionDAG *SelDAG,
bool AllowReturnsFirstArg) {
if (!CI || !CI->isTailCall())
return false;
// TODO: Fix "returns-first-arg" determination so it doesn't depend on which
// helper symbol we lower to.
return isInTailCallPosition(*CI, SelDAG->getTarget(),
AllowReturnsFirstArg &&
funcReturnsFirstArgOfCall(*CI));
}

std::pair<SDValue, SDValue>
SelectionDAG::getMemcmp(SDValue Chain, const SDLoc &dl, SDValue Mem0,
SDValue Mem1, SDValue Size, const CallInst *CI) {
Expand All @@ -9033,10 +9045,8 @@ SelectionDAG::getMemcmp(SDValue Chain, const SDLoc &dl, SDValue Mem0,
GetEntry(getDataLayout().getIntPtrType(*getContext()), Size)};

TargetLowering::CallLoweringInfo CLI(*this);
bool IsTailCall = false;
bool ReturnsFirstArg = CI && funcReturnsFirstArgOfCall(*CI);
IsTailCall = CI && CI->isTailCall() &&
isInTailCallPosition(*CI, getTarget(), ReturnsFirstArg);
bool IsTailCall =
isInTailCallPositionWrapper(CI, this, /*AllowReturnsFirstArg*/ true);

CLI.setDebugLoc(dl)
.setChain(Chain)
Expand Down Expand Up @@ -9117,10 +9127,7 @@ SDValue SelectionDAG::getMemcpy(
IsTailCall = *OverrideTailCall;
} else {
bool LowersToMemcpy = StringRef(MemCpyName) == StringRef("memcpy");
bool ReturnsFirstArg = CI && funcReturnsFirstArgOfCall(*CI);
IsTailCall = CI && CI->isTailCall() &&
isInTailCallPosition(*CI, getTarget(),
ReturnsFirstArg && LowersToMemcpy);
IsTailCall = isInTailCallPositionWrapper(CI, this, LowersToMemcpy);
}

CLI.setDebugLoc(dl)
Expand Down Expand Up @@ -9234,10 +9241,7 @@ SDValue SelectionDAG::getMemmove(SDValue Chain, const SDLoc &dl, SDValue Dst,
} else {
bool LowersToMemmove =
TLI->getLibcallName(RTLIB::MEMMOVE) == StringRef("memmove");
bool ReturnsFirstArg = CI && funcReturnsFirstArgOfCall(*CI);
IsTailCall = CI && CI->isTailCall() &&
isInTailCallPosition(*CI, getTarget(),
ReturnsFirstArg && LowersToMemmove);
IsTailCall = isInTailCallPositionWrapper(CI, this, LowersToMemmove);
}

CLI.setDebugLoc(dl)
Expand Down
Loading