diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2013-01-21 11:39:18 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2013-01-21 11:39:18 +0000 |
commit | 4319e2948d477595a85e6b5c8d4eb4cdfde7330d (patch) | |
tree | a18943deaddc9d7e538ad229b9ad273ff8d06836 /llvm/lib/Transforms/IPO/InlineAlways.cpp | |
parent | 7e88e744479ebd8121741460bfbac2e541756d1c (diff) | |
download | bcm5719-llvm-4319e2948d477595a85e6b5c8d4eb4cdfde7330d.tar.gz bcm5719-llvm-4319e2948d477595a85e6b5c8d4eb4cdfde7330d.zip |
Make the inline cost a proper analysis pass. This remains essentially
a dynamic analysis done on each call to the routine. However, now it can
use the standard pass infrastructure to reference other analyses,
instead of a silly setter method. This will become more interesting as
I teach it about more analysis passes.
This updates the two inliner passes to use the inline cost analysis.
Doing so highlights how utterly redundant these two passes are. Either
we should find a cheaper way to do always inlining, or we should merge
the two and just fiddle with the thresholds to get the desired behavior.
I'm leaning increasingly toward the latter as it would also remove the
Inliner sub-class split.
llvm-svn: 173030
Diffstat (limited to 'llvm/lib/Transforms/IPO/InlineAlways.cpp')
-rw-r--r-- | llvm/lib/Transforms/IPO/InlineAlways.cpp | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/llvm/lib/Transforms/IPO/InlineAlways.cpp b/llvm/lib/Transforms/IPO/InlineAlways.cpp index 5937fab472b..a0095dad1af 100644 --- a/llvm/lib/Transforms/IPO/InlineAlways.cpp +++ b/llvm/lib/Transforms/IPO/InlineAlways.cpp @@ -32,16 +32,16 @@ namespace { /// \brief Inliner pass which only handles "always inline" functions. class AlwaysInliner : public Inliner { - InlineCostAnalyzer CA; + InlineCostAnalysis *ICA; public: // Use extremely low threshold. - AlwaysInliner() : Inliner(ID, -2000000000, /*InsertLifetime*/ true) { + AlwaysInliner() : Inliner(ID, -2000000000, /*InsertLifetime*/ true), ICA(0) { initializeAlwaysInlinerPass(*PassRegistry::getPassRegistry()); } AlwaysInliner(bool InsertLifetime) - : Inliner(ID, -2000000000, InsertLifetime) { + : Inliner(ID, -2000000000, InsertLifetime), ICA(0) { initializeAlwaysInlinerPass(*PassRegistry::getPassRegistry()); } @@ -49,13 +49,13 @@ public: virtual InlineCost getInlineCost(CallSite CS); + virtual void getAnalysisUsage(AnalysisUsage &AU) const; + virtual bool runOnSCC(CallGraphSCC &SCC); + using llvm::Pass::doFinalization; virtual bool doFinalization(CallGraph &CG) { return removeDeadFunctions(CG, /*AlwaysInlineOnly=*/ true); } - - using llvm::Pass::doInitialization; - virtual bool doInitialization(CallGraph &CG); }; } @@ -64,6 +64,7 @@ char AlwaysInliner::ID = 0; INITIALIZE_PASS_BEGIN(AlwaysInliner, "always-inline", "Inliner for always_inline functions", false, false) INITIALIZE_AG_DEPENDENCY(CallGraph) +INITIALIZE_PASS_DEPENDENCY(InlineCostAnalysis) INITIALIZE_PASS_END(AlwaysInliner, "always-inline", "Inliner for always_inline functions", false, false) @@ -94,13 +95,18 @@ InlineCost AlwaysInliner::getInlineCost(CallSite CS) { if (Callee && !Callee->isDeclaration() && Callee->getAttributes().hasAttribute(AttributeSet::FunctionIndex, Attribute::AlwaysInline) && - CA.isInlineViable(*Callee)) + ICA->isInlineViable(*Callee)) return InlineCost::getAlways(); return InlineCost::getNever(); } -bool AlwaysInliner::doInitialization(CallGraph &CG) { - CA.setDataLayout(getAnalysisIfAvailable<DataLayout>()); - return false; +bool AlwaysInliner::runOnSCC(CallGraphSCC &SCC) { + ICA = &getAnalysis<InlineCostAnalysis>(); + return Inliner::runOnSCC(SCC); +} + +void AlwaysInliner::getAnalysisUsage(AnalysisUsage &AU) const { + AU.addRequired<InlineCostAnalysis>(); + Inliner::getAnalysisUsage(AU); } |