[llvm] r188765 - [stackprotector] Refactor out the end of isInTailCallPosition into the function returnTypeIsEligibleForTailCall.
Michael Gottesman
mgottesman at apple.com
Tue Aug 20 01:36:50 PDT 2013
Author: mgottesman
Date: Tue Aug 20 03:36:50 2013
New Revision: 188765
URL: http://llvm.org/viewvc/llvm-project?rev=188765&view=rev
Log:
[stackprotector] Refactor out the end of isInTailCallPosition into the function returnTypeIsEligibleForTailCall.
This allows me to use returnTypeIsEligibleForTailCall in the stack protector pass.
rdar://13935163
Modified:
llvm/trunk/include/llvm/CodeGen/Analysis.h
llvm/trunk/lib/CodeGen/Analysis.cpp
Modified: llvm/trunk/include/llvm/CodeGen/Analysis.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/Analysis.h?rev=188765&r1=188764&r2=188765&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/Analysis.h (original)
+++ llvm/trunk/include/llvm/CodeGen/Analysis.h Tue Aug 20 03:36:50 2013
@@ -26,6 +26,7 @@ namespace llvm {
class GlobalVariable;
class TargetLowering;
+class TargetLoweringBase;
class SDNode;
class SDValue;
class SelectionDAG;
@@ -88,6 +89,14 @@ ISD::CondCode getICmpCondCode(ICmpInst::
/// This function only tests target-independent requirements.
bool isInTailCallPosition(ImmutableCallSite CS, const TargetLowering &TLI);
+/// Test if given that the input instruction is in the tail call position if the
+/// return type or any attributes of the function will inhibit tail call
+/// optimization.
+bool returnTypeIsEligibleForTailCall(const Function *F,
+ const Instruction *I,
+ const ReturnInst *Ret,
+ const TargetLoweringBase &TLI);
+
} // End llvm namespace
#endif
Modified: llvm/trunk/lib/CodeGen/Analysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/Analysis.cpp?rev=188765&r1=188764&r2=188765&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/Analysis.cpp (original)
+++ llvm/trunk/lib/CodeGen/Analysis.cpp Tue Aug 20 03:36:50 2013
@@ -510,6 +510,13 @@ bool llvm::isInTailCallPosition(Immutabl
return false;
}
+ return returnTypeIsEligibleForTailCall(ExitBB->getParent(), I, Ret, TLI);
+}
+
+bool llvm::returnTypeIsEligibleForTailCall(const Function *F,
+ const Instruction *I,
+ const ReturnInst *Ret,
+ const TargetLoweringBase &TLI) {
// If the block ends with a void return or unreachable, it doesn't matter
// what the call's return type is.
if (!Ret || Ret->getNumOperands() == 0) return true;
@@ -519,7 +526,7 @@ bool llvm::isInTailCallPosition(Immutabl
if (isa<UndefValue>(Ret->getOperand(0))) return true;
// Make sure the attributes attached to each return are compatible.
- AttrBuilder CallerAttrs(ExitBB->getParent()->getAttributes(),
+ AttrBuilder CallerAttrs(F->getAttributes(),
AttributeSet::ReturnIndex);
AttrBuilder CalleeAttrs(cast<CallInst>(I)->getAttributes(),
AttributeSet::ReturnIndex);
More information about the llvm-commits
mailing list