[llvm] [CodeGen][NewPM] Split `MachineDominatorTree` into a concrete analysis result (PR #94571)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 7 02:19:30 PDT 2024
================
@@ -37,51 +37,59 @@ static cl::opt<bool, true> VerifyMachineDomInfoX(
namespace llvm {
template class DomTreeNodeBase<MachineBasicBlock>;
template class DominatorTreeBase<MachineBasicBlock, false>; // DomTreeBase
-}
-char MachineDominatorTree::ID = 0;
+namespace DomTreeBuilder {
+template void Calculate<MBBDomTree>(MBBDomTree &DT);
+template void CalculateWithUpdates<MBBDomTree>(MBBDomTree &DT, MBBUpdates U);
-INITIALIZE_PASS(MachineDominatorTree, "machinedomtree",
- "MachineDominator Tree Construction", true, true)
+template void InsertEdge<MBBDomTree>(MBBDomTree &DT, MachineBasicBlock *From,
+ MachineBasicBlock *To);
-char &llvm::MachineDominatorsID = MachineDominatorTree::ID;
+template void DeleteEdge<MBBDomTree>(MBBDomTree &DT, MachineBasicBlock *From,
+ MachineBasicBlock *To);
-void MachineDominatorTree::getAnalysisUsage(AnalysisUsage &AU) const {
- AU.setPreservesAll();
- MachineFunctionPass::getAnalysisUsage(AU);
+template void ApplyUpdates<MBBDomTree>(MBBDomTree &DT, MBBDomTreeGraphDiff &,
+ MBBDomTreeGraphDiff *);
+
+template bool Verify<MBBDomTree>(const MBBDomTree &DT,
+ MBBDomTree::VerificationLevel VL);
+} // namespace DomTreeBuilder
}
-bool MachineDominatorTree::runOnMachineFunction(MachineFunction &F) {
- calculate(F);
- return false;
+char MachineDominatorTreeWrapperPass::ID = 0;
+
+INITIALIZE_PASS(MachineDominatorTreeWrapperPass, "machinedomtree",
+ "MachineDominator Tree Construction", true, true)
+
+MachineDominatorTreeWrapperPass::MachineDominatorTreeWrapperPass()
+ : MachineFunctionPass(ID) {
+ initializeMachineDominatorTreeWrapperPassPass(
+ *PassRegistry::getPassRegistry());
}
void MachineDominatorTree::calculate(MachineFunction &F) {
CriticalEdgesToSplit.clear();
NewBBs.clear();
- DT.reset(new DomTreeBase<MachineBasicBlock>());
- DT->recalculate(F);
+ recalculate(F);
}
-MachineDominatorTree::MachineDominatorTree()
- : MachineFunctionPass(ID) {
- initializeMachineDominatorTreePass(*PassRegistry::getPassRegistry());
-}
+char &llvm::MachineDominatorsID = MachineDominatorTreeWrapperPass::ID;
-void MachineDominatorTree::releaseMemory() {
- CriticalEdgesToSplit.clear();
- DT.reset(nullptr);
+bool MachineDominatorTreeWrapperPass::runOnMachineFunction(MachineFunction &F) {
+ DT = MachineDominatorTree(F);
+ return false;
}
-void MachineDominatorTree::verifyAnalysis() const {
- if (DT && VerifyMachineDomInfo)
- if (!DT->verify(MachineDomTree::VerificationLevel::Basic)) {
- errs() << "MachineDominatorTree verification failed\n";
- abort();
- }
+void MachineDominatorTreeWrapperPass::releaseMemory() { DT.reset(); }
+
+void MachineDominatorTreeWrapperPass::verifyAnalysis() const {
+ if (VerifyMachineDomInfo && DT)
----------------
arsenm wrote:
I still think something is off here with DT not always being available. I tried running check-llvm with the current null check removed and only a few tests fail:
```
LLVM :: CodeGen/Generic/available_externally_alias.ll
LLVM :: CodeGen/Generic/externally_available.ll
LLVM :: CodeGen/LoongArch/machinelicm-address-pseudos.ll
LLVM :: CodeGen/LoongArch/opt-pipeline.ll
LLVM :: CodeGen/PowerPC/aix-available-externally-linkage-fun.ll
LLVM :: CodeGen/PowerPC/available-externally.ll
LLVM :: CodeGen/X86/2009-05-23-available_externally.ll
LLVM :: CodeGen/X86/dllimport-x86_64.ll
LLVM :: CodeGen/X86/dllimport.ll
LLVM :: CodeGen/X86/hidden-vis-pic.ll
LLVM :: CodeGen/X86/partially-coalesced3.mir
LLVM :: CodeGen/X86/visibility.ll
LLVM :: CodeGen/X86/win32-eh-available-externally.ll
```
so I think this is probably just a bug somewhere?
In any case, that's a pre-existing issue not related to this
https://github.com/llvm/llvm-project/pull/94571
More information about the llvm-commits
mailing list