1 //===--- StackMapLivenessAnalysis - StackMap Liveness Analysis --*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // 10 // This pass calculates the liveness for each basic block in a function and 11 // attaches the register live-out information to a patchpoint intrinsic (if 12 // present). 13 // 14 //===----------------------------------------------------------------------===// 15 16 #ifndef LLVM_CODEGEN_STACKMAPLIVENESSANALYSIS_H 17 #define LLVM_CODEGEN_STACKMAPLIVENESSANALYSIS_H 18 19 #include "llvm/CodeGen/LivePhysRegs.h" 20 #include "llvm/CodeGen/MachineFunctionPass.h" 21 22 23 namespace llvm { 24 25 /// \brief This pass calculates the liveness information for each basic block in 26 /// a function and attaches the register live-out information to a patchpoint 27 /// intrinsic if present. 28 /// 29 /// This pass can be disabled via the -enable-patchpoint-liveness=false flag. 30 /// The pass skips functions that don't have any patchpoint intrinsics. The 31 /// information provided by this pass is optional and not required by the 32 /// aformentioned intrinsic to function. 33 class StackMapLiveness : public MachineFunctionPass { 34 MachineFunction *MF; 35 const TargetRegisterInfo *TRI; 36 LivePhysRegs LiveRegs; 37 public: 38 static char ID; 39 40 /// \brief Default construct and initialize the pass. 41 StackMapLiveness(); 42 43 /// \brief Tell the pass manager which passes we depend on and what 44 /// information we preserve. 45 void getAnalysisUsage(AnalysisUsage &AU) const override; 46 47 /// \brief Calculate the liveness information for the given machine function. 48 bool runOnMachineFunction(MachineFunction &MF) override; 49 50 private: 51 /// \brief Performs the actual liveness calculation for the function. 52 bool calculateLiveness(); 53 54 /// \brief Add the current register live set to the instruction. 55 void addLiveOutSetToMI(MachineInstr &MI); 56 57 /// \brief Create a register mask and initialize it with the registers from 58 /// the register live set. 59 uint32_t *createRegisterMask() const; 60 }; 61 62 } // llvm namespace 63 64 #endif 65