From 9d6852cf98dd1e6a939b3469ea49ff7cbc15ad73 Mon Sep 17 00:00:00 2001 From: Michael Gottesman Date: Tue, 20 Aug 2013 08:36:50 +0000 Subject: [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 --- lib/CodeGen/Analysis.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/CodeGen/Analysis.cpp b/lib/CodeGen/Analysis.cpp index 332a042551..1600c67a7c 100644 --- a/lib/CodeGen/Analysis.cpp +++ b/lib/CodeGen/Analysis.cpp @@ -510,6 +510,13 @@ bool llvm::isInTailCallPosition(ImmutableCallSite CS, 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(ImmutableCallSite CS, if (isa(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(I)->getAttributes(), AttributeSet::ReturnIndex); -- cgit v1.2.3