18#include "llvm/Config/llvm-config.h"
44 cl::desc(
"Verify dominator info (time consuming)"));
46#ifdef EXPENSIVE_CHECKS
53 unsigned NumEdgesToEnd = 0;
57 if (NumEdgesToEnd >= 2)
60 assert(NumEdgesToEnd == 1);
83llvm::DomTreeBuilder::Calculate<DomTreeBuilder::BBDomTree>(
86llvm::DomTreeBuilder::CalculateWithUpdates<DomTreeBuilder::BBDomTree>(
90llvm::DomTreeBuilder::Calculate<DomTreeBuilder::BBPostDomTree>(
95llvm::DomTreeBuilder::InsertEdge<DomTreeBuilder::BBDomTree>(
98llvm::DomTreeBuilder::InsertEdge<DomTreeBuilder::BBPostDomTree>(
102llvm::DomTreeBuilder::DeleteEdge<DomTreeBuilder::BBDomTree>(
105llvm::DomTreeBuilder::DeleteEdge<DomTreeBuilder::BBPostDomTree>(
109llvm::DomTreeBuilder::ApplyUpdates<DomTreeBuilder::BBDomTree>(
113llvm::DomTreeBuilder::ApplyUpdates<DomTreeBuilder::BBPostDomTree>(
118llvm::DomTreeBuilder::Verify<DomTreeBuilder::BBDomTree>(
122llvm::DomTreeBuilder::Verify<DomTreeBuilder::BBPostDomTree>(
136 Instruction *UserInst = cast<Instruction>(U.getUser());
137 if (
auto *PN = dyn_cast<PHINode>(UserInst))
140 return dominates(BB, PN->getIncomingBlock(U));
150 const Instruction *Def = dyn_cast<Instruction>(DefV);
152 assert((isa<Argument>(DefV) || isa<Constant>(DefV)) &&
153 "Should be called with an instruction, argument or constant");
176 if (isa<InvokeInst>(Def) || isa<CallBrInst>(Def) || isa<PHINode>(
User))
182 return Def->comesBefore(
User);
204 if (
const auto *
II = dyn_cast<InvokeInst>(Def)) {
224 if (
End->getSinglePredecessor())
247 int IsDuplicateEdge = 0;
252 if (IsDuplicateEdge++)
264 Instruction *UserInst = cast<Instruction>(U.getUser());
266 PHINode *PN = dyn_cast<PHINode>(UserInst);
282 const Instruction *Def = dyn_cast<Instruction>(DefV);
284 assert((isa<Argument>(DefV) || isa<Constant>(DefV)) &&
285 "Should be called with an instruction, argument or constant");
289 Instruction *UserInst = cast<Instruction>(U.getUser());
296 if (
PHINode *PN = dyn_cast<PHINode>(UserInst))
297 UseBB = PN->getIncomingBlock(U);
328 if (isa<PHINode>(UserInst))
331 return Def->comesBefore(UserInst);
342 if (
PHINode *PN = dyn_cast<PHINode>(
I))
362 return I1->comesBefore(I2) ? I1 : I2;
397 OS <<
"DominatorTree for function: " <<
F.getName() <<
"\n";
427 "Dominator Tree Construction",
true,
true)
436 assert(DT.
verify(DominatorTree::VerificationLevel::Full));
438 assert(DT.
verify(DominatorTree::VerificationLevel::Basic));
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
BlockVerifier::State From
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define LLVM_EXPORT_TEMPLATE
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.
uint64_t IntrinsicInst * II
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
static constexpr bool ExpensiveChecksEnabled
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
LLVM_ABI 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.
LLVM_ABI 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.
LLVM_ABI DominatorTreePrinterPass(raw_ostream &OS)
LLVM_ABI 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.
LLVM_ABI bool isReachableFromEntry(const Use &U) const
Provide an overload for a Use.
LLVM_ABI 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...
LLVM_ABI bool dominates(const BasicBlock *BB, const Use &U) const
Return true if the (end of the) basic block BB dominates the use U.
LLVM_ABI bool invalidate(Function &F, const PreservedAnalyses &PA, FunctionAnalysisManager::Invalidator &)
Handle invalidation explicitly.
FunctionPass class - This class is used to implement most global optimizations.
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 LLVM_ABI 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.
const ParentTy * getParent() const
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, unsigned DynamicVGPRBlockSize=0)
auto successors(const MachineBasicBlock *BB)
LLVM_ABI void initializeDominatorTreeWrapperPassPass(PassRegistry &)
LLVM_ABI 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...
LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)