24#define DEBUG_TYPE "amdgpu-mark-last-scratch-load"
28class AMDGPUMarkLastScratchLoad {
37 : LS(LS), LIS(LIS), SI(SI) {}
58 return "AMDGPU Mark Last Scratch Load";
64bool AMDGPUMarkLastScratchLoadLegacy::runOnMachineFunction(
69 auto &
LS = getAnalysis<LiveStacksWrapperLegacy>().getLS();
70 auto &LIS = getAnalysis<LiveIntervalsWrapperPass>().getLIS();
71 auto &
SI = getAnalysis<SlotIndexesWrapperPass>().getSI();
73 return AMDGPUMarkLastScratchLoad(&LS, &LIS, &SI).run(MF);
83 AMDGPUMarkLastScratchLoad(&LS, &LIS, &SI).
run(MF);
92 SII = ST.getInstrInfo();
95 const unsigned NumSlots = LS->getNumIntervals();
103 bool Changed =
false;
105 for (
auto &[SS, LI] : *LS) {
113 const int FrameIndex = LI.reg().stackSlotIndex();
122 MISegmentEnd = SI->getInstructionFromIndex(NextSlot);
131 if (MISegmentStart && MISegmentStart->
getParent() == BB)
137 if (SII->isLoadFromStackSlot(*
MI, LoadFI) && LoadFI == FrameIndex) {
155char AMDGPUMarkLastScratchLoadLegacy::ID = 0;
160 "AMDGPU Mark last scratch load",
false,
false)
AMDGPU Mark last scratch load
AMD GCN specific subclass of TargetSubtarget.
#define INITIALIZE_PASS_DEPENDENCY(depName)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &AM)
A container for analyses that lazily runs them and caches their results.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Represent the analysis usage information of a pass.
AnalysisUsage & addRequired()
void setPreservesAll()
Set by analyses that do not transform their input at all.
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.
virtual bool runOnMachineFunction(MachineFunction &MF)=0
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
Function & getFunction()
Return the LLVM function that this machine code represents.
Representation of each machine instruction.
const MachineBasicBlock * getParent() const
bool memoperands_empty() const
Return true if we don't have any memory operands which described the memory access done by this instr...
mmo_iterator memoperands_begin() const
Access to memory operands of the instruction.
A description of a memory reference used in the backend.
void setFlags(Flags f)
Bitwise OR the current flags with the given flags.
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
SlotIndex - An opaque wrapper around machine indexes.
bool isBlock() const
isBlock - Returns true if this is a block boundary slot.
LLVM_ABI Result run(MachineFunction &MF, MachineFunctionAnalysisManager &)
SlotIndex getNextNonNullIndex(SlotIndex Index)
Returns the next non-null index, if one exists.
StringRef - Represent a constant reference to a string, i.e.
reverse_self_iterator getReverseIterator()
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
static const MachineMemOperand::Flags MOLastUse
Mark the MMO of a load as the last use.
char & AMDGPUMarkLastScratchLoadID
This represents a simple continuous liveness interval for a value.