aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineBasicBlock.cpp
diff options
context:
space:
mode:
authorAkshat Oke <Akshat.Oke@amd.com>2025-02-25 10:10:02 +0530
committerGitHub <noreply@github.com>2025-02-25 10:10:02 +0530
commit862595cab67b7fa71ea035e1090725bdf39d291b (patch)
tree0a81863a991f5e76152a8e28c849cbfdbd08d4e2 /llvm/lib/CodeGen/MachineBasicBlock.cpp
parent2c7780a96d24e1e23657057fb735e13e2ba5d2ce (diff)
downloadllvm-862595cab67b7fa71ea035e1090725bdf39d291b.zip
llvm-862595cab67b7fa71ea035e1090725bdf39d291b.tar.gz
llvm-862595cab67b7fa71ea035e1090725bdf39d291b.tar.bz2
[MachineBasicBlock][NFC] Decouple SplitCriticalEdges from pass manager (#128151)
New clients should use this overload that accepts analyses directly.
Diffstat (limited to 'llvm/lib/CodeGen/MachineBasicBlock.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineBasicBlock.cpp31
1 files changed, 20 insertions, 11 deletions
diff --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp b/llvm/lib/CodeGen/MachineBasicBlock.cpp
index 9bc8989..e90b224 100644
--- a/llvm/lib/CodeGen/MachineBasicBlock.cpp
+++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp
@@ -1137,6 +1137,9 @@ public:
}
};
+MachineBasicBlock *MachineBasicBlock::SplitCriticalEdge(
+ MachineBasicBlock *Succ, Pass *P, MachineFunctionAnalysisManager *MFAM,
+ std::vector<SparseBitVector<>> *LiveInSets, MachineDomTreeUpdater *MDTU) {
#define GET_RESULT(RESULT, GETTER, INFIX) \
[MF, P, MFAM]() { \
if (P) { \
@@ -1146,10 +1149,19 @@ public:
return MFAM->getCachedResult<RESULT##Analysis>(*MF); \
}()
+ assert((P || MFAM) && "Need a way to get analysis results!");
+ MachineFunction *MF = getParent();
+ LiveIntervals *LIS = GET_RESULT(LiveIntervals, getLIS, );
+ SlotIndexes *Indexes = GET_RESULT(SlotIndexes, getSI, );
+ LiveVariables *LV = GET_RESULT(LiveVariables, getLV, );
+ MachineLoopInfo *MLI = GET_RESULT(MachineLoop, getLI, Info);
+ return SplitCriticalEdge(Succ, {LIS, Indexes, LV, MLI}, LiveInSets, MDTU);
+#undef GET_RESULT
+}
+
MachineBasicBlock *MachineBasicBlock::SplitCriticalEdge(
- MachineBasicBlock *Succ, Pass *P, MachineFunctionAnalysisManager *MFAM,
+ MachineBasicBlock *Succ, const SplitCriticalEdgeAnalyses &Analyses,
std::vector<SparseBitVector<>> *LiveInSets, MachineDomTreeUpdater *MDTU) {
- assert((P || MFAM) && "Need a way to get analysis results!");
if (!canSplitCriticalEdge(Succ))
return nullptr;
@@ -1172,19 +1184,16 @@ MachineBasicBlock *MachineBasicBlock::SplitCriticalEdge(
LLVM_DEBUG(dbgs() << "Splitting critical edge: " << printMBBReference(*this)
<< " -- " << printMBBReference(*NMBB) << " -- "
<< printMBBReference(*Succ) << '\n');
-
- LiveIntervals *LIS = GET_RESULT(LiveIntervals, getLIS, );
- SlotIndexes *Indexes = GET_RESULT(SlotIndexes, getSI, );
+ auto *LIS = Analyses.LIS;
if (LIS)
LIS->insertMBBInMaps(NMBB);
- else if (Indexes)
- Indexes->insertMBBInMaps(NMBB);
+ else if (Analyses.SI)
+ Analyses.SI->insertMBBInMaps(NMBB);
// On some targets like Mips, branches may kill virtual registers. Make sure
// that LiveVariables is properly updated after updateTerminator replaces the
// terminators.
- LiveVariables *LV = GET_RESULT(LiveVariables, getLV, );
-
+ auto *LV = Analyses.LV;
// Collect a list of virtual registers killed by the terminators.
SmallVector<Register, 4> KilledRegs;
if (LV)
@@ -1223,7 +1232,7 @@ MachineBasicBlock *MachineBasicBlock::SplitCriticalEdge(
// as the fallthrough successor
if (Succ == PrevFallthrough)
PrevFallthrough = NMBB;
-
+ auto *Indexes = Analyses.SI;
if (!ChangedIndirectJump) {
SlotIndexUpdateDelegate SlotUpdater(*MF, Indexes);
updateTerminator(PrevFallthrough);
@@ -1351,7 +1360,7 @@ MachineBasicBlock *MachineBasicBlock::SplitCriticalEdge(
if (MDTU)
MDTU->splitCriticalEdge(this, Succ, NMBB);
- if (MachineLoopInfo *MLI = GET_RESULT(MachineLoop, getLI, Info))
+ if (MachineLoopInfo *MLI = Analyses.MLI)
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.