[llvm-commits] [llvm] r61969 - in /llvm/trunk: include/llvm/Transforms/IPO/InlinerPass.h include/llvm/Transforms/Utils/InlineCost.h lib/Transforms/IPO/InlineAlways.cpp lib/Transforms/IPO/InlineSimple.cpp lib/Transforms/IPO/Inliner.cpp lib/Transforms/Utils/InlineCost.cpp
Dale Johannesen
dalej at apple.com
Thu Jan 8 17:30:11 PST 2009
Author: johannes
Date: Thu Jan 8 19:30:11 2009
New Revision: 61969
URL: http://llvm.org/viewvc/llvm-project?rev=61969&view=rev
Log:
Adjustments to last patch based on review.
Modified:
llvm/trunk/include/llvm/Transforms/IPO/InlinerPass.h
llvm/trunk/include/llvm/Transforms/Utils/InlineCost.h
llvm/trunk/lib/Transforms/IPO/InlineAlways.cpp
llvm/trunk/lib/Transforms/IPO/InlineSimple.cpp
llvm/trunk/lib/Transforms/IPO/Inliner.cpp
llvm/trunk/lib/Transforms/Utils/InlineCost.cpp
Modified: llvm/trunk/include/llvm/Transforms/IPO/InlinerPass.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/IPO/InlinerPass.h?rev=61969&r1=61968&r2=61969&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Transforms/IPO/InlinerPass.h (original)
+++ llvm/trunk/include/llvm/Transforms/IPO/InlinerPass.h Thu Jan 8 19:30:11 2009
@@ -61,6 +61,11 @@
///
virtual float getInlineFudgeFactor(CallSite CS) = 0;
+ /// resetCachedCostInfo - erase any cached cost data from the derived class.
+ /// If the derived class has no such data this can be empty.
+ ///
+ virtual void resetCachedCostInfo(Function* Caller) = 0;
+
/// removeDeadFunctions - Remove dead functions that are not included in
/// DNR (Do Not Remove) list.
bool removeDeadFunctions(CallGraph &CG,
Modified: llvm/trunk/include/llvm/Transforms/Utils/InlineCost.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/InlineCost.h?rev=61969&r1=61968&r2=61969&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Transforms/Utils/InlineCost.h (original)
+++ llvm/trunk/include/llvm/Transforms/Utils/InlineCost.h Thu Jan 8 19:30:11 2009
@@ -128,6 +128,11 @@
/// getInlineFudgeFactor - Return a > 1.0 factor if the inliner should use a
/// higher threshold to determine if the function call should be inlined.
float getInlineFudgeFactor(CallSite CS);
+
+ /// resetCachedFunctionInfo - erase any cached cost info for this function.
+ void resetCachedCostInfo(Function* Caller) {
+ CachedFunctionInfo[Caller].NumBlocks = 0;
+ }
};
}
Modified: llvm/trunk/lib/Transforms/IPO/InlineAlways.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/InlineAlways.cpp?rev=61969&r1=61968&r2=61969&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/InlineAlways.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/InlineAlways.cpp Thu Jan 8 19:30:11 2009
@@ -45,6 +45,9 @@
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);
}
Modified: llvm/trunk/lib/Transforms/IPO/InlineSimple.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/InlineSimple.cpp?rev=61969&r1=61968&r2=61969&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/InlineSimple.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/InlineSimple.cpp Thu Jan 8 19:30:11 2009
@@ -43,6 +43,9 @@
float getInlineFudgeFactor(CallSite CS) {
return CA.getInlineFudgeFactor(CS);
}
+ void resetCachedCostInfo(Function *Caller) {
+ CA.resetCachedCostInfo(Caller);
+ }
virtual bool doInitialization(CallGraph &CG);
};
}
Modified: llvm/trunk/lib/Transforms/IPO/Inliner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/Inliner.cpp?rev=61969&r1=61968&r2=61969&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/Inliner.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/Inliner.cpp Thu Jan 8 19:30:11 2009
@@ -185,9 +185,14 @@
// 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
Modified: llvm/trunk/lib/Transforms/Utils/InlineCost.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/InlineCost.cpp?rev=61969&r1=61968&r2=61969&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/InlineCost.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/InlineCost.cpp Thu Jan 8 19:30:11 2009
@@ -127,7 +127,7 @@
}
if (const AllocaInst *AI = dyn_cast<AllocaInst>(II)) {
- if (!isa<ConstantInt>(AI->getArraySize()))
+ if (!AI->isStaticAlloca())
this->usesDynamicAlloca = true;
}
@@ -229,18 +229,20 @@
if (CalleeFI.NeverInline)
return InlineCost::getNever();
- // 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);
-
- // 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();
+ 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);
+
+ // 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
More information about the llvm-commits
mailing list