LLVM 22.0.0git
PostDominators.h
Go to the documentation of this file.
1//=- llvm/Analysis/PostDominators.h - Post Dominator Calculation --*- C++ -*-=//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file exposes interfaces to post dominance information.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_ANALYSIS_POSTDOMINATORS_H
14#define LLVM_ANALYSIS_POSTDOMINATORS_H
15
17#include "llvm/IR/Dominators.h"
18#include "llvm/IR/PassManager.h"
19#include "llvm/Pass.h"
21
22namespace llvm {
23
24class Function;
25class raw_ostream;
26
27/// PostDominatorTree Class - Concrete subclass of DominatorTree that is used to
28/// compute the post-dominator tree.
29class PostDominatorTree : public PostDomTreeBase<BasicBlock> {
30public:
32
33 PostDominatorTree() = default;
35 /// Handle invalidation explicitly.
37 FunctionAnalysisManager::Invalidator &);
38
39 // Ensure base-class overloads are visible.
40 using Base::dominates;
41
42 /// Return true if \p I1 dominates \p I2. This checks if \p I2 comes before
43 /// \p I1 if they belongs to the same basic block.
44 LLVM_ABI bool dominates(const Instruction *I1, const Instruction *I2) const;
45};
46
47/// Analysis pass which computes a \c PostDominatorTree.
49 : public AnalysisInfoMixin<PostDominatorTreeAnalysis> {
51
52 LLVM_ABI static AnalysisKey Key;
53
54public:
55 /// Provide the result type for this analysis pass.
57
58 /// Run the analysis pass over a function and produce a post dominator
59 /// tree.
61};
62
63/// Printer pass for the \c PostDominatorTree.
65 : public PassInfoMixin<PostDominatorTreePrinterPass> {
66 raw_ostream &OS;
67
68public:
70
72
73 static bool isRequired() { return true; }
74};
75
77 static char ID; // Pass identification, replacement for typeid
78
80
82
84 const PostDominatorTree &getPostDomTree() const { return DT; }
85
86 bool runOnFunction(Function &F) override;
87
88 void verifyAnalysis() const override;
89
90 void getAnalysisUsage(AnalysisUsage &AU) const override {
91 AU.setPreservesAll();
92 }
93
94 void releaseMemory() override { DT.reset(); }
95
96 void print(raw_ostream &OS, const Module*) const override;
97};
98
99LLVM_ABI FunctionPass *createPostDomTree();
100
101template <> struct GraphTraits<PostDominatorTree*>
104 return DT->getRootNode();
105 }
106
110
114};
115
116} // end namespace llvm
117
118#endif // LLVM_ANALYSIS_POSTDOMINATORS_H
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
#define LLVM_ABI
Definition Compiler.h:213
This file builds on the ADT/GraphTraits.h file to build generic depth first graph iterator.
static bool runOnFunction(Function &F, bool PostInlining)
This header defines various interfaces for pass management in LLVM.
#define F(x, y, z)
Definition MD5.cpp:55
Represent the analysis usage information of a pass.
void setPreservesAll()
Set by analyses that do not transform their input at all.
DomTreeNodeBase< NodeT > * getRootNode()
getRootNode - This returns the entry node for the CFG of the function.
bool dominates(const DomTreeNodeBase< T > *A, const DomTreeNodeBase< T > *B) const
void recalculate(ParentType &Func)
FunctionPass(char &pid)
Definition Pass.h:316
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:67
Analysis pass which computes a PostDominatorTree.
LLVM_ABI PostDominatorTree run(Function &F, FunctionAnalysisManager &)
Run the analysis pass over a function and produce a post dominator tree.
PostDominatorTree Result
Provide the result type for this analysis pass.
LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
LLVM_ABI PostDominatorTreePrinterPass(raw_ostream &OS)
PostDominatorTree Class - Concrete subclass of DominatorTree that is used to compute the post-dominat...
PostDominatorTree(Function &F)
PostDomTreeBase< BasicBlock > Base
LLVM_ABI bool invalidate(Function &F, const PreservedAnalyses &PA, FunctionAnalysisManager::Invalidator &)
Handle invalidation explicitly.
LLVM_ABI bool dominates(const Instruction *I1, const Instruction *I2) const
Return true if I1 dominates I2.
A set of analyses that are preserved following a run of a transformation pass.
Definition Analysis.h:112
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
This is an optimization pass for GlobalISel generic memory operations.
df_iterator< T > df_begin(const T &G)
DominatorTreeBase< T, true > PostDomTreeBase
LLVM_ABI FunctionPass * createPostDomTree()
df_iterator< T > df_end(const T &G)
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
#define N
A CRTP mix-in that provides informational APIs needed for analysis passes.
Definition PassManager.h:93
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition Analysis.h:29
df_iterator< DomTreeNode *, df_iterator_default_set< DomTreeNode * > > nodes_iterator
Definition Dominators.h:247
static NodeRef getEntryNode(PostDominatorTree *DT)
static nodes_iterator nodes_end(PostDominatorTree *N)
static nodes_iterator nodes_begin(PostDominatorTree *N)
typename PostDominatorTree *::UnknownGraphTypeError NodeRef
Definition GraphTraits.h:95
A CRTP mix-in to automatically provide informational APIs needed for passes.
Definition PassManager.h:70
void releaseMemory() override
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
const PostDominatorTree & getPostDomTree() const
PostDominatorTree & getPostDomTree()
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...