Please use GitHub pull requests for new patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
llvm/lib/Target/ARM/ARMISelLowering.cpp
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show First 20 Lines • Show All 2,946 Lines • ▼ Show 20 Lines | bool ARMTargetLowering::IsEligibleForTailCallOptimization( | ||||
const Function &CallerF = MF.getFunction(); | const Function &CallerF = MF.getFunction(); | ||||
CallingConv::ID CallerCC = CallerF.getCallingConv(); | CallingConv::ID CallerCC = CallerF.getCallingConv(); | ||||
assert(Subtarget->supportsTailCall()); | assert(Subtarget->supportsTailCall()); | ||||
// Indirect tail calls cannot be optimized for Thumb1 if the args | // Indirect tail calls cannot be optimized for Thumb1 if the args | ||||
// to the call take up r0-r3. The reason is that there are no legal registers | // to the call take up r0-r3. The reason is that there are no legal registers | ||||
// left to hold the pointer to the function to be called. | // left to hold the pointer to the function to be called. | ||||
if (Subtarget->isThumb1Only() && Outs.size() >= 4 && | // Similarly, if the function uses return address sign and authentication, | ||||
(!isa<GlobalAddressSDNode>(Callee.getNode()) || isIndirect)) | // r12 is needed to hold the PAC and is not available to hold the callee | ||||
// address. | |||||
if (Outs.size() >= 4 && | |||||
(!isa<GlobalAddressSDNode>(Callee.getNode()) || isIndirect)) { | |||||
if (Subtarget->isThumb1Only()) | |||||
return false; | |||||
// Conservatively assume the function spills LR. | |||||
if (MF.getInfo<ARMFunctionInfo>()->shouldSignReturnAddress(true)) | |||||
return false; | return false; | ||||
} | |||||
// Look for obvious safe cases to perform tail call optimization that do not | // Look for obvious safe cases to perform tail call optimization that do not | ||||
// require ABI changes. This is what gcc calls sibcall. | // require ABI changes. This is what gcc calls sibcall. | ||||
// Exception-handling functions need a special set of instructions to indicate | // Exception-handling functions need a special set of instructions to indicate | ||||
// a return to the hardware. Tail-calling another function would probably | // a return to the hardware. Tail-calling another function would probably | ||||
// break this. | // break this. | ||||
if (CallerF.hasFnAttribute("interrupt")) | if (CallerF.hasFnAttribute("interrupt")) | ||||
▲ Show 20 Lines • Show All 18,600 Lines • Show Last 20 Lines |