LLVM 19.0.0git
MachinePostDominators.cpp
Go to the documentation of this file.
1//===- MachinePostDominators.cpp -Machine Post Dominator Calculation ------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file implements simple dominator construction algorithms for finding
10// post dominators on machine functions.
11//
12//===----------------------------------------------------------------------===//
13
17
18using namespace llvm;
19
20namespace llvm {
21template class DominatorTreeBase<MachineBasicBlock, true>; // PostDomTreeBase
22
23namespace DomTreeBuilder {
24
25template void Calculate<MBBPostDomTree>(MBBPostDomTree &DT);
26template void InsertEdge<MBBPostDomTree>(MBBPostDomTree &DT,
29template void DeleteEdge<MBBPostDomTree>(MBBPostDomTree &DT,
32template void ApplyUpdates<MBBPostDomTree>(MBBPostDomTree &DT,
33 MBBPostDomTreeGraphDiff &,
34 MBBPostDomTreeGraphDiff *);
35template bool Verify<MBBPostDomTree>(const MBBPostDomTree &DT,
36 MBBPostDomTree::VerificationLevel VL);
37
38} // namespace DomTreeBuilder
39extern bool VerifyMachineDomInfo;
40} // namespace llvm
41
43
44//declare initializeMachinePostDominatorTreePass
46 "MachinePostDominator Tree Construction", true, true)
47
49 : MachineFunctionPass(ID), PDT() {
52}
53
57 PDT->recalculate(F);
58 return false;
59}
60
62 AnalysisUsage &AU) const {
63 AU.setPreservesAll();
65}
66
69 assert(!Blocks.empty());
70
71 MachineBasicBlock *NCD = Blocks.front();
72 for (MachineBasicBlock *BB : Blocks.drop_front()) {
74
75 // Stop when the root is reached.
76 if (isVirtualRoot(getNode(NCD)))
77 return nullptr;
78 }
79
80 return NCD;
81}
82
84 if (VerifyMachineDomInfo && PDT &&
86 report_fatal_error("MachinePostDominatorTree verification failed!");
87}
88
90 const Module *M) const {
91 PDT->print(OS);
92}
BlockVerifier::State From
DenseMap< Block *, BlockRelaxAux > Blocks
Definition: ELF_riscv.cpp:507
Generic dominator tree construction - this file provides routines to construct immediate dominator in...
#define F(x, y, z)
Definition: MD5.cpp:55
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
Definition: PassSupport.h:38
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
raw_pwrite_stream & OS
Represent the analysis usage information of a pass.
void setPreservesAll()
Set by analyses that do not transform their input at all.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
Core dominator tree base class.
NodeT * findNearestCommonDominator(NodeT *A, NodeT *B) const
Find nearest common dominator basic block for basic block A and B.
DomTreeNodeBase< NodeT > * getNode(const NodeT *BB) const
getNode - return the (Post)DominatorTree node for the specified basic block.
bool isVirtualRoot(const DomTreeNodeBase< NodeT > *A) const
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
void verifyAnalysis() const override
verifyAnalysis() - This member can be implemented by a analysis pass to check state of analysis infor...
bool runOnMachineFunction(MachineFunction &MF) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
void print(llvm::raw_ostream &OS, const Module *M=nullptr) const override
print - Print out the internal state of the pass.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
MachinePostDominatorTree - an analysis pass wrapper for DominatorTree used to compute the post-domina...
MachineBasicBlock * findNearestCommonDominator(ArrayRef< MachineBasicBlock * > Blocks) const
Returns the nearest common dominator of the given blocks.
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
void initializeMachinePostDominatorTreeWrapperPassPass(PassRegistry &)
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition: Error.cpp:159
bool VerifyMachineDomInfo