[llvm] [CodeGen][NewPM] Split `MachineDominatorTree` into a concrete analysis result (PR #94571)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 7 02:38:45 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)
----------------
paperchalice wrote:
Assuming that a function `F` which `hasAvailableExternallyLinkage ` is true and a pass `P` requires `MachineDominatorTreeWrapperPass` and preserves it.
https://github.com/llvm/llvm-project/blob/c0b468523c9c5517e61a197e7c1fe6cb52f8999c/llvm/lib/CodeGen/MachineFunctionPass.cpp#L39-L43
Then the construction of DT in `MachineDominatorTreeWrapperPass` is skipped.
Legacy pass manager will still try to verify the result which is not exist:
https://github.com/llvm/llvm-project/blob/0d1b3671a91c3929fc3e3613491ff4b57f1adcc3/llvm/lib/IR/LegacyPassManager.cpp#L915-L925
I think this can explain why `externally_available.ll`-like tests are failed.
https://github.com/llvm/llvm-project/pull/94571
More information about the llvm-commits
mailing list