LLVM 20.0.0git
Classes | Namespaces | Macros | Typedefs | Functions | Variables
MLRegAllocEvictAdvisor.cpp File Reference
#include "AllocationOrder.h"
#include "RegAllocEvictionAdvisor.h"
#include "RegAllocGreedy.h"
#include "llvm/Analysis/InteractiveModelRunner.h"
#include "llvm/Analysis/MLModelRunner.h"
#include "llvm/Analysis/TensorSpec.h"
#include "MLRegAllocEvictAdvisor.h"
#include "llvm/Analysis/ReleaseModeModelRunner.h"
#include "llvm/CodeGen/CalcSpillWeights.h"
#include "llvm/CodeGen/LiveRegMatrix.h"
#include "llvm/CodeGen/MachineBlockFrequencyInfo.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineLoopInfo.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/Passes.h"
#include "llvm/CodeGen/RegisterClassInfo.h"
#include "llvm/CodeGen/VirtRegMap.h"
#include "llvm/IR/Module.h"
#include "llvm/InitializePasses.h"
#include "llvm/Pass.h"
#include "llvm/PassRegistry.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ErrorHandling.h"
#include <array>
#include <bitset>
#include <memory>

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, __, ___)   name
 
#define _FEATURE_IDX(A, B, C, D)   _FEATURE_IDX_SIMPLE(A, B, C, D),
 
#define _RESET(TYPE, NAME, SHAPE, __)
 
#define _DECL_FEATURES(type, name, shape, _)    TensorSpec::createSpec<type>(#name, shape),
 
#define SET(ID, TYPE, VAL)
 

Typedefs

using CompiledModelType = NoopSavedModelImpl
 

Functions

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::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"))
 
static cl::opt< unsignedMaxCascade ("mlregalloc-max-cascade", cl::Hidden, cl::desc("The maximum number of times a live range can be " "evicted before preventing it from being evicted"), cl::init(20))
 
static const bool EnableDevelopmentFeatures = false
 
cl::opt< unsignedllvm::EvictInterferenceCutoff
 

Macro Definition Documentation

◆ _DECL_FEATURES

#define _DECL_FEATURES (   type,
  name,
  shape,
  _ 
)     TensorSpec::createSpec<type>(#name, shape),

◆ _FEATURE_IDX

#define _FEATURE_IDX (   A,
  B,
  C,
  D 
)    _FEATURE_IDX_SIMPLE(A, B, C, D),

◆ _FEATURE_IDX_SIMPLE

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

◆ _RESET

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

◆ DEBUG_TYPE

#define DEBUG_TYPE   "ml-regalloc"

Definition at line 48 of file MLRegAllocEvictAdvisor.cpp.

◆ DecisionName

#define DecisionName   "index_to_evict"

◆ RA_EVICT_FEATURES_LIST

#define RA_EVICT_FEATURES_LIST (   M)

◆ RA_EVICT_FIRST_DEVELOPMENT_FEATURE

#define RA_EVICT_FIRST_DEVELOPMENT_FEATURE (   M)

◆ RA_EVICT_REST_DEVELOPMENT_FEATURES

#define RA_EVICT_REST_DEVELOPMENT_FEATURES (   M)

◆ 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)

Typedef Documentation

◆ CompiledModelType

Definition at line 55 of file MLRegAllocEvictAdvisor.cpp.

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.

Definition at line 132 of file MLRegAllocEvictAdvisor.cpp.

References _DECL_FEATURES, _FEATURE_IDX, _FEATURE_IDX_SIMPLE, _RESET, llvm::AnalysisUsage::addRequired(), llvm::append_range(), llvm::RegAllocEvictionAdvisor::canEvictHintInterference(), llvm::DecisionName, DecisionName, llvm::DecisionSpec, llvm::RegAllocEvictionAdvisorAnalysis::Development, llvm::Pass::doInitialization(), llvm::LLVMContext::emitError(), EnableDevelopmentFeatures, llvm::FeatureCount, llvm::RegAllocEvictionAdvisorAnalysis::getAdvisor(), llvm::RegAllocEvictionAdvisorAnalysis::getAnalysisUsage(), llvm::Function::getContext(), llvm::MachineFunction::getFunction(), llvm::MachineFunction::getName(), llvm::InputFeatures, InteractiveChannelBaseName, llvm::RegAllocEvictionAdvisorAnalysis::logRewardIfNeeded(), Loops, llvm::NumberOfInterferences, OS, llvm::PerLiveRangeShape, RA, RA_EVICT_FEATURES_LIST, RA_EVICT_FIRST_DEVELOPMENT_FEATURE, RA_EVICT_REST_DEVELOPMENT_FEATURES, llvm::RegAllocEvictionAdvisorAnalysis::Release, and llvm::RegAllocEvictionAdvisor::tryFindEvictionCandidate().

Variable Documentation

◆ EnableDevelopmentFeatures

const bool EnableDevelopmentFeatures = false
static

Definition at line 91 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

◆ MaxCascade

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