Skip to content
Merged
Changes from 2 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
26 changes: 14 additions & 12 deletions llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9012,6 +9012,16 @@ static void checkAddrSpaceIsValidForLibcall(const TargetLowering *TLI,
}
}

static bool isInTailCallPositionWrapper(const CallInst *CI,
const SelectionDAG *SelDAG,
bool IsLowerToLibCall) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AllowReturnsFirstArg


return CI && CI->isTailCall() &&
isInTailCallPosition(*CI, SelDAG->getTarget(),
funcReturnsFirstArgOfCall(*CI) &&
IsLowerToLibCall);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IsLowerToLibCall && 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 +9043,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, /*LowerToLibCall*/ true);

CLI.setDebugLoc(dl)
.setChain(Chain)
Expand Down Expand Up @@ -9117,10 +9125,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 +9239,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