diff options
author | Bill Wendling <isanbard@gmail.com> | 2011-10-17 18:43:40 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2011-10-17 18:43:40 +0000 |
commit | 3c5e60994f53eef2808a33b5ca6c3dffc2168054 (patch) | |
tree | f77554018088b20adc18a5aca234db259071c838 /lib | |
parent | 8f3af87e99b9556224480f1aa18d340fb343bbf6 (diff) |
Correct over-zealous removal of hack.
Some code want to check that *any* call within a function has the 'returns
twice' attribute, not just that the current function has one.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142221 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Analysis/InlineCost.cpp | 2 | ||||
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 2 | ||||
-rw-r--r-- | lib/Transforms/Scalar/TailRecursionElimination.cpp | 2 | ||||
-rw-r--r-- | lib/VMCore/Function.cpp | 15 |
4 files changed, 18 insertions, 3 deletions
diff --git a/lib/Analysis/InlineCost.cpp b/lib/Analysis/InlineCost.cpp index 65db33cdc4..40ac9a211a 100644 --- a/lib/Analysis/InlineCost.cpp +++ b/lib/Analysis/InlineCost.cpp @@ -229,7 +229,7 @@ void CodeMetrics::analyzeFunction(Function *F, const TargetData *TD) { // _setjmp), never inline it. This is a hack because we depend on the user // marking their local variables as volatile if they are live across a setjmp // call, and they probably won't do this in callers. - callsSetJmp = F->hasFnAttr(Attribute::ReturnsTwice); + callsSetJmp = F->callsFunctionThatReturnsTwice(); // Look at the size of the callee. for (Function::const_iterator BB = F->begin(), E = F->end(); BB != E; ++BB) diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index 2db91ea40b..68b9146adf 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -374,7 +374,7 @@ bool SelectionDAGISel::runOnMachineFunction(MachineFunction &mf) { } // Determine if there is a call to setjmp in the machine function. - MF->setCallsSetJmp(Fn.hasFnAttr(Attribute::ReturnsTwice)); + MF->setCallsSetJmp(Fn.callsFunctionThatReturnsTwice()); // Replace forward-declared registers with the registers containing // the desired value. diff --git a/lib/Transforms/Scalar/TailRecursionElimination.cpp b/lib/Transforms/Scalar/TailRecursionElimination.cpp index 1022485a94..e21eb9dca2 100644 --- a/lib/Transforms/Scalar/TailRecursionElimination.cpp +++ b/lib/Transforms/Scalar/TailRecursionElimination.cpp @@ -213,7 +213,7 @@ bool TailCallElim::runOnFunction(Function &F) { // Finally, if this function contains no non-escaping allocas, or calls // setjmp, mark all calls in the function as eligible for tail calls //(there is no stack memory for them to access). - if (!FunctionContainsEscapingAllocas && !F.hasFnAttr(Attribute::ReturnsTwice)) + if (!FunctionContainsEscapingAllocas && !F.callsFunctionThatReturnsTwice()) for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) if (CallInst *CI = dyn_cast<CallInst>(I)) { diff --git a/lib/VMCore/Function.cpp b/lib/VMCore/Function.cpp index 975ec83b4d..a6128b0cad 100644 --- a/lib/VMCore/Function.cpp +++ b/lib/VMCore/Function.cpp @@ -411,4 +411,19 @@ bool Function::hasAddressTaken(const User* *PutOffender) const { return false; } +/// callsFunctionThatReturnsTwice - Return true if the function has a call to +/// setjmp or other function that gcc recognizes as "returning twice". +bool Function::callsFunctionThatReturnsTwice() const { + for (const_inst_iterator + I = inst_begin(this), E = inst_end(this); I != E; ++I) { + const CallInst* callInst = dyn_cast<CallInst>(&*I); + if (!callInst) + continue; + if (callInst->canReturnTwice()) + return true; + } + + return false; +} + // vim: sw=2 ai |