29#define DEBUG_TYPE "stackmaps"
33 cl::desc(
"Enable PatchPoint Liveness Analysis Pass"));
35STATISTIC(NumStackMapFuncVisited,
"Number of functions visited");
36STATISTIC(NumStackMapFuncSkipped,
"Number of functions skipped");
37STATISTIC(NumBBsVisited,
"Number of basic blocks visited");
38STATISTIC(NumBBsHaveNoStackmap,
"Number of basic blocks with no stackmap");
39STATISTIC(NumStackMaps,
"Number of StackMaps visited");
69 bool runOnMachineFunction(MachineFunction &MF)
override;
73 bool calculateLiveness(MachineFunction &MF);
76 void addLiveOutSetToMI(MachineFunction &MF, MachineInstr &
MI);
80 uint32_t *createRegisterMask(MachineFunction &MF)
const;
84char StackMapLiveness::ID = 0;
87 "StackMap Liveness Analysis",
false,
false)
96void StackMapLiveness::getAnalysisUsage(
AnalysisUsage &AU)
const {
104bool StackMapLiveness::runOnMachineFunction(MachineFunction &MF) {
109 ++NumStackMapFuncVisited;
113 ++NumStackMapFuncSkipped;
116 return calculateLiveness(MF);
120bool StackMapLiveness::calculateLiveness(MachineFunction &MF) {
122 << MF.
getName() <<
" **********\n");
123 bool HasChanged =
false;
125 for (
auto &
MBB : MF) {
129 bool HasStackMap =
false;
133 if (
MI.getOpcode() == TargetOpcode::PATCHPOINT) {
134 addLiveOutSetToMI(MF,
MI);
144 ++NumBBsHaveNoStackmap;
150void StackMapLiveness::addLiveOutSetToMI(MachineFunction &MF,
152 uint32_t *
Mask = createRegisterMask(MF);
154 MI.addOperand(MF, MO);
159uint32_t *StackMapLiveness::createRegisterMask(MachineFunction &MF)
const {
162 for (
auto Reg : LiveRegs)
166 TRI->adjustStackMapLiveOutMask(Mask);
This file implements the LivePhysRegs utility for tracking liveness of physical registers.
Register const TargetRegisterInfo * TRI
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
static cl::opt< bool > EnablePatchPointLiveness("enable-patchpoint-liveness", cl::Hidden, cl::init(true), cl::desc("Enable PatchPoint Liveness Analysis Pass"))
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
Represent the analysis usage information of a pass.
LLVM_ABI void setPreservesCFG()
This function should be called by the pass, iff they do not:
void setPreservesAll()
Set by analyses that do not transform their input at all.
A set of physical registers with utility functions to track liveness when walking backward/forward th...
void stepBackward(const MachineInstr &MI)
Simulates liveness when stepping backwards over an instruction(bundle).
void init(const TargetRegisterInfo &TRI)
(re-)initializes and clears the set.
void addLiveOuts(const MachineBasicBlock &MBB)
Adds all live-out registers of basic block MBB.
LLVM_ABI StringRef getName() const
Return the name of the corresponding LLVM basic block, or an empty string.
bool hasPatchPoint() const
This method may be called any time after instruction selection is complete to determine if there is a...
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
Properties which a MachineFunction may have at a given point in time.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
uint32_t * allocateRegMask()
Allocate and initialize a register mask with NumRegister bits.
static MachineOperand CreateRegLiveOut(const uint32_t *Mask)
static LLVM_ABI PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
virtual const TargetRegisterInfo * getRegisterInfo() const =0
Return the target's register information.
constexpr std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
initializer< Ty > init(const Ty &Val)
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI void initializeStackMapLivenessPass(PassRegistry &)
auto reverse(ContainerTy &&C)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_ABI char & StackMapLivenessID
StackMapLiveness - This pass analyses the register live-out set of stackmap/patchpoint intrinsics and...