Skip to content

Commit 955e081

Browse files
committed
add a helper function isTailCall
1 parent cba5f1b commit 955e081

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9012,6 +9012,14 @@ static void checkAddrSpaceIsValidForLibcall(const TargetLowering *TLI,
90129012
}
90139013
}
90149014

9015+
static bool isTailCall(const CallInst *CI, const SelectionDAG *SelDAG,
9016+
bool IsLowerToLibCall) {
9017+
bool ReturnsFirstArg = CI && funcReturnsFirstArgOfCall(*CI);
9018+
return CI && CI->isTailCall() &&
9019+
isInTailCallPosition(*CI, SelDAG->getTarget(),
9020+
ReturnsFirstArg && IsLowerToLibCall);
9021+
}
9022+
90159023
std::pair<SDValue, SDValue>
90169024
SelectionDAG::getMemcmp(SDValue Chain, const SDLoc &dl, SDValue Mem0,
90179025
SDValue Mem1, SDValue Size, const CallInst *CI) {
@@ -9033,10 +9041,7 @@ SelectionDAG::getMemcmp(SDValue Chain, const SDLoc &dl, SDValue Mem0,
90339041
GetEntry(getDataLayout().getIntPtrType(*getContext()), Size)};
90349042

90359043
TargetLowering::CallLoweringInfo CLI(*this);
9036-
bool IsTailCall = false;
9037-
bool ReturnsFirstArg = CI && funcReturnsFirstArgOfCall(*CI);
9038-
IsTailCall = CI && CI->isTailCall() &&
9039-
isInTailCallPosition(*CI, getTarget(), ReturnsFirstArg);
9044+
bool IsTailCall = isTailCall(CI, this, /*LowerToLibCall*/ true);
90409045

90419046
CLI.setDebugLoc(dl)
90429047
.setChain(Chain)
@@ -9117,10 +9122,7 @@ SDValue SelectionDAG::getMemcpy(
91179122
IsTailCall = *OverrideTailCall;
91189123
} else {
91199124
bool LowersToMemcpy = StringRef(MemCpyName) == StringRef("memcpy");
9120-
bool ReturnsFirstArg = CI && funcReturnsFirstArgOfCall(*CI);
9121-
IsTailCall = CI && CI->isTailCall() &&
9122-
isInTailCallPosition(*CI, getTarget(),
9123-
ReturnsFirstArg && LowersToMemcpy);
9125+
IsTailCall = isTailCall(CI, this, LowersToMemcpy);
91249126
}
91259127

91269128
CLI.setDebugLoc(dl)
@@ -9234,10 +9236,7 @@ SDValue SelectionDAG::getMemmove(SDValue Chain, const SDLoc &dl, SDValue Dst,
92349236
} else {
92359237
bool LowersToMemmove =
92369238
TLI->getLibcallName(RTLIB::MEMMOVE) == StringRef("memmove");
9237-
bool ReturnsFirstArg = CI && funcReturnsFirstArgOfCall(*CI);
9238-
IsTailCall = CI && CI->isTailCall() &&
9239-
isInTailCallPosition(*CI, getTarget(),
9240-
ReturnsFirstArg && LowersToMemmove);
9239+
IsTailCall = isTailCall(CI, this, LowersToMemmove);
92419240
}
92429241

92439242
CLI.setDebugLoc(dl)

0 commit comments

Comments
 (0)