llvm.org GIT mirror llvm / bb4954d
[PM][cleanup] Clean up comments and use modern doxygen in this file. This is a precursor to breaking the pass that computes the DominatorTree apart from the concrete DominatorTree. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199103 91177308-0d34-0410-b5e6-96231b3b80d8 Chandler Carruth 6 years ago
1 changed file(s) with 35 addition(s) and 33 deletion(s). Raw diff Collapse all Expand all
5050 bool isSingleEdge() const;
5151 };
5252
53 //===-------------------------------------
54 /// DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to
55 /// compute a normal dominator tree.
56 ///
53 /// \brief Concrete subclass of DominatorTreeBase that is used to compute a
54 /// normal dominator tree.
5755 class DominatorTree : public FunctionPass {
5856 public:
5957 static char ID; // Pass ID, replacement for typeid
7068
7169 DominatorTreeBase& getBase() { return *DT; }
7270
73 /// getRoots - Return the root blocks of the current CFG. This may include
74 /// multiple blocks if we are computing post dominators. For forward
75 /// dominators, this will always be a single block (the entry node).
76 ///
71 /// \brief Returns the root blocks of the current CFG.
72 ///
73 /// This may include multiple blocks if we are computing post dominators.
74 /// For forward dominators, this will always be a single block (the entry
75 /// node).
7776 inline const std::vector &getRoots() const {
7877 return DT->getRoots();
7978 }
9291 DT->getDescendants(R, Result);
9392 }
9493
95 /// compare - Return false if the other dominator tree matches this
96 /// dominator tree. Otherwise return true.
94 /// \brief Returns *false* if the other dominator tree matches this dominator
95 /// tree.
9796 inline bool compare(DominatorTree &Other) const {
9897 DomTreeNode *R = getRootNode();
9998 DomTreeNode *OtherR = Other.getRootNode();
123122 return DT->dominates(A, B);
124123 }
125124
126 // dominates - Return true if Def dominates a use in User. This performs
127 // the special checks necessary if Def and User are in the same basic block.
128 // Note that Def doesn't dominate a use in Def itself!
125 // \brief Return true if Def dominates a use in User.
126 //
127 // This performs the special checks necessary if Def and User are in the same
128 // basic block. Note that Def doesn't dominate a use in Def itself!
129129 bool dominates(const Instruction *Def, const Use &U) const;
130130 bool dominates(const Instruction *Def, const Instruction *User) const;
131131 bool dominates(const Instruction *Def, const BasicBlock *BB) const;
140140 return DT->properlyDominates(A, B);
141141 }
142142
143 /// findNearestCommonDominator - Find nearest common dominator basic block
144 /// for basic block A and B. If there is no such block then return NULL.
143 /// \brief Find nearest common dominator basic block for basic block A and B.
144 ///
145 /// If there is no such block then return NULL.
145146 inline BasicBlock *findNearestCommonDominator(BasicBlock *A, BasicBlock *B) {
146147 return DT->findNearestCommonDominator(A, B);
147148 }
155156 return DT->getNode(BB);
156157 }
157158
158 /// getNode - return the (Post)DominatorTree node for the specified basic
159 /// block. This is the same as using operator[] on this class.
160 ///
159 /// \brief Returns the DominatorTree node for the specified basic block.
160 ///
161 /// This is the same as using operator[] on this class.
161162 inline DomTreeNode *getNode(BasicBlock *BB) const {
162163 return DT->getNode(BB);
163164 }
164165
165 /// addNewBlock - Add a new node to the dominator tree information. This
166 /// creates a new node as a child of DomBB dominator node,linking it into
167 /// the children list of the immediate dominator.
166 /// \brief Add a new node to the dominator tree information.
167 ///
168 /// This creates a new node as a child of DomBB dominator node, linking it
169 /// into the children list of the immediate dominator.
168170 inline DomTreeNode *addNewBlock(BasicBlock *BB, BasicBlock *DomBB) {
169171 return DT->addNewBlock(BB, DomBB);
170172 }
171173
172 /// changeImmediateDominator - This method is used to update the dominator
173 /// tree information when a node's immediate dominator changes.
174 ///
174 /// \brief Updates the dominator tree information when a node's immediate
175 /// dominator changes.
175176 inline void changeImmediateDominator(BasicBlock *N, BasicBlock* NewIDom) {
176177 DT->changeImmediateDominator(N, NewIDom);
177178 }
180181 DT->changeImmediateDominator(N, NewIDom);
181182 }
182183
183 /// eraseNode - Removes a node from the dominator tree. Block must not
184 /// dominate any other blocks. Removes node from its immediate dominator's
185 /// children list. Deletes dominator node associated with basic block BB.
184 /// \brief Removes a node from the dominator tree.
185 ///
186 /// The block must not dominate any other blocks. Removes node from its
187 /// immediate dominator's children list. Deletes dominator node associated
188 /// with basic block BB.
186189 inline void eraseNode(BasicBlock *BB) {
187190 DT->eraseNode(BB);
188191 }
189192
190 /// splitBlock - BB is split and now it has one successor. Update dominator
191 /// tree to reflect this change.
193 /// \brief BB is split and now it has one successor; update dominator tree to
194 /// reflect this change.
192195 inline void splitBlock(BasicBlock* NewBB) {
193196 DT->splitBlock(NewBB);
194197 }
208211 };
209212
210213 //===-------------------------------------
211 /// DominatorTree GraphTraits specialization so the DominatorTree can be
212 /// iterable by generic graph iterators.
213 ///
214 // DominatorTree GraphTraits specializations so the DominatorTree can be
215 // iterable by generic graph iterators.
216
214217 template <> struct GraphTraits {
215218 typedef DomTreeNode NodeType;
216219 typedef NodeType::iterator ChildIteratorType;
251254 }
252255 };
253256
254
255257 } // End llvm namespace
256258
257259 #endif