@@ -9053,6 +9053,18 @@ static void checkAddrSpaceIsValidForLibcall(const TargetLowering *TLI,
9053
9053
}
9054
9054
}
9055
9055
9056
+ static bool isInTailCallPositionWrapper(const CallInst *CI,
9057
+ const SelectionDAG *SelDAG,
9058
+ bool AllowReturnsFirstArg) {
9059
+ if (!CI || !CI->isTailCall())
9060
+ return false;
9061
+ // TODO: Fix "returns-first-arg" determination so it doesn't depend on which
9062
+ // helper symbol we lower to.
9063
+ return isInTailCallPosition(*CI, SelDAG->getTarget(),
9064
+ AllowReturnsFirstArg &&
9065
+ funcReturnsFirstArgOfCall(*CI));
9066
+ }
9067
+
9056
9068
std::pair<SDValue, SDValue>
9057
9069
SelectionDAG::getMemcmp(SDValue Chain, const SDLoc &dl, SDValue Mem0,
9058
9070
SDValue Mem1, SDValue Size, const CallInst *CI) {
@@ -9067,10 +9079,8 @@ SelectionDAG::getMemcmp(SDValue Chain, const SDLoc &dl, SDValue Mem0,
9067
9079
{Size, getDataLayout().getIntPtrType(*getContext())}};
9068
9080
9069
9081
TargetLowering::CallLoweringInfo CLI(*this);
9070
- bool IsTailCall = false;
9071
- bool ReturnsFirstArg = CI && funcReturnsFirstArgOfCall(*CI);
9072
- IsTailCall = CI && CI->isTailCall() &&
9073
- isInTailCallPosition(*CI, getTarget(), ReturnsFirstArg);
9082
+ bool IsTailCall =
9083
+ isInTailCallPositionWrapper(CI, this, /*AllowReturnsFirstArg*/ true);
9074
9084
9075
9085
CLI.setDebugLoc(dl)
9076
9086
.setChain(Chain)
@@ -9148,10 +9158,7 @@ SDValue SelectionDAG::getMemcpy(
9148
9158
IsTailCall = *OverrideTailCall;
9149
9159
} else {
9150
9160
bool LowersToMemcpy = StringRef(MemCpyName) == StringRef("memcpy");
9151
- bool ReturnsFirstArg = CI && funcReturnsFirstArgOfCall(*CI);
9152
- IsTailCall = CI && CI->isTailCall() &&
9153
- isInTailCallPosition(*CI, getTarget(),
9154
- ReturnsFirstArg && LowersToMemcpy);
9161
+ IsTailCall = isInTailCallPositionWrapper(CI, this, LowersToMemcpy);
9155
9162
}
9156
9163
9157
9164
CLI.setDebugLoc(dl)
@@ -9255,10 +9262,7 @@ SDValue SelectionDAG::getMemmove(SDValue Chain, const SDLoc &dl, SDValue Dst,
9255
9262
} else {
9256
9263
bool LowersToMemmove =
9257
9264
TLI->getLibcallName(RTLIB::MEMMOVE) == StringRef("memmove");
9258
- bool ReturnsFirstArg = CI && funcReturnsFirstArgOfCall(*CI);
9259
- IsTailCall = CI && CI->isTailCall() &&
9260
- isInTailCallPosition(*CI, getTarget(),
9261
- ReturnsFirstArg && LowersToMemmove);
9265
+ IsTailCall = isInTailCallPositionWrapper(CI, this, LowersToMemmove);
9262
9266
}
9263
9267
9264
9268
CLI.setDebugLoc(dl)
0 commit comments