aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/Transforms
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-10-13 18:24:11 +0000
committerDan Gohman <gohman@apple.com>2009-10-13 18:24:11 +0000
commit9b39cf5ac82e21935aeebb88d8c3893d927eec1f (patch)
treeeab82c9ff13e8bf33527fd866b32046356303ccf /include/llvm/Transforms
parent11f15dbb287b5d9aa63913f84ce931569a5ebdf3 (diff)
downloadexternal_llvm-9b39cf5ac82e21935aeebb88d8c3893d927eec1f.zip
external_llvm-9b39cf5ac82e21935aeebb88d8c3893d927eec1f.tar.gz
external_llvm-9b39cf5ac82e21935aeebb88d8c3893d927eec1f.tar.bz2
Start refactoring the inline cost estimation code so that it can be used
for purposes other than inlining. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83997 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Transforms')
-rw-r--r--include/llvm/Transforms/Utils/InlineCost.h24
1 files changed, 16 insertions, 8 deletions
diff --git a/include/llvm/Transforms/Utils/InlineCost.h b/include/llvm/Transforms/Utils/InlineCost.h
index bfcb546..e0fee85 100644
--- a/include/llvm/Transforms/Utils/InlineCost.h
+++ b/include/llvm/Transforms/Utils/InlineCost.h
@@ -23,6 +23,7 @@ namespace llvm {
class Value;
class Function;
+ class BasicBlock;
class CallSite;
template<class PtrType, unsigned SmallSize>
class SmallPtrSet;
@@ -96,9 +97,9 @@ namespace llvm {
: ConstantWeight(CWeight), AllocaWeight(AWeight) {}
};
- // FunctionInfo - For each function, calculate the size of it in blocks and
- // instructions.
- struct FunctionInfo {
+ // RegionInfo - Calculate size and a few related metrics for a set of
+ // basic blocks.
+ struct RegionInfo {
/// NeverInline - True if this callee should never be inlined into a
/// caller.
bool NeverInline;
@@ -115,17 +116,24 @@ namespace llvm {
/// kernels.
unsigned NumVectorInsts;
+ /// NumRets - Keep track of how many Ret instructions the block contains.
+ unsigned NumRets;
+
/// ArgumentWeights - Each formal argument of the function is inspected to
/// see if it is used in any contexts where making it a constant or alloca
/// would reduce the code size. If so, we add some value to the argument
/// entry here.
std::vector<ArgInfo> ArgumentWeights;
- FunctionInfo() : NeverInline(false), usesDynamicAlloca(false), NumInsts(0),
- NumBlocks(0), NumVectorInsts(0) {}
+ RegionInfo() : NeverInline(false), usesDynamicAlloca(false), NumInsts(0),
+ NumBlocks(0), NumVectorInsts(0), NumRets(0) {}
- /// analyzeFunction - Fill in the current structure with information
- /// gleaned from the specified function.
+ /// analyzeBasicBlock - Add information about the specified basic block
+ /// to the current structure.
+ void analyzeBasicBlock(const BasicBlock *BB);
+
+ /// analyzeFunction - Add information about the specified function
+ /// to the current structure.
void analyzeFunction(Function *F);
/// CountCodeReductionForConstant - Figure out an approximation for how
@@ -140,7 +148,7 @@ namespace llvm {
unsigned CountCodeReductionForAlloca(Value *V);
};
- std::map<const Function *, FunctionInfo> CachedFunctionInfo;
+ std::map<const Function *, RegionInfo> CachedFunctionInfo;
public: