31 #ifdef EXPENSIVE_CHECKS
38 cl::desc(
"Verify dominator info (time consuming)"));
42 unsigned NumEdgesToEnd = 0;
46 if (NumEdgesToEnd >= 2)
49 assert(NumEdgesToEnd == 1);
68 llvm::DomTreeBuilder::Calculate<DomTreeBuilder::BBDomTree, Function>(
71 llvm::DomTreeBuilder::Calculate<DomTreeBuilder::BBPostDomTree, Function>(
74 template void llvm::DomTreeBuilder::InsertEdge<DomTreeBuilder::BBDomTree>(
76 template void llvm::DomTreeBuilder::InsertEdge<DomTreeBuilder::BBPostDomTree>(
79 template void llvm::DomTreeBuilder::DeleteEdge<DomTreeBuilder::BBDomTree>(
81 template void llvm::DomTreeBuilder::DeleteEdge<DomTreeBuilder::BBPostDomTree>(
84 template bool llvm::DomTreeBuilder::Verify<DomTreeBuilder::BBDomTree>(
86 template bool llvm::DomTreeBuilder::Verify<DomTreeBuilder::BBPostDomTree>(
122 if (isa<InvokeInst>(Def) || isa<PHINode>(User))
130 for (; &*I != Def && &*I != User; ++
I)
155 if (
const auto *II = dyn_cast<InvokeInst>(Def)) {
198 int IsDuplicateEdge = 0;
205 if (IsDuplicateEdge++)
220 if (PN && PN->getParent() == BBE.
getEnd() &&
221 PN->getIncomingBlock(U) == BBE.
getStart())
228 UseBB = PN->getIncomingBlock(U);
242 if (
PHINode *PN = dyn_cast<PHINode>(UserInst))
243 UseBB = PN->getIncomingBlock(U);
260 if (
const InvokeInst *II = dyn_cast<InvokeInst>(Def)) {
274 if (isa<PHINode>(UserInst))
279 for (; &*I != Def && &*I != UserInst; ++
I)
282 return &*I != UserInst;
293 if (
PHINode *PN = dyn_cast<PHINode>(I))
303 errs() <<
"\n~~~~~~~~~~~\n\t\tDomTree verification failed!\n~~~~~~~~~~~\n";
313 errs() <<
"DominatorTree is not up to date!\nComputed:\n";
315 errs() <<
"\nActual:\n";
343 OS <<
"DominatorTree for function: " << F.
getName() <<
"\n";
367 "Dominator Tree Construction",
true,
true)
bool compare(const DominatorTree &Other) const
Returns false if the other dominator tree matches this dominator tree.
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
A Module instance is used to store all the information related to an LLVM module. ...
const BasicBlock * getStart() const
unsigned getNumSuccessors() const
Return the number of successors that this terminator has.
Analysis pass which computes a DominatorTree.
StringRef getName() const
Return a constant reference to the value's name.
iterator begin()
Instruction iterator methods.
void verifyAnalysis() const override
verifyAnalysis() - This member can be implemented by a analysis pass to check state of analysis infor...
A Use represents the edge between a Value definition and its users.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs...ExtraArgs)
Get the result of an analysis pass for a given IR unit.
bool verify() const
verify - check parent and sibling property
User * getUser() const LLVM_READONLY
Returns the User that contains this Use.
bool isReachableFromEntry(const Use &U) const
Provide an overload for a Use.
Base class for the actual dominator tree node.
DominatorTreePrinterPass(raw_ostream &OS)
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
Subclasses of this class are all able to terminate a basic block.
A set of analyses that are preserved following a run of a transformation pass.
LLVM Basic Block Representation.
DominatorTree run(Function &F, FunctionAnalysisManager &)
Run the analysis pass over a function and produce a dominator tree.
Interval::pred_iterator pred_begin(Interval *I)
pred_begin/pred_end - define methods so that Intervals may be used just like BasicBlocks can with the...
PreservedAnalysisChecker getChecker() const
Build a checker for this PreservedAnalyses and the specified analysis type.
static const unsigned End
Interval::pred_iterator pred_end(Interval *I)
bool VerifyDomInfo
Enables verification of dominator trees.
void verifyDomTree() const
Verify the correctness of the domtree by re-computing it.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
static cl::opt< bool, true > VerifyDomInfoX("verify-dom-info", cl::location(VerifyDomInfo), cl::desc("Verify dominator info (time consuming)"))
const BasicBlock * getEnd() const
bool dominates(const Instruction *Def, const Use &U) const
Return true if Def dominates a use in User.
Iterator for intrusive lists based on ilist_node.
Generic dominator tree construction - This file provides routines to construct immediate dominator in...
BasicBlock * getSuccessor(unsigned idx) const
Return the specified successor.
const BasicBlock * getSinglePredecessor() const
Return the predecessor of this block if it has a single predecessor block.
void print(raw_ostream &OS, const Module *M=nullptr) const override
print - Print out the internal state of the pass.
bool invalidate(Function &F, const PreservedAnalyses &PA, FunctionAnalysisManager::Invalidator &)
Handle invalidation explicitly.
Represents analyses that only rely on functions' control flow.
INITIALIZE_PASS(DominatorTreeWrapperPass,"domtree","Dominator Tree Construction", true, true) bool DominatorTreeWrapperPass
void print(raw_ostream &O) const
print - Convert to human readable form
bool dominates(const BasicBlockEdge &BBE, const BasicBlock *BB) const
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
API to communicate dependencies between analyses during invalidation.
bool isSingleEdge() const
Check if this is the only edge between Start and End.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This templated class represents "all analyses that operate over \<a particular IR unit\>" (e...
void recalculate(FT &F)
recalculate - compute a dominator tree for the given function
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
This class implements an extremely fast bulk output stream that can only output to a stream...
A container for analyses that lazily runs them and caches their results.
Legacy analysis pass which computes a DominatorTree.
const TerminatorInst * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
This header defines various interfaces for pass management in LLVM.
A special type used by analysis passes to provide an address that identifies that particular analysis...
LocationClass< Ty > location(Ty &L)
const BasicBlock * getParent() const
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)