mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-24 22:24:54 +00:00
Add InlineCost class for represent the estimated cost of inlining a
function. - This explicitly models the costs for functions which should "always" or "never" be inlined. This fixes bugs where such costs were not previously respected. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58450 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
#define LLVM_TRANSFORMS_UTILS_INLINECOST_H
|
||||
|
||||
#include "llvm/ADT/SmallPtrSet.h"
|
||||
#include <cassert>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
@@ -24,6 +25,41 @@ namespace llvm {
|
||||
class Function;
|
||||
class CallSite;
|
||||
|
||||
/// InlineCost - Represent the cost of inlining a function. This
|
||||
/// supports special values for functions which should "always" or
|
||||
/// "never" be inlined. Otherwise, the cost represents a unitless
|
||||
/// amount; smaller values increase the likelyhood of the function
|
||||
/// being inlined.
|
||||
class InlineCost {
|
||||
enum Kind {
|
||||
Value,
|
||||
Always,
|
||||
Never
|
||||
};
|
||||
|
||||
int Cost : 30;
|
||||
unsigned Type : 2;
|
||||
|
||||
InlineCost(int C, int T) : Cost(C), Type(T) {
|
||||
assert(Cost == C && "Cost exceeds InlineCost precision");
|
||||
}
|
||||
public:
|
||||
static InlineCost get(int Cost) { return InlineCost(Cost, Value); }
|
||||
static InlineCost getAlways() { return InlineCost(0, Always); }
|
||||
static InlineCost getNever() { return InlineCost(0, Never); }
|
||||
|
||||
bool isVariable() const { return Type == Value; }
|
||||
bool isAlways() const { return Type == Always; }
|
||||
bool isNever() const { return Type == Never; }
|
||||
|
||||
/// getValue() - Return a "variable" inline cost's amount. It is
|
||||
/// an error to call this on an "always" or "never" InlineCost.
|
||||
int getValue() const {
|
||||
assert(Type == Value && "Invalid access of InlineCost");
|
||||
return Cost;
|
||||
}
|
||||
};
|
||||
|
||||
/// InlineCostAnalyzer - Cost analyzer used by inliner.
|
||||
class InlineCostAnalyzer {
|
||||
struct ArgInfo {
|
||||
@@ -83,8 +119,8 @@ namespace llvm {
|
||||
/// getInlineCost - The heuristic used to determine if we should inline the
|
||||
/// function call or not.
|
||||
///
|
||||
int getInlineCost(CallSite CS,
|
||||
SmallPtrSet<const Function *, 16> &NeverInline);
|
||||
InlineCost getInlineCost(CallSite CS,
|
||||
SmallPtrSet<const Function *, 16> &NeverInline);
|
||||
|
||||
/// getInlineFudgeFactor - Return a > 1.0 factor if the inliner should use a
|
||||
/// higher threshold to determine if the function call should be inlined.
|
||||
|
Reference in New Issue
Block a user