X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FTransforms%2FUtils%2FInlineCost.cpp;h=6ecd060991238c9f46ff137f400a09ef0db616aa;hb=dd4924c564c7a661b78b604ebf16dfef7aa62b35;hp=c17705bf85090504a74bfe0681d1d839e1791a63;hpb=91e1c32dd025c1595a46e2ae59b0ce6ad0f0edea;p=oota-llvm.git diff --git a/lib/Transforms/Utils/InlineCost.cpp b/lib/Transforms/Utils/InlineCost.cpp index c17705bf850..6ecd0609912 100644 --- a/lib/Transforms/Utils/InlineCost.cpp +++ b/lib/Transforms/Utils/InlineCost.cpp @@ -100,9 +100,32 @@ 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(II)) continue; // Debug intrinsics don't count. if (isa(II)) continue; // PHI nodes don't count. + // Special handling for calls. + if (isa(II) || isa(II)) { + if (isa(II)) + continue; // Debug intrinsics don't count as size. + + CallSite CS = CallSite::get(const_cast(&*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; + } + + // Calls often compile into many machine instructions. Bump up their + // cost to reflect this. + if (!isa(II)) + NumInsts += 5; + } + if (isa(II) || isa(II->getType())) ++NumVectorInsts; @@ -194,6 +217,13 @@ 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; + + if (!Callee->isDeclaration() && Callee->hasNote(FN_NOTE_AlwaysInline)) + 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