diff options
author | Chris Lattner <sabre@nondot.org> | 2008-07-14 17:32:59 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-07-14 17:32:59 +0000 |
commit | 8882b1c41c69e3946a0ed73466cf6ba673cac738 (patch) | |
tree | a2ae8bd437d1dc44ed5e79b3b33d3b1dc1593a58 /llvm/lib/Transforms/Utils/InlineCost.cpp | |
parent | a30cbd9797855fc2bef7b69c05a460871e024ebf (diff) | |
download | bcm5719-llvm-8882b1c41c69e3946a0ed73466cf6ba673cac738.tar.gz bcm5719-llvm-8882b1c41c69e3946a0ed73466cf6ba673cac738.zip |
Reapply r53540, now with the matching header!
llvm-svn: 53557
Diffstat (limited to 'llvm/lib/Transforms/Utils/InlineCost.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/InlineCost.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Utils/InlineCost.cpp b/llvm/lib/Transforms/Utils/InlineCost.cpp index c17705bf850..10cb77bbcba 100644 --- a/llvm/lib/Transforms/Utils/InlineCost.cpp +++ b/llvm/lib/Transforms/Utils/InlineCost.cpp @@ -100,9 +100,27 @@ void InlineCostAnalyzer::FunctionInfo::analyzeFunction(Function *F) { for (Function::const_iterator BB = F->begin(), E = F->end(); BB != E; ++BB) { for (BasicBlock::const_iterator II = BB->begin(), E = BB->end(); II != E; ++II) { - if (isa<DbgInfoIntrinsic>(II)) continue; // Debug intrinsics don't count. if (isa<PHINode>(II)) continue; // PHI nodes don't count. + // Special handling for calls. + if (isa<CallInst>(II) || isa<InvokeInst>(II)) { + if (isa<DbgInfoIntrinsic>(II)) + continue; // Debug intrinsics don't count as size. + + CallSite CS = CallSite::get(const_cast<Instruction*>(&*II)); + + // If this function contains a call to setjmp or _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. + if (Function *F = CS.getCalledFunction()) + if (F->isDeclaration() && + (F->isName("setjmp") || F->isName("_setjmp"))) { + NeverInline = true; + return; + } + } + if (isa<ExtractElementInst>(II) || isa<VectorType>(II->getType())) ++NumVectorInsts; @@ -194,6 +212,10 @@ int InlineCostAnalyzer::getInlineCost(CallSite CS, // If we haven't calculated this information yet, do so now. if (CalleeFI.NumBlocks == 0) CalleeFI.analyzeFunction(Callee); + + // If we should never inline this, return a huge cost. + if (CalleeFI.NeverInline) + return 2000000000; // Add to the inline quality for properties that make the call valuable to // inline. This includes factors that indicate that the result of inlining |