diff options
| author | paperchalice <liujunchang97@outlook.com> | 2024-06-12 14:29:22 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-12 14:29:22 +0800 |
| commit | 4b24c2dfb5c02896ec2e9855ac72eb0771d0764d (patch) | |
| tree | ef6fc89bafb9a489aec935ccf56aed981c6c3f70 /llvm/lib/CodeGen/MachinePostDominators.cpp | |
| parent | c012e487b7246239c31bd378ab074fb110631186 (diff) | |
[CodeGen][NewPM] Split `MachinePostDominators` into a concrete analysis result (#95113)
`MachinePostDominators` version of #94571.
Diffstat (limited to 'llvm/lib/CodeGen/MachinePostDominators.cpp')
| -rw-r--r-- | llvm/lib/CodeGen/MachinePostDominators.cpp | 58 |
1 files changed, 35 insertions, 23 deletions
diff --git a/llvm/lib/CodeGen/MachinePostDominators.cpp b/llvm/lib/CodeGen/MachinePostDominators.cpp index fb96d0efa4d4..bb587b0611fa 100644 --- a/llvm/lib/CodeGen/MachinePostDominators.cpp +++ b/llvm/lib/CodeGen/MachinePostDominators.cpp @@ -19,31 +19,46 @@ using namespace llvm; namespace llvm { template class DominatorTreeBase<MachineBasicBlock, true>; // PostDomTreeBase +namespace DomTreeBuilder { + +template void Calculate<MBBPostDomTree>(MBBPostDomTree &DT); +template void InsertEdge<MBBPostDomTree>(MBBPostDomTree &DT, + MachineBasicBlock *From, + MachineBasicBlock *To); +template void DeleteEdge<MBBPostDomTree>(MBBPostDomTree &DT, + MachineBasicBlock *From, + MachineBasicBlock *To); +template void ApplyUpdates<MBBPostDomTree>(MBBPostDomTree &DT, + MBBPostDomTreeGraphDiff &, + MBBPostDomTreeGraphDiff *); +template bool Verify<MBBPostDomTree>(const MBBPostDomTree &DT, + MBBPostDomTree::VerificationLevel VL); + +} // namespace DomTreeBuilder extern bool VerifyMachineDomInfo; } // namespace llvm -char MachinePostDominatorTree::ID = 0; +char MachinePostDominatorTreeWrapperPass::ID = 0; //declare initializeMachinePostDominatorTreePass -INITIALIZE_PASS(MachinePostDominatorTree, "machinepostdomtree", +INITIALIZE_PASS(MachinePostDominatorTreeWrapperPass, "machinepostdomtree", "MachinePostDominator Tree Construction", true, true) -MachinePostDominatorTree::MachinePostDominatorTree() - : MachineFunctionPass(ID), PDT(nullptr) { - initializeMachinePostDominatorTreePass(*PassRegistry::getPassRegistry()); +MachinePostDominatorTreeWrapperPass::MachinePostDominatorTreeWrapperPass() + : MachineFunctionPass(ID), PDT() { + initializeMachinePostDominatorTreeWrapperPassPass( + *PassRegistry::getPassRegistry()); } -FunctionPass *MachinePostDominatorTree::createMachinePostDominatorTreePass() { - return new MachinePostDominatorTree(); -} - -bool MachinePostDominatorTree::runOnMachineFunction(MachineFunction &F) { - PDT = std::make_unique<PostDomTreeT>(); +bool MachinePostDominatorTreeWrapperPass::runOnMachineFunction( + MachineFunction &F) { + PDT = MachinePostDominatorTree(); PDT->recalculate(F); return false; } -void MachinePostDominatorTree::getAnalysisUsage(AnalysisUsage &AU) const { +void MachinePostDominatorTreeWrapperPass::getAnalysisUsage( + AnalysisUsage &AU) const { AU.setPreservesAll(); MachineFunctionPass::getAnalysisUsage(AU); } @@ -54,26 +69,23 @@ MachineBasicBlock *MachinePostDominatorTree::findNearestCommonDominator( MachineBasicBlock *NCD = Blocks.front(); for (MachineBasicBlock *BB : Blocks.drop_front()) { - NCD = PDT->findNearestCommonDominator(NCD, BB); + NCD = Base::findNearestCommonDominator(NCD, BB); // Stop when the root is reached. - if (PDT->isVirtualRoot(PDT->getNode(NCD))) + if (isVirtualRoot(getNode(NCD))) return nullptr; } return NCD; } -void MachinePostDominatorTree::verifyAnalysis() const { - if (PDT && VerifyMachineDomInfo) - if (!PDT->verify(PostDomTreeT::VerificationLevel::Basic)) { - errs() << "MachinePostDominatorTree verification failed\n"; - - abort(); - } +void MachinePostDominatorTreeWrapperPass::verifyAnalysis() const { + if (VerifyMachineDomInfo && PDT && + !PDT->verify(MachinePostDominatorTree::VerificationLevel::Basic)) + report_fatal_error("MachinePostDominatorTree verification failed!"); } -void MachinePostDominatorTree::print(llvm::raw_ostream &OS, - const Module *M) const { +void MachinePostDominatorTreeWrapperPass::print(llvm::raw_ostream &OS, + const Module *M) const { PDT->print(OS); } |
