Go to the documentation of this file.
18 #include "llvm/Config/llvm-config.h"
42 cl::desc(
"Verify dominator info (time consuming)"));
44 #ifdef EXPENSIVE_CHECKS
52 unsigned NumEdgesToEnd = 0;
56 if (NumEdgesToEnd >= 2)
59 assert(NumEdgesToEnd == 1);
79 template void llvm::DomTreeBuilder::Calculate<DomTreeBuilder::BBDomTree>(
82 llvm::DomTreeBuilder::CalculateWithUpdates<DomTreeBuilder::BBDomTree>(
85 template void llvm::DomTreeBuilder::Calculate<DomTreeBuilder::BBPostDomTree>(
89 template void llvm::DomTreeBuilder::InsertEdge<DomTreeBuilder::BBDomTree>(
91 template void llvm::DomTreeBuilder::InsertEdge<DomTreeBuilder::BBPostDomTree>(
94 template void llvm::DomTreeBuilder::DeleteEdge<DomTreeBuilder::BBDomTree>(
96 template void llvm::DomTreeBuilder::DeleteEdge<DomTreeBuilder::BBPostDomTree>(
99 template void llvm::DomTreeBuilder::ApplyUpdates<DomTreeBuilder::BBDomTree>(
102 template void llvm::DomTreeBuilder::ApplyUpdates<DomTreeBuilder::BBPostDomTree>(
106 template bool llvm::DomTreeBuilder::Verify<DomTreeBuilder::BBDomTree>(
109 template bool llvm::DomTreeBuilder::Verify<DomTreeBuilder::BBPostDomTree>(
124 if (
auto *PN = dyn_cast<PHINode>(UserInst))
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))
191 if (
const auto *II = dyn_cast<InvokeInst>(
Def)) {
198 if (
const auto *CBI = dyn_cast<CallBrInst>(
Def)) {
199 BasicBlock *NormalDest = CBI->getDefaultDest();
218 if (End->getSinglePredecessor())
241 int IsDuplicateEdge = 0;
246 if (IsDuplicateEdge++)
260 PHINode *PN = dyn_cast<PHINode>(UserInst);
278 assert((isa<Argument>(DefV) || isa<Constant>(DefV)) &&
279 "Should be called with an instruction, argument or constant");
290 if (
PHINode *PN = dyn_cast<PHINode>(UserInst))
291 UseBB = PN->getIncomingBlock(U);
315 if (
const auto *CBI = dyn_cast<CallBrInst>(
Def)) {
316 BasicBlock *NormalDest = CBI->getDefaultDest();
329 if (isa<PHINode>(UserInst))
332 return Def->comesBefore(UserInst);
343 if (
PHINode *PN = dyn_cast<PHINode>(
I))
363 return I1->comesBefore(I2) ? I1 : I2;
398 OS <<
"DominatorTree for function: " <<
F.getName() <<
"\n";
428 "Dominator Tree Construction",
true,
true)
A set of analyses that are preserved following a run of a transformation pass.
INITIALIZE_PASS(DominatorTreeWrapperPass, "domtree", "Dominator Tree Construction", true, true) bool DominatorTreeWrapperPass
This class represents an incoming formal argument to a Function.
unsigned getNumSuccessors() const LLVM_READONLY
Return the number of successors that this instruction has.
This is an optimization pass for GlobalISel generic memory operations.
void print(raw_ostream &O) const
print - Convert to human readable form
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
LocationClass< Ty > location(Ty &L)
ArrayRef< llvm::cfg::Update< BasicBlock * > > BBUpdates
This templated class represents "all analyses that operate over <a particular IR unit>" (e....
bool invalidate(Function &F, const PreservedAnalyses &PA, FunctionAnalysisManager::Invalidator &)
Handle invalidation explicitly.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
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.
LLVM Basic Block Representation.
bool dominates(const BasicBlock *BB, const Use &U) const
Return true if the (end of the) basic block BB dominates the use U.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Legacy analysis pass which computes a DominatorTree.
This class implements an extremely fast bulk output stream that can only output to a stream.
User * getUser() const
Returns the User that contains this Use.
const BasicBlock * getStart() const
API to communicate dependencies between analyses during invalidation.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
auto predecessors(const MachineBasicBlock *BB)
This is an important base class in LLVM.
BasicBlock * getSuccessor(unsigned Idx) const LLVM_READONLY
Return the specified successor. This instruction must be a terminator.
A special type used by analysis passes to provide an address that identifies that particular analysis...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool isReachableFromEntry(const Use &U) const
Provide an overload for a Use.
A Module instance is used to store all the information related to an LLVM module.
DominatorTree run(Function &F, FunctionAnalysisManager &)
Run the analysis pass over a function and produce a dominator tree.
Printable print(const GCNRegPressure &RP, const GCNSubtarget *ST=nullptr)
void recalculate(ParentType &Func)
recalculate - compute a dominator tree for the given function
const BasicBlock * getEnd() const
Represents analyses that only rely on functions' control flow.
void verifyAnalysis() const override
verifyAnalysis() - This member can be implemented by a analysis pass to check state of analysis infor...
bool properlyDominates(const DomTreeNodeBase< BasicBlock > *A, const DomTreeNodeBase< BasicBlock > *B) const
properlyDominates - Returns true iff A dominates B and A != B.
static constexpr bool ExpensiveChecksEnabled
static bool runOnFunction(Function &F, bool PostInlining)
bool isSingleEdge() const
Check if this is the only edge between Start and End.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
void initializeDominatorTreeWrapperPassPass(PassRegistry &)
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...
Analysis pass which computes a DominatorTree.
DominatorTreePrinterPass(raw_ostream &OS)
const BasicBlock * getParent() const
BasicBlock * getIncomingBlock(unsigned i) const
Return incoming basic block number i.
bool verify(VerificationLevel VL=VerificationLevel::Full) const
verify - checks if the tree is correct.
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...
PreservedAnalysisChecker getChecker() const
Build a checker for this PreservedAnalyses and the specified analysis type.
A container for analyses that lazily runs them and caches their results.
FunctionPass class - This class is used to implement most global optimizations.
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
BlockVerifier::State From
The same transformation can work with an even modulo with the addition of a and shrink the compare RHS by the same amount Unless the target supports that transformation probably isn t worthwhile The transformation can also easily be made to work with non zero equality for n
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
LLVM Value Representation.
bool VerifyDomInfo
Enables verification of dominator trees.
A Use represents the edge between a Value definition and its users.
DominatorTreeWrapperPass()