mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-26 12:20:42 +00:00
Split code not specific to Function inlining out into a separate class,
named CodeMetrics. Move it to be a non-nested class. Rename RegionInfo back to FunctionInfo. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84013 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -28,6 +28,40 @@ namespace llvm {
|
||||
template<class PtrType, unsigned SmallSize>
|
||||
class SmallPtrSet;
|
||||
|
||||
// CodeMetrics - Calculate size and a few similar metrics for a set of
|
||||
// basic blocks.
|
||||
struct CodeMetrics {
|
||||
/// NeverInline - True if this callee should never be inlined into a
|
||||
/// caller.
|
||||
bool NeverInline;
|
||||
|
||||
/// usesDynamicAlloca - True if this function calls alloca (in the C sense).
|
||||
bool usesDynamicAlloca;
|
||||
|
||||
/// NumInsts, NumBlocks - Keep track of how large each function is, which
|
||||
/// is used to estimate the code size cost of inlining it.
|
||||
unsigned NumInsts, NumBlocks;
|
||||
|
||||
/// NumVectorInsts - Keep track of how many instructions produce vector
|
||||
/// values. The inliner is being more aggressive with inlining vector
|
||||
/// kernels.
|
||||
unsigned NumVectorInsts;
|
||||
|
||||
/// NumRets - Keep track of how many Ret instructions the block contains.
|
||||
unsigned NumRets;
|
||||
|
||||
CodeMetrics() : NeverInline(false), usesDynamicAlloca(false), NumInsts(0),
|
||||
NumBlocks(0), NumVectorInsts(0), NumRets(0) {}
|
||||
|
||||
/// 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);
|
||||
};
|
||||
|
||||
namespace InlineConstants {
|
||||
// Various magic constants used to adjust heuristics.
|
||||
const int CallPenalty = 5;
|
||||
@@ -97,58 +131,32 @@ namespace llvm {
|
||||
: ConstantWeight(CWeight), AllocaWeight(AWeight) {}
|
||||
};
|
||||
|
||||
// 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;
|
||||
|
||||
/// usesDynamicAlloca - True if this function calls alloca (in the C sense).
|
||||
bool usesDynamicAlloca;
|
||||
|
||||
/// NumInsts, NumBlocks - Keep track of how large each function is, which
|
||||
/// is used to estimate the code size cost of inlining it.
|
||||
unsigned NumInsts, NumBlocks;
|
||||
|
||||
/// NumVectorInsts - Keep track of how many instructions produce vector
|
||||
/// values. The inliner is being more aggressive with inlining vector
|
||||
/// kernels.
|
||||
unsigned NumVectorInsts;
|
||||
|
||||
/// NumRets - Keep track of how many Ret instructions the block contains.
|
||||
unsigned NumRets;
|
||||
struct FunctionInfo {
|
||||
CodeMetrics Metrics;
|
||||
|
||||
/// 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;
|
||||
|
||||
RegionInfo() : NeverInline(false), usesDynamicAlloca(false), NumInsts(0),
|
||||
NumBlocks(0), NumVectorInsts(0), NumRets(0) {}
|
||||
|
||||
/// 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
|
||||
/// many instructions will be constant folded if the specified value is
|
||||
/// constant.
|
||||
unsigned CountCodeReductionForConstant(Value *V);
|
||||
|
||||
|
||||
/// CountCodeReductionForAlloca - Figure out an approximation of how much
|
||||
/// smaller the function will be if it is inlined into a context where an
|
||||
/// argument becomes an alloca.
|
||||
///
|
||||
unsigned CountCodeReductionForAlloca(Value *V);
|
||||
|
||||
/// analyzeFunction - Add information about the specified function
|
||||
/// to the current structure.
|
||||
void analyzeFunction(Function *F);
|
||||
};
|
||||
|
||||
std::map<const Function *, RegionInfo> CachedFunctionInfo;
|
||||
std::map<const Function *, FunctionInfo> CachedFunctionInfo;
|
||||
|
||||
public:
|
||||
|
||||
@@ -164,7 +172,7 @@ namespace llvm {
|
||||
|
||||
/// resetCachedFunctionInfo - erase any cached cost info for this function.
|
||||
void resetCachedCostInfo(Function* Caller) {
|
||||
CachedFunctionInfo[Caller].NumBlocks = 0;
|
||||
CachedFunctionInfo[Caller].Metrics.NumBlocks = 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user