LLVM 22.0.0git
MLRegAllocEvictAdvisor.cpp File Reference

Go to the source code of this file.

Classes

class  llvm::RegAllocScoring

Namespaces

namespace  llvm
 This is an optimization pass for GlobalISel generic memory operations.

Macros

#define DEBUG_TYPE   "ml-regalloc"
#define RA_EVICT_FEATURES_LIST(M)
#define RA_EVICT_FIRST_DEVELOPMENT_FEATURE(M)
#define RA_EVICT_REST_DEVELOPMENT_FEATURES(M)
#define DecisionName   "index_to_evict"
#define _FEATURE_IDX_SIMPLE(_, name, __, ___)
#define _FEATURE_IDX(A, B, C, D)
#define _RESET(TYPE, NAME, SHAPE, __)
#define _DECL_FEATURES(type, name, shape, _)
#define SET(ID, TYPE, VAL)

Functions

LLVM_ABI FunctionPassllvm::createRegAllocScoringPass ()
 When learning an eviction policy, extract score(reward) information, otherwise this does nothing.
 INITIALIZE_PASS (RegAllocScoring, "regallocscoringpass", "Register Allocation Scoring Pass", false, false) namespace

Variables

static cl::opt< std::stringInteractiveChannelBaseName ("regalloc-evict-interactive-channel-base", cl::Hidden, cl::desc("Base file path for the interactive mode. The incoming filename should " "have the name <regalloc-evict-interactive-channel-base>.in, while the " "outgoing name should be " "<regalloc-evict-interactive-channel-base>.out"))
static cl::opt< unsignedMaxEvictionCount ("mlregalloc-max-eviction-count", cl::Hidden, cl::desc("The maximum number of times a live range can be " "evicted before preventing it from being evicted"), cl::init(100))
static const bool EnableDevelopmentFeatures = false
cl::opt< unsignedllvm::EvictInterferenceCutoff

Macro Definition Documentation

◆ _DECL_FEATURES

#define _DECL_FEATURES ( type,
name,
shape,
_ )
Value:
static const char * name
static TensorSpec createSpec(const std::string &Name, const std::vector< int64_t > &Shape, int Port=0)
Definition TensorSpec.h:66

Referenced by INITIALIZE_PASS().

◆ _FEATURE_IDX

#define _FEATURE_IDX ( A,
B,
C,
D )
Value:
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define _FEATURE_IDX_SIMPLE(_, name, __, ___)
@ C
The default llvm calling convention, compatible with C.
Definition CallingConv.h:34

Referenced by INITIALIZE_PASS().

◆ _FEATURE_IDX_SIMPLE

#define _FEATURE_IDX_SIMPLE ( _,
name,
__,
___ )
Value:

Referenced by INITIALIZE_PASS().

◆ _RESET

#define _RESET ( TYPE,
NAME,
SHAPE,
__ )
Value:
std::memset(Runner.getTensorUntyped(FeatureIDs::NAME), 0, \
getTotalSize<TYPE>(SHAPE));

Referenced by INITIALIZE_PASS().

◆ DEBUG_TYPE

#define DEBUG_TYPE   "ml-regalloc"

Definition at line 49 of file MLRegAllocEvictAdvisor.cpp.

◆ DecisionName

#define DecisionName   "index_to_evict"

Referenced by INITIALIZE_PASS().

◆ RA_EVICT_FEATURES_LIST

#define RA_EVICT_FEATURES_LIST ( M)

Referenced by INITIALIZE_PASS().

◆ RA_EVICT_FIRST_DEVELOPMENT_FEATURE

#define RA_EVICT_FIRST_DEVELOPMENT_FEATURE ( M)

Referenced by INITIALIZE_PASS().

◆ RA_EVICT_REST_DEVELOPMENT_FEATURES

#define RA_EVICT_REST_DEVELOPMENT_FEATURES ( M)

Referenced by INITIALIZE_PASS().

◆ SET

#define SET ( ID,
TYPE,
VAL )
Value:
do { \
Runner->getTensor<TYPE>(FeatureIDs::ID)[Pos] = static_cast<TYPE>(VAL); \
if (!DoNotNormalize.test(FeatureIDs::ID)) \
Largest[FeatureIDs::ID] = \
std::max(Largest[FeatureIDs::ID], static_cast<float>(VAL)); \
} while (false)

Function Documentation

◆ INITIALIZE_PASS()

INITIALIZE_PASS ( RegAllocScoring ,
"regallocscoringpass" ,
"Register Allocation Scoring Pass" ,
false ,
false  )

The ML evictor (commonalities between release and development mode)

This just calls Evaluate on the Runner, but in the development mode case, if we're just capturing the log of the default advisor, it needs to call the latter instead, so we need to pass all the necessary parameters for it. In the development case, it will also log.

Load the features of the given VirtReg (allocated or not) at column Pos, but if that can't be evicted, return false instead.

Common provider for legacy and new pass managers.

Definition at line 133 of file MLRegAllocEvictAdvisor.cpp.

References _DECL_FEATURES, _FEATURE_IDX, _FEATURE_IDX_SIMPLE, _RESET, llvm::AnalysisUsage::addRequired(), llvm::append_range(), assert(), llvm::RegAllocEvictionAdvisor::canEvictHintInterference(), llvm::TensorSpec::createSpec(), DecisionName, llvm::DecisionSpec, llvm::Pass::doInitialization(), llvm::dyn_cast(), llvm::LLVMContext::emitError(), EnableDevelopmentFeatures, llvm::FeatureCount, llvm::RegAllocEvictionAdvisorProvider::getAdvisor(), llvm::RegAllocEvictionAdvisorAnalysisLegacy::getAnalysisUsage(), llvm::Function::getContext(), llvm::MachineFunction::getFunction(), llvm::MachineFunction::getName(), llvm::Register::id(), llvm::InputFeatures, InteractiveChannelBaseName, llvm::RegAllocEvictionAdvisorAnalysisLegacy::logRewardIfNeeded(), llvm::RegAllocEvictionAdvisorProvider::logRewardIfNeeded(), Loops, llvm::NumberOfInterferences, llvm::PerLiveRangeShape, RA, RA_EVICT_FEATURES_LIST, RA_EVICT_FIRST_DEVELOPMENT_FEATURE, RA_EVICT_REST_DEVELOPMENT_FEATURES, Reg, llvm::RegAllocEvictionAdvisorAnalysisLegacy::RegAllocEvictionAdvisorAnalysisLegacy(), llvm::RegAllocEvictionAdvisorProvider::RegAllocEvictionAdvisorProvider(), T, and llvm::RegAllocEvictionAdvisor::tryFindEvictionCandidate().

Variable Documentation

◆ EnableDevelopmentFeatures

const bool EnableDevelopmentFeatures = false
static

Definition at line 92 of file MLRegAllocEvictAdvisor.cpp.

Referenced by INITIALIZE_PASS().

◆ InteractiveChannelBaseName

cl::opt< std::string > InteractiveChannelBaseName("regalloc-evict-interactive-channel-base", cl::Hidden, cl::desc( "Base file path for the interactive mode. The incoming filename should " "have the name <regalloc-evict-interactive-channel-base>.in, while the " "outgoing name should be " "<regalloc-evict-interactive-channel-base>.out")) ( "regalloc-evict-interactive-channel-base" ,
cl::Hidden ,
cl::desc( "Base file path for the interactive mode. The incoming filename should " "have the name <regalloc-evict-interactive-channel-base>.in, while the " "outgoing name should be " "<regalloc-evict-interactive-channel-base>.out")  )
static

◆ MaxEvictionCount

cl::opt< unsigned > MaxEvictionCount("mlregalloc-max-eviction-count", cl::Hidden, cl::desc("The maximum number of times a live range can be " "evicted before preventing it from being evicted"), cl::init(100)) ( "mlregalloc-max-eviction-count" ,
cl::Hidden ,
cl::desc("The maximum number of times a live range can be " "evicted before preventing it from being evicted") ,
cl::init(100)  )
static