aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineBasicBlock.cpp
diff options
context:
space:
mode:
authorpaperchalice <liujunchang97@outlook.com>2024-07-17 11:26:56 +0800
committerGitHub <noreply@github.com>2024-07-17 11:26:56 +0800
commit1b873e565eea97d02cdb2375c50ceea89a818e5b (patch)
treec70bf3aac847f4edf027f0a6b38cc88e7a020f71 /llvm/lib/CodeGen/MachineBasicBlock.cpp
parentbefd44bcdc6e9d2f4099bf344826b2cd0fd8cbdc (diff)
downloadllvm-1b873e565eea97d02cdb2375c50ceea89a818e5b.zip
llvm-1b873e565eea97d02cdb2375c50ceea89a818e5b.tar.gz
llvm-1b873e565eea97d02cdb2375c50ceea89a818e5b.tar.bz2
[CodeGen][NewPM] Port `phi-node-elimination` to new pass manager (#98867)
- Add `PHIEliminationPass `. - Support new pass manager in `MachineBasicBlock:: SplitCriticalEdge `
Diffstat (limited to 'llvm/lib/CodeGen/MachineBasicBlock.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineBasicBlock.cpp29
1 files changed, 17 insertions, 12 deletions
diff --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp b/llvm/lib/CodeGen/MachineBasicBlock.cpp
index 90d2ede..d681d00 100644
--- a/llvm/lib/CodeGen/MachineBasicBlock.cpp
+++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp
@@ -1135,9 +1135,19 @@ public:
}
};
+#define GET_RESULT(RESULT, GETTER, INFIX) \
+ [MF, P, MFAM]() { \
+ if (P) { \
+ auto *Wrapper = P->getAnalysisIfAvailable<RESULT##INFIX##WrapperPass>(); \
+ return Wrapper ? &Wrapper->GETTER() : nullptr; \
+ } \
+ return MFAM->getCachedResult<RESULT##Analysis>(*MF); \
+ }()
+
MachineBasicBlock *MachineBasicBlock::SplitCriticalEdge(
- MachineBasicBlock *Succ, Pass &P,
+ MachineBasicBlock *Succ, Pass *P, MachineFunctionAnalysisManager *MFAM,
std::vector<SparseBitVector<>> *LiveInSets) {
+ assert((P || MFAM) && "Need a way to get analysis results!");
if (!canSplitCriticalEdge(Succ))
return nullptr;
@@ -1161,10 +1171,8 @@ MachineBasicBlock *MachineBasicBlock::SplitCriticalEdge(
<< " -- " << printMBBReference(*NMBB) << " -- "
<< printMBBReference(*Succ) << '\n');
- auto *LISWrapper = P.getAnalysisIfAvailable<LiveIntervalsWrapperPass>();
- LiveIntervals *LIS = LISWrapper ? &LISWrapper->getLIS() : nullptr;
- auto *SIWrapper = P.getAnalysisIfAvailable<SlotIndexesWrapperPass>();
- SlotIndexes *Indexes = SIWrapper ? &SIWrapper->getSI() : nullptr;
+ LiveIntervals *LIS = GET_RESULT(LiveIntervals, getLIS, );
+ SlotIndexes *Indexes = GET_RESULT(SlotIndexes, getSI, );
if (LIS)
LIS->insertMBBInMaps(NMBB);
else if (Indexes)
@@ -1173,8 +1181,7 @@ MachineBasicBlock *MachineBasicBlock::SplitCriticalEdge(
// On some targets like Mips, branches may kill virtual registers. Make sure
// that LiveVariables is properly updated after updateTerminator replaces the
// terminators.
- auto *LVWrapper = P.getAnalysisIfAvailable<LiveVariablesWrapperPass>();
- LiveVariables *LV = LVWrapper ? &LVWrapper->getLV() : nullptr;
+ LiveVariables *LV = GET_RESULT(LiveVariables, getLV, );
// Collect a list of virtual registers killed by the terminators.
SmallVector<Register, 4> KilledRegs;
@@ -1339,12 +1346,10 @@ MachineBasicBlock *MachineBasicBlock::SplitCriticalEdge(
LIS->repairIntervalsInRange(this, getFirstTerminator(), end(), UsedRegs);
}
- if (auto *MDTWrapper =
- P.getAnalysisIfAvailable<MachineDominatorTreeWrapperPass>())
- MDTWrapper->getDomTree().recordSplitCriticalEdge(this, Succ, NMBB);
+ if (auto *MDT = GET_RESULT(MachineDominatorTree, getDomTree, ))
+ MDT->recordSplitCriticalEdge(this, Succ, NMBB);
- auto *MLIWrapper = P.getAnalysisIfAvailable<MachineLoopInfoWrapperPass>();
- if (MachineLoopInfo *MLI = MLIWrapper ? &MLIWrapper->getLI() : nullptr)
+ if (MachineLoopInfo *MLI = GET_RESULT(MachineLoop, getLI, Info))
if (MachineLoop *TIL = MLI->getLoopFor(this)) {
// If one or the other blocks were not in a loop, the new block is not
// either, and thus LI doesn't need to be updated.