[llvm] [CodeGen][NewPM] Split `MachineDominatorTree` into a concrete analysis result (PR #94571)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 7 06:21:54 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:
`MachineFunctionPass` is subclass of `FunctionPass`, maybe we can just change `F.isDeclaration()` -> `F.isDeclaration() || F.hasAvailableExternallyLinkage()`
https://github.com/llvm/llvm-project/blob/2117677e304d334326f6591f3c75fb2f34dc4bcb/llvm/lib/IR/LegacyPassManager.cpp#L1399-L1401
Not sure what the impact will be, but CodeGen pipeline is the only user of legacy pass manager.
https://github.com/llvm/llvm-project/pull/94571
More information about the llvm-commits
mailing list