18#include "llvm/Config/llvm-config.h"
43 cl::desc(
"Verify dominator info (time consuming)"));
45#ifdef EXPENSIVE_CHECKS
52 unsigned NumEdgesToEnd = 0;
56 if (NumEdgesToEnd >= 2)
59 assert(NumEdgesToEnd == 1);
79template void llvm::DomTreeBuilder::Calculate<DomTreeBuilder::BBDomTree>(
82llvm::DomTreeBuilder::CalculateWithUpdates<DomTreeBuilder::BBDomTree>(
85template void llvm::DomTreeBuilder::Calculate<DomTreeBuilder::BBPostDomTree>(
89template void llvm::DomTreeBuilder::InsertEdge<DomTreeBuilder::BBDomTree>(
91template void llvm::DomTreeBuilder::InsertEdge<DomTreeBuilder::BBPostDomTree>(
94template void llvm::DomTreeBuilder::DeleteEdge<DomTreeBuilder::BBDomTree>(
96template void llvm::DomTreeBuilder::DeleteEdge<DomTreeBuilder::BBPostDomTree>(
99template void llvm::DomTreeBuilder::ApplyUpdates<DomTreeBuilder::BBDomTree>(
102template void llvm::DomTreeBuilder::ApplyUpdates<DomTreeBuilder::BBPostDomTree>(
106template bool llvm::DomTreeBuilder::Verify<DomTreeBuilder::BBDomTree>(
109template bool llvm::DomTreeBuilder::Verify<DomTreeBuilder::BBPostDomTree>(
123 Instruction *UserInst = cast<Instruction>(U.getUser());
124 if (
auto *PN = dyn_cast<PHINode>(UserInst))
127 return dominates(BB, PN->getIncomingBlock(U));
137 const Instruction *Def = dyn_cast<Instruction>(DefV);
139 assert((isa<Argument>(DefV) || isa<Constant>(DefV)) &&
140 "Should be called with an instruction, argument or constant");
163 if (isa<InvokeInst>(Def) || isa<CallBrInst>(Def) || isa<PHINode>(
User))
169 return Def->comesBefore(
User);
191 if (
const auto *
II = dyn_cast<InvokeInst>(Def)) {
211 if (
End->getSinglePredecessor())
234 int IsDuplicateEdge = 0;
239 if (IsDuplicateEdge++)
251 Instruction *UserInst = cast<Instruction>(U.getUser());
253 PHINode *PN = dyn_cast<PHINode>(UserInst);
269 const Instruction *Def = dyn_cast<Instruction>(DefV);
271 assert((isa<Argument>(DefV) || isa<Constant>(DefV)) &&
272 "Should be called with an instruction, argument or constant");
276 Instruction *UserInst = cast<Instruction>(U.getUser());
283 if (
PHINode *PN = dyn_cast<PHINode>(UserInst))
284 UseBB = PN->getIncomingBlock(U);
315 if (isa<PHINode>(UserInst))
318 return Def->comesBefore(UserInst);
329 if (
PHINode *PN = dyn_cast<PHINode>(
I))
349 return I1->comesBefore(I2) ? I1 : I2;
384 OS <<
"DominatorTree for function: " <<
F.getName() <<
"\n";
414 "Dominator Tree Construction",
true,
true)
423 assert(DT.
verify(DominatorTree::VerificationLevel::Full));
425 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...
uint64_t IntrinsicInst * II
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.
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.
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.
auto successors(const MachineBasicBlock *BB)
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)