diff options
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/IPO/InlineAlways.cpp | 3 | ||||
-rw-r--r-- | lib/Transforms/IPO/InlineSimple.cpp | 3 | ||||
-rw-r--r-- | lib/Transforms/IPO/Inliner.cpp | 5 | ||||
-rw-r--r-- | lib/Transforms/Utils/InlineCost.cpp | 24 |
4 files changed, 24 insertions, 11 deletions
diff --git a/lib/Transforms/IPO/InlineAlways.cpp b/lib/Transforms/IPO/InlineAlways.cpp index 9031432162..5f9ea5453c 100644 --- a/lib/Transforms/IPO/InlineAlways.cpp +++ b/lib/Transforms/IPO/InlineAlways.cpp @@ -45,6 +45,9 @@ namespace { float getInlineFudgeFactor(CallSite CS) { return CA.getInlineFudgeFactor(CS); } + void resetCachedCostInfo(Function *Caller) { + return CA.resetCachedCostInfo(Caller); + } virtual bool doFinalization(CallGraph &CG) { return removeDeadFunctions(CG, &NeverInline); } diff --git a/lib/Transforms/IPO/InlineSimple.cpp b/lib/Transforms/IPO/InlineSimple.cpp index 8ae5235383..e107a0023c 100644 --- a/lib/Transforms/IPO/InlineSimple.cpp +++ b/lib/Transforms/IPO/InlineSimple.cpp @@ -43,6 +43,9 @@ namespace { float getInlineFudgeFactor(CallSite CS) { return CA.getInlineFudgeFactor(CS); } + void resetCachedCostInfo(Function *Caller) { + CA.resetCachedCostInfo(Caller); + } virtual bool doInitialization(CallGraph &CG); }; } diff --git a/lib/Transforms/IPO/Inliner.cpp b/lib/Transforms/IPO/Inliner.cpp index f97fce6e06..639f3a84cb 100644 --- a/lib/Transforms/IPO/Inliner.cpp +++ b/lib/Transforms/IPO/Inliner.cpp @@ -185,9 +185,14 @@ bool Inliner::runOnSCC(const std::vector<CallGraphNode*> &SCC) { // try to do so. CallSite CS = CallSites[CSi]; if (shouldInline(CS)) { + Function *Caller = CS.getCaller(); // Attempt to inline the function... if (InlineCallIfPossible(CS, CG, SCCFunctions, getAnalysis<TargetData>())) { + // Remove any cached cost info for this caller, as inlining the callee + // has increased the size of the caller. + resetCachedCostInfo(Caller); + // Remove this call site from the list. If possible, use // swap/pop_back for efficiency, but do not use it if doing so would // move a call site to a function in this SCC before the diff --git a/lib/Transforms/Utils/InlineCost.cpp b/lib/Transforms/Utils/InlineCost.cpp index 82e310b38c..90d72efa36 100644 --- a/lib/Transforms/Utils/InlineCost.cpp +++ b/lib/Transforms/Utils/InlineCost.cpp @@ -127,7 +127,7 @@ void InlineCostAnalyzer::FunctionInfo::analyzeFunction(Function *F) { } if (const AllocaInst *AI = dyn_cast<AllocaInst>(II)) { - if (!isa<ConstantInt>(AI->getArraySize())) + if (!AI->isStaticAlloca()) this->usesDynamicAlloca = true; } @@ -229,18 +229,20 @@ InlineCost InlineCostAnalyzer::getInlineCost(CallSite CS, if (CalleeFI.NeverInline) return InlineCost::getNever(); - // Get infomation about the caller... - FunctionInfo &CallerFI = CachedFunctionInfo[Caller]; + if (CalleeFI.usesDynamicAlloca) { + // Get infomation about the caller... + FunctionInfo &CallerFI = CachedFunctionInfo[Caller]; - // If we haven't calculated this information yet, do so now. - if (CallerFI.NumBlocks == 0) - CallerFI.analyzeFunction(Caller); + // If we haven't calculated this information yet, do so now. + if (CallerFI.NumBlocks == 0) + CallerFI.analyzeFunction(Caller); - // Don't inline a callee with dynamic alloca into a caller without them. - // Functions containing dynamic alloca's are inefficient in various ways; - // don't create more inefficiency. - if (CalleeFI.usesDynamicAlloca && !CallerFI.usesDynamicAlloca) - return InlineCost::getNever(); + // Don't inline a callee with dynamic alloca into a caller without them. + // Functions containing dynamic alloca's are inefficient in various ways; + // don't create more inefficiency. + if (!CallerFI.usesDynamicAlloca) + return InlineCost::getNever(); + } // FIXME: It would be nice to kill off CalleeFI.NeverInline. Then we // could move this up and avoid computing the FunctionInfo for |