llvm.org GIT mirror llvm / 9d6852c
[stackprotector] Refactor out the end of isInTailCallPosition into the function returnTypeIsEligibleForTailCall. This allows me to use returnTypeIsEligibleForTailCall in the stack protector pass. rdar://13935163 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188765 91177308-0d34-0410-b5e6-96231b3b80d8 Michael Gottesman 6 years ago
2 changed file(s) with 17 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
2525
2626 class GlobalVariable;
2727 class TargetLowering;
28 class TargetLoweringBase;
2829 class SDNode;
2930 class SDValue;
3031 class SelectionDAG;
8788 /// This function only tests target-independent requirements.
8889 bool isInTailCallPosition(ImmutableCallSite CS, const TargetLowering &TLI);
8990
91 /// Test if given that the input instruction is in the tail call position if the
92 /// return type or any attributes of the function will inhibit tail call
93 /// optimization.
94 bool returnTypeIsEligibleForTailCall(const Function *F,
95 const Instruction *I,
96 const ReturnInst *Ret,
97 const TargetLoweringBase &TLI);
98
9099 } // End llvm namespace
91100
92101 #endif
509509 return false;
510510 }
511511
512 return returnTypeIsEligibleForTailCall(ExitBB->getParent(), I, Ret, TLI);
513 }
514
515 bool llvm::returnTypeIsEligibleForTailCall(const Function *F,
516 const Instruction *I,
517 const ReturnInst *Ret,
518 const TargetLoweringBase &TLI) {
512519 // If the block ends with a void return or unreachable, it doesn't matter
513520 // what the call's return type is.
514521 if (!Ret || Ret->getNumOperands() == 0) return true;
518525 if (isa(Ret->getOperand(0))) return true;
519526
520527 // Make sure the attributes attached to each return are compatible.
521 AttrBuilder CallerAttrs(ExitBB->getParent()->getAttributes(),
528 AttrBuilder CallerAttrs(F->getAttributes(),
522529 AttributeSet::ReturnIndex);
523530 AttrBuilder CalleeAttrs(cast(I)->getAttributes(),
524531 AttributeSet::ReturnIndex);