18#include "llvm/Config/llvm-config.h"
43 cl::desc(
"Verify dominator info (time consuming)"));
45#ifdef EXPENSIVE_CHECKS
53 unsigned NumEdgesToEnd = 0;
57 if (NumEdgesToEnd >= 2)
60 assert(NumEdgesToEnd == 1);
80template void llvm::DomTreeBuilder::Calculate<DomTreeBuilder::BBDomTree>(
83llvm::DomTreeBuilder::CalculateWithUpdates<DomTreeBuilder::BBDomTree>(
86template void llvm::DomTreeBuilder::Calculate<DomTreeBuilder::BBPostDomTree>(
90template void llvm::DomTreeBuilder::InsertEdge<DomTreeBuilder::BBDomTree>(
92template void llvm::DomTreeBuilder::InsertEdge<DomTreeBuilder::BBPostDomTree>(
95template void llvm::DomTreeBuilder::DeleteEdge<DomTreeBuilder::BBDomTree>(
97template void llvm::DomTreeBuilder::DeleteEdge<DomTreeBuilder::BBPostDomTree>(
100template void llvm::DomTreeBuilder::ApplyUpdates<DomTreeBuilder::BBDomTree>(
103template void llvm::DomTreeBuilder::ApplyUpdates<DomTreeBuilder::BBPostDomTree>(
107template bool llvm::DomTreeBuilder::Verify<DomTreeBuilder::BBDomTree>(
110template bool llvm::DomTreeBuilder::Verify<DomTreeBuilder::BBPostDomTree>(
124 Instruction *UserInst = cast<Instruction>(U.getUser());
125 if (
auto *PN = dyn_cast<PHINode>(UserInst))
128 return dominates(BB, PN->getIncomingBlock(U));
138 const Instruction *Def = dyn_cast<Instruction>(DefV);
140 assert((isa<Argument>(DefV) || isa<Constant>(DefV)) &&
141 "Should be called with an instruction, argument or constant");
164 if (isa<InvokeInst>(Def) || isa<CallBrInst>(Def) || isa<PHINode>(
User))
170 return Def->comesBefore(
User);
192 if (
const auto *II = dyn_cast<InvokeInst>(Def)) {
212 if (
End->getSinglePredecessor())
235 int IsDuplicateEdge = 0;
240 if (IsDuplicateEdge++)
252 Instruction *UserInst = cast<Instruction>(U.getUser());
254 PHINode *PN = dyn_cast<PHINode>(UserInst);
270 const Instruction *Def = dyn_cast<Instruction>(DefV);
272 assert((isa<Argument>(DefV) || isa<Constant>(DefV)) &&
273 "Should be called with an instruction, argument or constant");
277 Instruction *UserInst = cast<Instruction>(U.getUser());
284 if (
PHINode *PN = dyn_cast<PHINode>(UserInst))
285 UseBB = PN->getIncomingBlock(U);
302 if (
const InvokeInst *II = dyn_cast<InvokeInst>(Def)) {
316 if (isa<PHINode>(UserInst))
319 return Def->comesBefore(UserInst);
330 if (
PHINode *PN = dyn_cast<PHINode>(
I))
350 return I1->comesBefore(I2) ? I1 : I2;
385 OS <<
"DominatorTree for function: " <<
F.getName() <<
"\n";
415 "Dominator Tree Construction",
true,
true)
424 assert(DT.
verify(DominatorTree::VerificationLevel::Full));
426 assert(DT.
verify(DominatorTree::VerificationLevel::Basic));
BlockVerifier::State From
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static constexpr bool ExpensiveChecksEnabled
static cl::opt< bool, true > VerifyDomInfoX("verify-dom-info", cl::location(VerifyDomInfo), cl::Hidden, cl::desc("Verify dominator info (time consuming)"))
static bool runOnFunction(Function &F, bool PostInlining)
Generic dominator tree construction - this file provides routines to construct immediate dominator in...
This file provides various utilities for inspecting and working with the control flow graph in LLVM I...
This header defines various interfaces for pass management in LLVM.
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
static constexpr bool ExpensiveChecksEnabled
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This templated class represents "all analyses that operate over <a particular IR unit>" (e....
API to communicate dependencies between analyses during invalidation.
A container for analyses that lazily runs them and caches their results.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
This class represents an incoming formal argument to a Function.
const BasicBlock * getEnd() const
const BasicBlock * getStart() const
bool isSingleEdge() const
Check if this is the only edge between Start and End.
LLVM Basic Block Representation.
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
Represents analyses that only rely on functions' control flow.
This is an important base class in LLVM.
Base class for the actual dominator tree node.
Analysis pass which computes a DominatorTree.
DominatorTree run(Function &F, FunctionAnalysisManager &)
Run the analysis pass over a function and produce a dominator tree.
Core dominator tree base class.
void print(raw_ostream &O) const
print - Convert to human readable form
bool verify(VerificationLevel VL=VerificationLevel::Full) const
verify - checks if the tree is correct.
void recalculate(ParentType &Func)
recalculate - compute a dominator tree for the given function
bool properlyDominates(const DomTreeNodeBase< BasicBlock > *A, const DomTreeNodeBase< BasicBlock > *B) const
properlyDominates - Returns true iff A dominates B and A != B.
DominatorTreePrinterPass(raw_ostream &OS)
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Legacy analysis pass which computes a DominatorTree.
DominatorTreeWrapperPass()
void print(raw_ostream &OS, const Module *M=nullptr) const override
print - Print out the internal state of the pass.
void verifyAnalysis() const override
verifyAnalysis() - This member can be implemented by a analysis pass to check state of analysis infor...
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
bool isReachableFromEntry(const Use &U) const
Provide an overload for a Use.
Instruction * findNearestCommonDominator(Instruction *I1, Instruction *I2) const
Find the nearest instruction I that dominates both I1 and I2, in the sense that a result produced bef...
bool dominates(const BasicBlock *BB, const Use &U) const
Return true if the (end of the) basic block BB dominates the use U.
bool invalidate(Function &F, const PreservedAnalyses &PA, FunctionAnalysisManager::Invalidator &)
Handle invalidation explicitly.
FunctionPass class - This class is used to implement most global optimizations.
unsigned getNumSuccessors() const LLVM_READONLY
Return the number of successors that this instruction has.
const BasicBlock * getParent() const
BasicBlock * getSuccessor(unsigned Idx) const LLVM_READONLY
Return the specified successor. This instruction must be a terminator.
A Module instance is used to store all the information related to an LLVM module.
BasicBlock * getIncomingBlock(unsigned i) const
Return incoming basic block number i.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
PreservedAnalysisChecker getChecker() const
Build a checker for this PreservedAnalyses and the specified analysis type.
A Use represents the edge between a Value definition and its users.
LLVM Value Representation.
This class implements an extremely fast bulk output stream that can only output to a stream.
LocationClass< Ty > location(Ty &L)
This is an optimization pass for GlobalISel generic memory operations.
Printable print(const GCNRegPressure &RP, const GCNSubtarget *ST=nullptr)
void initializeDominatorTreeWrapperPassPass(PassRegistry &)
bool VerifyDomInfo
Enables verification of dominator trees.
auto predecessors(const MachineBasicBlock *BB)
A special type used by analysis passes to provide an address that identifies that particular analysis...
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)