summaryrefslogtreecommitdiff
path: root/include/llvm/Analysis
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2013-01-21 11:39:18 +0000
committerChandler Carruth <chandlerc@gmail.com>2013-01-21 11:39:18 +0000
commit86953b5795007eaa98838297360a6987e33e92e7 (patch)
tree8958a38475e5e185639a31da6b9ec61400e67826 /include/llvm/Analysis
parent0378e3916a3d568ee161803d4f0107512e595af8 (diff)
downloadllvm-86953b5795007eaa98838297360a6987e33e92e7.tar.gz
llvm-86953b5795007eaa98838297360a6987e33e92e7.tar.bz2
llvm-86953b5795007eaa98838297360a6987e33e92e7.tar.xz
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173030 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Analysis')
-rw-r--r--include/llvm/Analysis/InlineCost.h16
1 files changed, 12 insertions, 4 deletions
diff --git a/include/llvm/Analysis/InlineCost.h b/include/llvm/Analysis/InlineCost.h
index dfdfe3e4f8..3d81529178 100644
--- a/include/llvm/Analysis/InlineCost.h
+++ b/include/llvm/Analysis/InlineCost.h
@@ -15,6 +15,7 @@
#define LLVM_ANALYSIS_INLINECOST_H
#include "llvm/Analysis/CodeMetrics.h"
+#include "llvm/Analysis/CallGraphSCCPass.h"
#include <cassert>
#include <climits>
@@ -97,14 +98,18 @@ public:
};
/// \brief Cost analyzer used by inliner.
-class InlineCostAnalyzer {
- // DataLayout if available, or null.
+class InlineCostAnalysis : public CallGraphSCCPass {
const DataLayout *TD;
public:
- InlineCostAnalyzer() : TD(0) {}
+ static char ID;
- void setDataLayout(const DataLayout *TData) { TD = TData; }
+ InlineCostAnalysis();
+ ~InlineCostAnalysis();
+
+ // Pass interface implementation.
+ void getAnalysisUsage(AnalysisUsage &AU) const;
+ bool runOnSCC(CallGraphSCC &SCC);
/// \brief Get an InlineCost object representing the cost of inlining this
/// callsite.
@@ -113,6 +118,9 @@ public:
/// threshold are computed with any accuracy. The threshold can be used to
/// bound the computation necessary to determine whether the cost is
/// sufficiently low to warrant inlining.
+ ///
+ /// Also note that calling this function *dynamically* computes the cost of
+ /// inlining the callsite. It is an expensive, heavyweight call.
InlineCost getInlineCost(CallSite CS, int Threshold);
/// \brief Get an InlineCost with the callee explicitly specified.