Skip to content

Commit

Permalink
[AMDGPU] Preserve dominators trees in WQM pass
Browse files Browse the repository at this point in the history
Update the dominator and post-dominator trees when we split
blocks during WQM.

Note: changes to MachinePostDominatorTree are going upstream
first.

Change-Id: I93cf26278b64adfd2a57583ed0de58d2e29c3608
  • Loading branch information
perlfu committed Apr 28, 2020
1 parent 6475878 commit 64a620f
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions llvm/lib/Target/AMDGPU/SIWholeQuadMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,9 @@ class SIWholeQuadMode : public MachineFunctionPass {
void getAnalysisUsage(AnalysisUsage &AU) const override {
AU.addRequired<LiveIntervals>();
AU.addRequired<MachineDominatorTree>();
AU.addPreserved<MachineDominatorTree>();
AU.addRequired<MachinePostDominatorTree>();
AU.addPreserved<MachinePostDominatorTree>();
MachineFunctionPass::getAnalysisUsage(AU);
}
};
Expand Down Expand Up @@ -1062,6 +1064,19 @@ MachineBasicBlock *SIWholeQuadMode::splitBlock(MachineBasicBlock *BB,
SplitBB->splice(SplitBB->begin(), BB, SplitPoint, BB->end());
SplitBB->transferSuccessorsAndUpdatePHIs(BB);
BB->addSuccessor(SplitBB);

// Update dominator trees
using DomTreeT = DomTreeBase<MachineBasicBlock>;
SmallVector<DomTreeT::UpdateType, 16> DTUpdates;
for (MachineBasicBlock *Succ : SplitBB->successors()) {
DTUpdates.push_back({DomTreeT::Insert, SplitBB, Succ});
DTUpdates.push_back({DomTreeT::Delete, BB, Succ});
}
DTUpdates.push_back({DomTreeT::Insert, BB, SplitBB});
if (MDT)
MDT->getBase().applyUpdates(DTUpdates);
if (PDT)
PDT->getBase().applyUpdates(DTUpdates);
}

// Convert last instruction in to a terminator.
Expand Down

0 comments on commit 64a620f

Please sign in to comment.