20 #include "llvm/Config/llvm-config.h" 35 cl::desc(
"Verify dominator info (time consuming)"));
37 #ifdef EXPENSIVE_CHECKS 40 static constexpr
bool ExpensiveChecksEnabled =
false;
45 unsigned NumEdgesToEnd = 0;
49 if (NumEdgesToEnd >= 2)
52 assert(NumEdgesToEnd == 1);
72 template void llvm::DomTreeBuilder::Calculate<DomTreeBuilder::BBDomTree>(
75 llvm::DomTreeBuilder::CalculateWithUpdates<DomTreeBuilder::BBDomTree>(
78 template void llvm::DomTreeBuilder::Calculate<DomTreeBuilder::BBPostDomTree>(
82 template void llvm::DomTreeBuilder::InsertEdge<DomTreeBuilder::BBDomTree>(
84 template void llvm::DomTreeBuilder::InsertEdge<DomTreeBuilder::BBPostDomTree>(
87 template void llvm::DomTreeBuilder::DeleteEdge<DomTreeBuilder::BBDomTree>(
89 template void llvm::DomTreeBuilder::DeleteEdge<DomTreeBuilder::BBPostDomTree>(
92 template void llvm::DomTreeBuilder::ApplyUpdates<DomTreeBuilder::BBDomTree>(
94 template void llvm::DomTreeBuilder::ApplyUpdates<DomTreeBuilder::BBPostDomTree>(
97 template bool llvm::DomTreeBuilder::Verify<DomTreeBuilder::BBDomTree>(
100 template bool llvm::DomTreeBuilder::Verify<DomTreeBuilder::BBPostDomTree>(
122 if (!isReachableFromEntry(UseBB))
126 if (!isReachableFromEntry(DefBB))
137 if (isa<InvokeInst>(Def) || isa<PHINode>(User))
138 return dominates(Def, UseBB);
141 return dominates(DefBB, UseBB);
145 for (; &*I != Def && &*I != User; ++
I)
158 if (!isReachableFromEntry(UseBB))
162 if (!isReachableFromEntry(DefBB))
170 if (
const auto *II = dyn_cast<InvokeInst>(Def)) {
173 return dominates(E, UseBB);
176 return dominates(DefBB, UseBB);
185 if (!dominates(End, UseBB))
213 int IsDuplicateEdge = 0;
220 if (IsDuplicateEdge++)
225 if (!dominates(End, BB))
235 if (PN && PN->getParent() == BBE.
getEnd() &&
236 PN->getIncomingBlock(U) == BBE.
getStart())
243 UseBB = PN->getIncomingBlock(U);
246 return dominates(BBE, UseBB);
257 if (
PHINode *PN = dyn_cast<PHINode>(UserInst))
258 UseBB = PN->getIncomingBlock(U);
263 if (!isReachableFromEntry(UseBB))
267 if (!isReachableFromEntry(DefBB))
275 if (
const InvokeInst *II = dyn_cast<InvokeInst>(Def)) {
278 return dominates(E, U);
284 return dominates(DefBB, UseBB);
289 if (isa<PHINode>(UserInst))
294 for (; &*I != Def && &*I != UserInst; ++
I)
297 return &*I != UserInst;
308 if (
PHINode *PN = dyn_cast<PHINode>(I))
309 return isReachableFromEntry(PN->getIncomingBlock(U));
312 return isReachableFromEntry(I->
getParent());
337 OS <<
"DominatorTree for function: " << F.
getName() <<
"\n";
362 "Dominator Tree Construction",
true,
true)
372 else if (ExpensiveChecksEnabled)
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
This class represents lattice values for constants.
A Module instance is used to store all the information related to an LLVM module. ...
BasicBlock * getSuccessor(unsigned Idx) const
Return the specified successor. This instruction must be a terminator.
void recalculate(ParentType &Func)
recalculate - compute a dominator tree for the given function
static constexpr bool ExpensiveChecksEnabled
Analysis pass which computes a DominatorTree.
const BasicBlock * getEnd() const
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...
bool isReachableFromEntry(const Use &U) const
Provide an overload for a Use.
iterator begin()
Instruction iterator methods.
bool isSingleEdge() const
Check if this is the only edge between Start and End.
PreservedAnalysisChecker getChecker() const
Build a checker for this PreservedAnalyses and the specified analysis type.
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.
User * getUser() const LLVM_READONLY
Returns the User that contains this Use.
DominatorTreePrinterPass(raw_ostream &OS)
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
unsigned getNumSuccessors() const
Return the number of successors that this instruction has.
static bool runOnFunction(Function &F, bool PostInlining)
A set of analyses that are preserved following a run of a transformation pass.
const BasicBlock * getSinglePredecessor() const
Return the predecessor of this block if it has a single predecessor block.
LLVM Basic Block Representation.
DominatorTree run(Function &F, FunctionAnalysisManager &)
Run the analysis pass over a function and produce a dominator tree.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
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...
Interval::pred_iterator pred_end(Interval *I)
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
bool VerifyDomInfo
Enables verification of dominator trees.
ArrayRef< llvm::cfg::Update< BasicBlock * > > BBUpdates
INITIALIZE_PASS(DominatorTreeWrapperPass, "domtree", "Dominator Tree Construction", true, true) bool DominatorTreeWrapperPass
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Iterator for intrusive lists based on ilist_node.
BlockVerifier::State From
Generic dominator tree construction - This file provides routines to construct immediate dominator in...
bool dominates(const Instruction *Def, const Use &U) const
Return true if Def dominates a use in User.
static cl::opt< bool, true > VerifyDomInfoX("verify-dom-info", cl::location(VerifyDomInfo), cl::Hidden, cl::desc("Verify dominator info (time consuming)"))
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.
This file provides various utilities for inspecting and working with the control flow graph in LLVM I...
StringRef getName() const
Return a constant reference to the value's name.
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.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This templated class represents "all analyses that operate over <a particular IR unit>" (e...
const BasicBlock * getStart() const
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.
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)
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
const BasicBlock * getParent() const