diff options
author | Akshat Oke <Akshat.Oke@amd.com> | 2024-12-06 15:16:07 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-06 15:16:07 +0530 |
commit | 2c7ece2e8cf58d607f870ca9f02302df8aaa75d4 (patch) | |
tree | 165aee948ccca8a94b6b9bac209e7e4b19e774ed /llvm/lib/CodeGen | |
parent | 91d6e10cca4ea8d50927aba024f33c9076785d3a (diff) | |
download | llvm-2c7ece2e8cf58d607f870ca9f02302df8aaa75d4.zip llvm-2c7ece2e8cf58d607f870ca9f02302df8aaa75d4.tar.gz llvm-2c7ece2e8cf58d607f870ca9f02302df8aaa75d4.tar.bz2 |
[CodeGen][NewPM] Port LiveStacks analysis to NPM (#118778)
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/CodeGen.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/CodeGen/InlineSpiller.cpp | 4 | ||||
-rw-r--r-- | llvm/lib/CodeGen/LiveStacks.cpp | 45 | ||||
-rw-r--r-- | llvm/lib/CodeGen/MachineVerifier.cpp | 5 | ||||
-rw-r--r-- | llvm/lib/CodeGen/RegAllocBasic.cpp | 6 | ||||
-rw-r--r-- | llvm/lib/CodeGen/RegAllocGreedy.cpp | 6 | ||||
-rw-r--r-- | llvm/lib/CodeGen/RegAllocPBQP.cpp | 6 | ||||
-rw-r--r-- | llvm/lib/CodeGen/StackSlotColoring.cpp | 6 | ||||
-rw-r--r-- | llvm/lib/CodeGen/VirtRegMap.cpp | 6 |
9 files changed, 57 insertions, 29 deletions
diff --git a/llvm/lib/CodeGen/CodeGen.cpp b/llvm/lib/CodeGen/CodeGen.cpp index 5942881..8efe540 100644 --- a/llvm/lib/CodeGen/CodeGen.cpp +++ b/llvm/lib/CodeGen/CodeGen.cpp @@ -62,7 +62,7 @@ void llvm::initializeCodeGen(PassRegistry &Registry) { initializeLiveDebugVariablesWrapperLegacyPass(Registry); initializeLiveIntervalsWrapperPassPass(Registry); initializeLiveRangeShrinkPass(Registry); - initializeLiveStacksPass(Registry); + initializeLiveStacksWrapperLegacyPass(Registry); initializeLiveVariablesWrapperPassPass(Registry); initializeLocalStackSlotPassPass(Registry); initializeLowerGlobalDtorsLegacyPassPass(Registry); diff --git a/llvm/lib/CodeGen/InlineSpiller.cpp b/llvm/lib/CodeGen/InlineSpiller.cpp index e8f7c68..64f290f 100644 --- a/llvm/lib/CodeGen/InlineSpiller.cpp +++ b/llvm/lib/CodeGen/InlineSpiller.cpp @@ -131,7 +131,7 @@ public: HoistSpillHelper(MachineFunctionPass &pass, MachineFunction &mf, VirtRegMap &vrm) : MF(mf), LIS(pass.getAnalysis<LiveIntervalsWrapperPass>().getLIS()), - LSS(pass.getAnalysis<LiveStacks>()), + LSS(pass.getAnalysis<LiveStacksWrapperLegacy>().getLS()), MDT(pass.getAnalysis<MachineDominatorTreeWrapperPass>().getDomTree()), VRM(vrm), MRI(mf.getRegInfo()), TII(*mf.getSubtarget().getInstrInfo()), TRI(*mf.getSubtarget().getRegisterInfo()), @@ -193,7 +193,7 @@ public: InlineSpiller(MachineFunctionPass &Pass, MachineFunction &MF, VirtRegMap &VRM, VirtRegAuxInfo &VRAI) : MF(MF), LIS(Pass.getAnalysis<LiveIntervalsWrapperPass>().getLIS()), - LSS(Pass.getAnalysis<LiveStacks>()), + LSS(Pass.getAnalysis<LiveStacksWrapperLegacy>().getLS()), MDT(Pass.getAnalysis<MachineDominatorTreeWrapperPass>().getDomTree()), VRM(VRM), MRI(MF.getRegInfo()), TII(*MF.getSubtarget().getInstrInfo()), TRI(*MF.getSubtarget().getRegisterInfo()), diff --git a/llvm/lib/CodeGen/LiveStacks.cpp b/llvm/lib/CodeGen/LiveStacks.cpp index 6228a4d..92cc669 100644 --- a/llvm/lib/CodeGen/LiveStacks.cpp +++ b/llvm/lib/CodeGen/LiveStacks.cpp @@ -15,20 +15,21 @@ #include "llvm/CodeGen/LiveStacks.h" #include "llvm/CodeGen/TargetRegisterInfo.h" #include "llvm/CodeGen/TargetSubtargetInfo.h" +#include "llvm/IR/Function.h" using namespace llvm; #define DEBUG_TYPE "livestacks" -char LiveStacks::ID = 0; -INITIALIZE_PASS_BEGIN(LiveStacks, DEBUG_TYPE, - "Live Stack Slot Analysis", false, false) +char LiveStacksWrapperLegacy::ID = 0; +INITIALIZE_PASS_BEGIN(LiveStacksWrapperLegacy, DEBUG_TYPE, + "Live Stack Slot Analysis", false, false) INITIALIZE_PASS_DEPENDENCY(SlotIndexesWrapperPass) -INITIALIZE_PASS_END(LiveStacks, DEBUG_TYPE, - "Live Stack Slot Analysis", false, false) +INITIALIZE_PASS_END(LiveStacksWrapperLegacy, DEBUG_TYPE, + "Live Stack Slot Analysis", false, false) -char &llvm::LiveStacksID = LiveStacks::ID; +char &llvm::LiveStacksID = LiveStacksWrapperLegacy::ID; -void LiveStacks::getAnalysisUsage(AnalysisUsage &AU) const { +void LiveStacksWrapperLegacy::getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesAll(); AU.addPreserved<SlotIndexesWrapperPass>(); AU.addRequiredTransitive<SlotIndexesWrapperPass>(); @@ -42,11 +43,10 @@ void LiveStacks::releaseMemory() { S2RCMap.clear(); } -bool LiveStacks::runOnMachineFunction(MachineFunction &MF) { +void LiveStacks::init(MachineFunction &MF) { TRI = MF.getSubtarget().getRegisterInfo(); // FIXME: No analysis is being done right now. We are relying on the // register allocators to provide the information. - return false; } LiveInterval & @@ -68,6 +68,33 @@ LiveStacks::getOrCreateInterval(int Slot, const TargetRegisterClass *RC) { return I->second; } +AnalysisKey LiveStacksAnalysis::Key; + +LiveStacks LiveStacksAnalysis::run(MachineFunction &MF, + MachineFunctionAnalysisManager &) { + LiveStacks Impl; + Impl.init(MF); + return Impl; +} +PreservedAnalyses +LiveStacksPrinterPass::run(MachineFunction &MF, + MachineFunctionAnalysisManager &AM) { + AM.getResult<LiveStacksAnalysis>(MF).print(OS, MF.getFunction().getParent()); + return PreservedAnalyses::all(); +} + +bool LiveStacksWrapperLegacy::runOnMachineFunction(MachineFunction &MF) { + Impl = LiveStacks(); + Impl.init(MF); + return false; +} + +void LiveStacksWrapperLegacy::releaseMemory() { Impl = LiveStacks(); } + +void LiveStacksWrapperLegacy::print(raw_ostream &OS, const Module *) const { + Impl.print(OS); +} + /// print - Implement the dump method. void LiveStacks::print(raw_ostream &OS, const Module*) const { diff --git a/llvm/lib/CodeGen/MachineVerifier.cpp b/llvm/lib/CodeGen/MachineVerifier.cpp index 8e64e40..fb4d96f 100644 --- a/llvm/lib/CodeGen/MachineVerifier.cpp +++ b/llvm/lib/CodeGen/MachineVerifier.cpp @@ -369,7 +369,7 @@ struct MachineVerifierLegacyPass : public MachineFunctionPass { } void getAnalysisUsage(AnalysisUsage &AU) const override { - AU.addUsedIfAvailable<LiveStacks>(); + AU.addUsedIfAvailable<LiveStacksWrapperLegacy>(); AU.addUsedIfAvailable<LiveVariablesWrapperPass>(); AU.addUsedIfAvailable<SlotIndexesWrapperPass>(); AU.addUsedIfAvailable<LiveIntervalsWrapperPass>(); @@ -491,7 +491,8 @@ bool MachineVerifier::verify(const MachineFunction &MF) { auto *LVWrapper = PASS->getAnalysisIfAvailable<LiveVariablesWrapperPass>(); if (!LiveInts) LiveVars = LVWrapper ? &LVWrapper->getLV() : nullptr; - LiveStks = PASS->getAnalysisIfAvailable<LiveStacks>(); + auto *LSWrapper = PASS->getAnalysisIfAvailable<LiveStacksWrapperLegacy>(); + LiveStks = LSWrapper ? &LSWrapper->getLS() : nullptr; auto *SIWrapper = PASS->getAnalysisIfAvailable<SlotIndexesWrapperPass>(); Indexes = SIWrapper ? &SIWrapper->getSI() : nullptr; } diff --git a/llvm/lib/CodeGen/RegAllocBasic.cpp b/llvm/lib/CodeGen/RegAllocBasic.cpp index 7ee24c9..c05aa1e 100644 --- a/llvm/lib/CodeGen/RegAllocBasic.cpp +++ b/llvm/lib/CodeGen/RegAllocBasic.cpp @@ -135,7 +135,7 @@ INITIALIZE_PASS_DEPENDENCY(SlotIndexesWrapperPass) INITIALIZE_PASS_DEPENDENCY(LiveIntervalsWrapperPass) INITIALIZE_PASS_DEPENDENCY(RegisterCoalescer) INITIALIZE_PASS_DEPENDENCY(MachineScheduler) -INITIALIZE_PASS_DEPENDENCY(LiveStacks) +INITIALIZE_PASS_DEPENDENCY(LiveStacksWrapperLegacy) INITIALIZE_PASS_DEPENDENCY(AAResultsWrapperPass) INITIALIZE_PASS_DEPENDENCY(MachineDominatorTreeWrapperPass) INITIALIZE_PASS_DEPENDENCY(MachineLoopInfoWrapperPass) @@ -182,8 +182,8 @@ void RABasic::getAnalysisUsage(AnalysisUsage &AU) const { AU.addPreserved<SlotIndexesWrapperPass>(); AU.addRequired<LiveDebugVariablesWrapperLegacy>(); AU.addPreserved<LiveDebugVariablesWrapperLegacy>(); - AU.addRequired<LiveStacks>(); - AU.addPreserved<LiveStacks>(); + AU.addRequired<LiveStacksWrapperLegacy>(); + AU.addPreserved<LiveStacksWrapperLegacy>(); AU.addRequired<ProfileSummaryInfoWrapperPass>(); AU.addRequired<MachineBlockFrequencyInfoWrapperPass>(); AU.addPreserved<MachineBlockFrequencyInfoWrapperPass>(); diff --git a/llvm/lib/CodeGen/RegAllocGreedy.cpp b/llvm/lib/CodeGen/RegAllocGreedy.cpp index 8564fd8..cb29218 100644 --- a/llvm/lib/CodeGen/RegAllocGreedy.cpp +++ b/llvm/lib/CodeGen/RegAllocGreedy.cpp @@ -156,7 +156,7 @@ INITIALIZE_PASS_DEPENDENCY(SlotIndexesWrapperPass) INITIALIZE_PASS_DEPENDENCY(LiveIntervalsWrapperPass) INITIALIZE_PASS_DEPENDENCY(RegisterCoalescer) INITIALIZE_PASS_DEPENDENCY(MachineScheduler) -INITIALIZE_PASS_DEPENDENCY(LiveStacks) +INITIALIZE_PASS_DEPENDENCY(LiveStacksWrapperLegacy) INITIALIZE_PASS_DEPENDENCY(MachineDominatorTreeWrapperPass) INITIALIZE_PASS_DEPENDENCY(MachineLoopInfoWrapperPass) INITIALIZE_PASS_DEPENDENCY(VirtRegMapWrapperLegacy) @@ -206,8 +206,8 @@ void RAGreedy::getAnalysisUsage(AnalysisUsage &AU) const { AU.addPreserved<SlotIndexesWrapperPass>(); AU.addRequired<LiveDebugVariablesWrapperLegacy>(); AU.addPreserved<LiveDebugVariablesWrapperLegacy>(); - AU.addRequired<LiveStacks>(); - AU.addPreserved<LiveStacks>(); + AU.addRequired<LiveStacksWrapperLegacy>(); + AU.addPreserved<LiveStacksWrapperLegacy>(); AU.addRequired<MachineDominatorTreeWrapperPass>(); AU.addPreserved<MachineDominatorTreeWrapperPass>(); AU.addRequired<MachineLoopInfoWrapperPass>(); diff --git a/llvm/lib/CodeGen/RegAllocPBQP.cpp b/llvm/lib/CodeGen/RegAllocPBQP.cpp index 261e93a..696c312 100644 --- a/llvm/lib/CodeGen/RegAllocPBQP.cpp +++ b/llvm/lib/CodeGen/RegAllocPBQP.cpp @@ -121,7 +121,7 @@ public: : MachineFunctionPass(ID), customPassID(cPassID) { initializeSlotIndexesWrapperPassPass(*PassRegistry::getPassRegistry()); initializeLiveIntervalsWrapperPassPass(*PassRegistry::getPassRegistry()); - initializeLiveStacksPass(*PassRegistry::getPassRegistry()); + initializeLiveStacksWrapperLegacyPass(*PassRegistry::getPassRegistry()); initializeVirtRegMapWrapperLegacyPass(*PassRegistry::getPassRegistry()); } @@ -550,8 +550,8 @@ void RegAllocPBQP::getAnalysisUsage(AnalysisUsage &au) const { //au.addRequiredID(SplitCriticalEdgesID); if (customPassID) au.addRequiredID(*customPassID); - au.addRequired<LiveStacks>(); - au.addPreserved<LiveStacks>(); + au.addRequired<LiveStacksWrapperLegacy>(); + au.addPreserved<LiveStacksWrapperLegacy>(); au.addRequired<MachineBlockFrequencyInfoWrapperPass>(); au.addPreserved<MachineBlockFrequencyInfoWrapperPass>(); au.addRequired<MachineLoopInfoWrapperPass>(); diff --git a/llvm/lib/CodeGen/StackSlotColoring.cpp b/llvm/lib/CodeGen/StackSlotColoring.cpp index cdc5306..4dc5dc8 100644 --- a/llvm/lib/CodeGen/StackSlotColoring.cpp +++ b/llvm/lib/CodeGen/StackSlotColoring.cpp @@ -149,7 +149,7 @@ namespace { AU.setPreservesCFG(); AU.addRequired<SlotIndexesWrapperPass>(); AU.addPreserved<SlotIndexesWrapperPass>(); - AU.addRequired<LiveStacks>(); + AU.addRequired<LiveStacksWrapperLegacy>(); AU.addRequired<MachineBlockFrequencyInfoWrapperPass>(); AU.addPreserved<MachineBlockFrequencyInfoWrapperPass>(); AU.addPreservedID(MachineDominatorsID); @@ -185,7 +185,7 @@ char &llvm::StackSlotColoringID = StackSlotColoring::ID; INITIALIZE_PASS_BEGIN(StackSlotColoring, DEBUG_TYPE, "Stack Slot Coloring", false, false) INITIALIZE_PASS_DEPENDENCY(SlotIndexesWrapperPass) -INITIALIZE_PASS_DEPENDENCY(LiveStacks) +INITIALIZE_PASS_DEPENDENCY(LiveStacksWrapperLegacy) INITIALIZE_PASS_DEPENDENCY(MachineLoopInfoWrapperPass) INITIALIZE_PASS_END(StackSlotColoring, DEBUG_TYPE, "Stack Slot Coloring", false, false) @@ -522,7 +522,7 @@ bool StackSlotColoring::runOnMachineFunction(MachineFunction &MF) { MFI = &MF.getFrameInfo(); TII = MF.getSubtarget().getInstrInfo(); - LS = &getAnalysis<LiveStacks>(); + LS = &getAnalysis<LiveStacksWrapperLegacy>().getLS(); MBFI = &getAnalysis<MachineBlockFrequencyInfoWrapperPass>().getMBFI(); Indexes = &getAnalysis<SlotIndexesWrapperPass>().getSI(); diff --git a/llvm/lib/CodeGen/VirtRegMap.cpp b/llvm/lib/CodeGen/VirtRegMap.cpp index 2084e68..1352102 100644 --- a/llvm/lib/CodeGen/VirtRegMap.cpp +++ b/llvm/lib/CodeGen/VirtRegMap.cpp @@ -253,7 +253,7 @@ INITIALIZE_PASS_DEPENDENCY(SlotIndexesWrapperPass) INITIALIZE_PASS_DEPENDENCY(LiveIntervalsWrapperPass) INITIALIZE_PASS_DEPENDENCY(LiveDebugVariablesWrapperLegacy) INITIALIZE_PASS_DEPENDENCY(LiveRegMatrixWrapperLegacy) -INITIALIZE_PASS_DEPENDENCY(LiveStacks) +INITIALIZE_PASS_DEPENDENCY(LiveStacksWrapperLegacy) INITIALIZE_PASS_DEPENDENCY(VirtRegMapWrapperLegacy) INITIALIZE_PASS_END(VirtRegRewriter, "virtregrewriter", "Virtual Register Rewriter", false, false) @@ -265,8 +265,8 @@ void VirtRegRewriter::getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired<SlotIndexesWrapperPass>(); AU.addPreserved<SlotIndexesWrapperPass>(); AU.addRequired<LiveDebugVariablesWrapperLegacy>(); - AU.addRequired<LiveStacks>(); - AU.addPreserved<LiveStacks>(); + AU.addRequired<LiveStacksWrapperLegacy>(); + AU.addPreserved<LiveStacksWrapperLegacy>(); AU.addRequired<VirtRegMapWrapperLegacy>(); AU.addRequired<LiveRegMatrixWrapperLegacy>(); |