llvm.org GIT mirror llvm / 7f2eff7
[PM] Split DominatorTree into a concrete analysis result object which can be used by both the new pass manager and the old. This removes it from any of the virtual mess of the pass interfaces and lets it derive cleanly from the DominatorTreeBase<> template. In turn, tons of boilerplate interface can be nuked and it turns into a very straightforward extension of the base DominatorTree interface. The old analysis pass is now a simple wrapper. The names and style of this split should match the split between CallGraph and CallGraphWrapperPass. All of the users of DominatorTree have been updated to match using many of the same tricks as with CallGraph. The goal is that the common type remains the resulting DominatorTree rather than the pass. This will make subsequent work toward the new pass manager significantly easier. Also in numerous places things became cleaner because I switched from re-running the pass (!!! mid way through some other passes run!!!) to directly recomputing the domtree. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199104 91177308-0d34-0410-b5e6-96231b3b80d8 Chandler Carruth 6 years ago
60 changed file(s) with 358 addition(s) and 369 deletion(s). Raw diff Collapse all Expand all
168168
169169 virtual bool runOnFunction(Function &) {
170170 Frontiers.clear();
171 DominatorTree &DT = getAnalysis>();
171 DominatorTree &DT = getAnalysisWrapperPass>().getDomTree();
172172 Roots = DT.getRoots();
173173 assert(Roots.size() == 1 && "Only one entry block for forward domfronts!");
174174 calculate(DT, DT[Roots[0]]);
177177
178178 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
179179 AU.setPreservesAll();
180 AU.addRequired>();
180 AU.addRequiredWrapperPass>();
181181 }
182182
183183 const DomSetType &calculate(const DominatorTree &DT,
114114 }
115115
116116 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
117 AU.addPreserved>();
117 AU.addPreservedWrapperPass>();
118118 }
119119
120120 SSPLayoutKind getSSPLayout(const AllocaInst *AI) const;
5252
5353 /// \brief Concrete subclass of DominatorTreeBase that is used to compute a
5454 /// normal dominator tree.
55 class DominatorTree : public FunctionPass {
55 class DominatorTree : public DominatorTreeBase {
5656 public:
57 static char ID; // Pass ID, replacement for typeid
58 DominatorTreeBase* DT;
57 typedef DominatorTreeBase Base;
5958
60 DominatorTree() : FunctionPass(ID) {
61 initializeDominatorTreePass(*PassRegistry::getPassRegistry());
62 DT = new DominatorTreeBase(false);
63 }
59 DominatorTree() : DominatorTreeBase(false) {}
6460
65 ~DominatorTree() {
66 delete DT;
67 }
68
69 DominatorTreeBase& getBase() { return *DT; }
70
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).
76 inline const std::vector &getRoots() const {
77 return DT->getRoots();
78 }
79
80 inline BasicBlock *getRoot() const {
81 return DT->getRoot();
82 }
83
84 inline DomTreeNode *getRootNode() const {
85 return DT->getRootNode();
86 }
87
88 /// Get all nodes dominated by R, including R itself.
89 void getDescendants(BasicBlock *R,
90 SmallVectorImpl &Result) const {
91 DT->getDescendants(R, Result);
92 }
61 // FIXME: This is no longer needed and should be removed when its uses are
62 // cleaned up.
63 Base& getBase() { return *this; }
9364
9465 /// \brief Returns *false* if the other dominator tree matches this dominator
9566 /// tree.
96 inline bool compare(DominatorTree &Other) const {
97 DomTreeNode *R = getRootNode();
98 DomTreeNode *OtherR = Other.getRootNode();
67 inline bool compare(const DominatorTree &Other) const {
68 const DomTreeNode *R = getRootNode();
69 const DomTreeNode *OtherR = Other.getRootNode();
9970
10071 if (!R || !OtherR || R->getBlock() != OtherR->getBlock())
10172 return true;
10273
103 if (DT->compare(Other.getBase()))
74 if (Base::compare(Other))
10475 return true;
10576
10677 return false;
10778 }
10879
109 virtual bool runOnFunction(Function &F);
80 // Ensure base-class overloads are visible.
81 using Base::dominates;
11082
111 virtual void verifyAnalysis() const;
112
113 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
114 AU.setPreservesAll();
115 }
116
117 inline bool dominates(const DomTreeNode* A, const DomTreeNode* B) const {
118 return DT->dominates(A, B);
119 }
120
121 inline bool dominates(const BasicBlock* A, const BasicBlock* B) const {
122 return DT->dominates(A, B);
123 }
124
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!
83 /// \brief Return true if Def dominates a use in User.
84 ///
85 /// This performs the special checks necessary if Def and User are in the same
86 /// basic block. Note that Def doesn't dominate a use in Def itself!
12987 bool dominates(const Instruction *Def, const Use &U) const;
13088 bool dominates(const Instruction *Def, const Instruction *User) const;
13189 bool dominates(const Instruction *Def, const BasicBlock *BB) const;
13290 bool dominates(const BasicBlockEdge &BBE, const Use &U) const;
13391 bool dominates(const BasicBlockEdge &BBE, const BasicBlock *BB) const;
13492
135 bool properlyDominates(const DomTreeNode *A, const DomTreeNode *B) const {
136 return DT->properlyDominates(A, B);
93 inline DomTreeNode *operator[](BasicBlock *BB) const {
94 return getNode(BB);
13795 }
13896
139 bool properlyDominates(const BasicBlock *A, const BasicBlock *B) const {
140 return DT->properlyDominates(A, B);
141 }
97 // Ensure base class overloads are visible.
98 using Base::isReachableFromEntry;
14299
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.
146 inline BasicBlock *findNearestCommonDominator(BasicBlock *A, BasicBlock *B) {
147 return DT->findNearestCommonDominator(A, B);
148 }
149
150 inline const BasicBlock *findNearestCommonDominator(const BasicBlock *A,
151 const BasicBlock *B) {
152 return DT->findNearestCommonDominator(A, B);
153 }
154
155 inline DomTreeNode *operator[](BasicBlock *BB) const {
156 return DT->getNode(BB);
157 }
158
159 /// \brief Returns the DominatorTree node for the specified basic block.
160 ///
161 /// This is the same as using operator[] on this class.
162 inline DomTreeNode *getNode(BasicBlock *BB) const {
163 return DT->getNode(BB);
164 }
165
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.
170 inline DomTreeNode *addNewBlock(BasicBlock *BB, BasicBlock *DomBB) {
171 return DT->addNewBlock(BB, DomBB);
172 }
173
174 /// \brief Updates the dominator tree information when a node's immediate
175 /// dominator changes.
176 inline void changeImmediateDominator(BasicBlock *N, BasicBlock* NewIDom) {
177 DT->changeImmediateDominator(N, NewIDom);
178 }
179
180 inline void changeImmediateDominator(DomTreeNode *N, DomTreeNode* NewIDom) {
181 DT->changeImmediateDominator(N, NewIDom);
182 }
183
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.
189 inline void eraseNode(BasicBlock *BB) {
190 DT->eraseNode(BB);
191 }
192
193 /// \brief BB is split and now it has one successor; update dominator tree to
194 /// reflect this change.
195 inline void splitBlock(BasicBlock* NewBB) {
196 DT->splitBlock(NewBB);
197 }
198
199 bool isReachableFromEntry(const BasicBlock* A) const {
200 return DT->isReachableFromEntry(A);
201 }
202
100 /// \brief Provide an overload for a Use.
203101 bool isReachableFromEntry(const Use &U) const;
204102
205
206 virtual void releaseMemory() {
207 DT->releaseMemory();
208 }
209
210 virtual void print(raw_ostream &OS, const Module* M= 0) const;
103 /// \brief Verify the correctness of the domtree by re-computing it.
104 ///
105 /// This should only be used for debugging as it aborts the program if the
106 /// verification fails.
107 void verifyDomTree() const;
211108 };
212109
213110 //===-------------------------------------
254151 }
255152 };
256153
154 /// \brief Analysis pass which computes a \c DominatorTree.
155 class DominatorTreeWrapperPass : public FunctionPass {
156 DominatorTree DT;
157
158 public:
159 static char ID;
160
161 DominatorTreeWrapperPass() : FunctionPass(ID) {
162 initializeDominatorTreeWrapperPassPass(*PassRegistry::getPassRegistry());
163 }
164
165 DominatorTree &getDomTree() { return DT; }
166 const DominatorTree &getDomTree() const { return DT; }
167
168 virtual bool runOnFunction(Function &F);
169
170 virtual void verifyAnalysis() const;
171
172 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
173 AU.setPreservesAll();
174 }
175
176 virtual void releaseMemory() { DT.releaseMemory(); }
177
178 virtual void print(raw_ostream &OS, const Module *M = 0) const;
179 };
180
257181 } // End llvm namespace
258182
259183 #endif
109109 void initializeDomPrinterPass(PassRegistry&);
110110 void initializeDomViewerPass(PassRegistry&);
111111 void initializeDominanceFrontierPass(PassRegistry&);
112 void initializeDominatorTreePass(PassRegistry&);
112 void initializeDominatorTreeWrapperPassPass(PassRegistry&);
113113 void initializeEarlyIfConverterPass(PassRegistry&);
114114 void initializeEdgeBundlesPass(PassRegistry&);
115115 void initializeExpandPostRAPass(PassRegistry&);
297297
298298 /// compare - Return false if the other dominator tree base matches this
299299 /// dominator tree base. Otherwise return true.
300 bool compare(DominatorTreeBase &Other) const {
300 bool compare(const DominatorTreeBase &Other) const {
301301
302302 const DomTreeNodeMapType &OtherDomTreeNodes = Other.DomTreeNodes;
303303 if (DomTreeNodes.size() != OtherDomTreeNodes.size())
13341334 return false;
13351335
13361336 // Use dominance or loop info if available.
1337 DominatorTree *DT = getAnalysisIfAvailable();
1337 DominatorTreeWrapperPass *DTWP =
1338 getAnalysisIfAvailable();
1339 DominatorTree *DT = DTWP ? &DTWP->getDomTree() : 0;
13381340 LoopInfo *LI = getAnalysisIfAvailable();
13391341
13401342 // Make sure that the visited phis cannot reach the Value. This ensures that
8080 }
8181
8282 namespace {
83 struct DomViewer
84 : public DOTGraphTraitsViewer {
85 static char ID;
86 DomViewer() : DOTGraphTraitsViewer("dom", ID){
83 struct DominatorTreeWrapperPassAnalysisGraphTraits {
84 static DominatorTree *getGraph(DominatorTreeWrapperPass *DTWP) {
85 return &DTWP->getDomTree();
86 }
87 };
88
89 struct DomViewer : public DOTGraphTraitsViewer<
90 DominatorTreeWrapperPass, false, DominatorTree *,
91 DominatorTreeWrapperPassAnalysisGraphTraits> {
92 static char ID;
93 DomViewer()
94 : DOTGraphTraitsViewer
95 DominatorTreeWrapperPassAnalysisGraphTraits>(
96 "dom", ID) {
8797 initializeDomViewerPass(*PassRegistry::getPassRegistry());
8898 }
8999 };
90100
91 struct DomOnlyViewer
92 : public DOTGraphTraitsViewer {
93 static char ID;
94 DomOnlyViewer() : DOTGraphTraitsViewer("domonly", ID){
101 struct DomOnlyViewer : public DOTGraphTraitsViewer<
102 DominatorTreeWrapperPass, true, DominatorTree *,
103 DominatorTreeWrapperPassAnalysisGraphTraits> {
104 static char ID;
105 DomOnlyViewer()
106 : DOTGraphTraitsViewer
107 DominatorTreeWrapperPassAnalysisGraphTraits>(
108 "domonly", ID) {
95109 initializeDomOnlyViewerPass(*PassRegistry::getPassRegistry());
96110 }
97111 };
135149 false, false)
136150
137151 namespace {
138 struct DomPrinter
139 : public DOTGraphTraitsPrinter {
140 static char ID;
141 DomPrinter() : DOTGraphTraitsPrinter("dom", ID) {
152 struct DomPrinter : public DOTGraphTraitsPrinter<
153 DominatorTreeWrapperPass, false, DominatorTree *,
154 DominatorTreeWrapperPassAnalysisGraphTraits> {
155 static char ID;
156 DomPrinter()
157 : DOTGraphTraitsPrinter
158 DominatorTreeWrapperPassAnalysisGraphTraits>(
159 "dom", ID) {
142160 initializeDomPrinterPass(*PassRegistry::getPassRegistry());
143161 }
144162 };
145163
146 struct DomOnlyPrinter
147 : public DOTGraphTraitsPrinter {
148 static char ID;
149 DomOnlyPrinter() : DOTGraphTraitsPrinter("domonly", ID) {
164 struct DomOnlyPrinter : public DOTGraphTraitsPrinter<
165 DominatorTreeWrapperPass, true, DominatorTree *,
166 DominatorTreeWrapperPassAnalysisGraphTraits> {
167 static char ID;
168 DomOnlyPrinter()
169 : DOTGraphTraitsPrinter
170 DominatorTreeWrapperPassAnalysisGraphTraits>(
171 "domonly", ID) {
150172 initializeDomOnlyPrinterPass(*PassRegistry::getPassRegistry());
151173 }
152174 };
1515 char DominanceFrontier::ID = 0;
1616 INITIALIZE_PASS_BEGIN(DominanceFrontier, "domfrontier",
1717 "Dominance Frontier Construction", true, true)
18 INITIALIZE_PASS_DEPENDENCY(DominatorTree)
18 INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
1919 INITIALIZE_PASS_END(DominanceFrontier, "domfrontier",
2020 "Dominance Frontier Construction", true, true)
2121
3232 INITIALIZE_PASS_BEGIN(IVUsers, "iv-users",
3333 "Induction Variable Users", false, true)
3434 INITIALIZE_PASS_DEPENDENCY(LoopInfo)
35 INITIALIZE_PASS_DEPENDENCY(DominatorTree)
35 INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
3636 INITIALIZE_PASS_DEPENDENCY(ScalarEvolution)
3737 INITIALIZE_PASS_END(IVUsers, "iv-users",
3838 "Induction Variable Users", false, true)
222222
223223 void IVUsers::getAnalysisUsage(AnalysisUsage &AU) const {
224224 AU.addRequired();
225 AU.addRequired>();
225 AU.addRequiredWrapperPass>();
226226 AU.addRequired();
227227 AU.setPreservesAll();
228228 }
231231
232232 L = l;
233233 LI = &getAnalysis();
234 DT = &getAnalysis>();
234 DT = &getAnalysisWrapperPass>().getDomTree();
235235 SE = &getAnalysis();
236236 TD = getAnalysisIfAvailable();
237237
118118 AU.setPreservesAll();
119119 AU.addRequired();
120120 AU.addRequired();
121 AU.addRequired>();
121 AU.addRequiredWrapperPass>();
122122 }
123123 virtual void print(raw_ostream &O, const Module *M) const {}
124124
151151 INITIALIZE_PASS_BEGIN(Lint, "lint", "Statically lint-checks LLVM IR",
152152 false, true)
153153 INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfo)
154 INITIALIZE_PASS_DEPENDENCY(DominatorTree)
154 INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
155155 INITIALIZE_AG_DEPENDENCY(AliasAnalysis)
156156 INITIALIZE_PASS_END(Lint, "lint", "Statically lint-checks LLVM IR",
157157 false, true)
174174 bool Lint::runOnFunction(Function &F) {
175175 Mod = F.getParent();
176176 AA = &getAnalysis();
177 DT = &getAnalysis>();
177 DT = &getAnalysisWrapperPass>().getDomTree();
178178 TD = getAnalysisIfAvailable();
179179 TLI = &getAnalysis();
180180 visit(F);
4545
4646 char LoopInfo::ID = 0;
4747 INITIALIZE_PASS_BEGIN(LoopInfo, "loops", "Natural Loop Information", true, true)
48 INITIALIZE_PASS_DEPENDENCY(DominatorTree)
48 INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
4949 INITIALIZE_PASS_END(LoopInfo, "loops", "Natural Loop Information", true, true)
5050
5151 // Loop identifier metadata name.
612612 //
613613 bool LoopInfo::runOnFunction(Function &) {
614614 releaseMemory();
615 LI.Analyze(getAnalysis>().getBase());
615 LI.Analyze(getAnalysisWrapperPass>().getDomTree());
616616 return false;
617617 }
618618
703703
704704 void LoopInfo::getAnalysisUsage(AnalysisUsage &AU) const {
705705 AU.setPreservesAll();
706 AU.addRequired>();
706 AU.addRequiredWrapperPass>();
707707 }
708708
709709 void LoopInfo::print(raw_ostream &OS, const Module*) const {
8787 bool MemoryDependenceAnalysis::runOnFunction(Function &) {
8888 AA = &getAnalysis();
8989 TD = getAnalysisIfAvailable();
90 DT = getAnalysisIfAvailable();
90 DominatorTreeWrapperPass *DTWP =
91 getAnalysisIfAvailable();
92 DT = DTWP ? &DTWP->getDomTree() : 0;
9193 if (!PredCache)
9294 PredCache.reset(new PredIteratorCache());
9395 return false;
705705 bool RegionInfo::runOnFunction(Function &F) {
706706 releaseMemory();
707707
708 DT = &getAnalysis>();
708 DT = &getAnalysisWrapperPass>().getDomTree();
709709 PDT = &getAnalysis();
710710 DF = &getAnalysis();
711711
719719
720720 void RegionInfo::getAnalysisUsage(AnalysisUsage &AU) const {
721721 AU.setPreservesAll();
722 AU.addRequiredTransitive>();
722 AU.addRequiredTransitiveWrapperPass>();
723723 AU.addRequired();
724724 AU.addRequired();
725725 }
845845 char RegionInfo::ID = 0;
846846 INITIALIZE_PASS_BEGIN(RegionInfo, "regions",
847847 "Detect single entry single exit regions", true, true)
848 INITIALIZE_PASS_DEPENDENCY(DominatorTree)
848 INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
849849 INITIALIZE_PASS_DEPENDENCY(PostDominatorTree)
850850 INITIALIZE_PASS_DEPENDENCY(DominanceFrontier)
851851 INITIALIZE_PASS_END(RegionInfo, "regions",
112112 INITIALIZE_PASS_BEGIN(ScalarEvolution, "scalar-evolution",
113113 "Scalar Evolution Analysis", false, true)
114114 INITIALIZE_PASS_DEPENDENCY(LoopInfo)
115 INITIALIZE_PASS_DEPENDENCY(DominatorTree)
115 INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
116116 INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfo)
117117 INITIALIZE_PASS_END(ScalarEvolution, "scalar-evolution",
118118 "Scalar Evolution Analysis", false, true)
72677267 LI = &getAnalysis();
72687268 TD = getAnalysisIfAvailable();
72697269 TLI = &getAnalysis();
7270 DT = &getAnalysis>();
7270 DT = &getAnalysisWrapperPass>().getDomTree();
72717271 return false;
72727272 }
72737273
73047304 void ScalarEvolution::getAnalysisUsage(AnalysisUsage &AU) const {
73057305 AU.setPreservesAll();
73067306 AU.addRequiredTransitive();
7307 AU.addRequiredTransitive>();
7307 AU.addRequiredTransitiveWrapperPass>();
73087308 AU.addRequired();
73097309 }
73107310
4141
4242 public:
4343 static char ID; // Pass identification, replacement for typeid.
44 DwarfEHPrepare(const TargetMachine *TM) :
45 FunctionPass(ID), TM(TM), RewindFunction(0) {
46 initializeDominatorTreePass(*PassRegistry::getPassRegistry());
47 }
44 DwarfEHPrepare(const TargetMachine *TM)
45 : FunctionPass(ID), TM(TM), RewindFunction(0) {
46 initializeDominatorTreeWrapperPassPass(*PassRegistry::getPassRegistry());
47 }
4848
4949 virtual bool runOnFunction(Function &Fn);
5050
152152 void LowerIntrinsics::getAnalysisUsage(AnalysisUsage &AU) const {
153153 FunctionPass::getAnalysisUsage(AU);
154154 AU.addRequired();
155 AU.addPreserved>();
155 AU.addPreservedWrapperPass>();
156156 }
157157
158158 /// doInitialization - If this module uses the GC intrinsics, find them now.
269269
270270 // Custom lowering may modify the CFG, so dominators must be recomputed.
271271 if (UseCustomLoweringPass) {
272 if (DominatorTree *DT = getAnalysisIfAvailable())
273 DT->DT->recalculate(F);
272 if (DominatorTreeWrapperPass *DTWP =
273 getAnalysisIfAvailable())
274 DTWP->getDomTree().recalculate(F);
274275 }
275276
276277 return MadeChange;
5959 bool StackProtector::runOnFunction(Function &Fn) {
6060 F = &Fn;
6161 M = F->getParent();
62 DT = getAnalysisIfAvailable();
62 DominatorTreeWrapperPass *DTWP =
63 getAnalysisIfAvailable();
64 DT = DTWP ? &DTWP->getDomTree() : 0;
6365 TLI = TM->getTargetLowering();
6466
6567 if (!RequiresStackProtector())
4747 }
4848
4949 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
50 AU.addPreserved>();
50 AU.addPreservedWrapperPass>();
5151 }
5252 };
5353 }
3939 using namespace llvm;
4040
4141 void llvm::initializeCore(PassRegistry &Registry) {
42 initializeDominatorTreePass(Registry);
42 initializeDominatorTreeWrapperPassPass(Registry);
4343 initializePrintModulePassWrapperPass(Registry);
4444 initializePrintFunctionPassWrapperPass(Registry);
4545 initializePrintBasicBlockPassPass(Registry);
6262
6363 TEMPLATE_INSTANTIATION(class llvm::DomTreeNodeBase);
6464 TEMPLATE_INSTANTIATION(class llvm::DominatorTreeBase);
65
66 char DominatorTree::ID = 0;
67 INITIALIZE_PASS(DominatorTree, "domtree",
68 "Dominator Tree Construction", true, true)
69
70 bool DominatorTree::runOnFunction(Function &F) {
71 DT->recalculate(F);
72 return false;
73 }
74
75 void DominatorTree::verifyAnalysis() const {
76 if (!VerifyDomInfo) return;
77
78 Function &F = *getRoot()->getParent();
79
80 DominatorTree OtherDT;
81 OtherDT.getBase().recalculate(F);
82 if (compare(OtherDT)) {
83 errs() << "DominatorTree is not up to date!\nComputed:\n";
84 print(errs());
85 errs() << "\nActual:\n";
86 OtherDT.print(errs());
87 abort();
88 }
89 }
90
91 void DominatorTree::print(raw_ostream &OS, const Module *) const {
92 DT->print(OS);
93 }
9465
9566 // dominates - Return true if Def dominates a use in User. This performs
9667 // the special checks necessary if Def and User are in the same basic block.
209180 return true;
210181 }
211182
212 bool DominatorTree::dominates(const BasicBlockEdge &BBE,
213 const Use &U) const {
183 bool DominatorTree::dominates(const BasicBlockEdge &BBE, const Use &U) const {
214184 // Assert that we have a single edge. We could handle them by simply
215185 // returning false, but since isSingleEdge is linear on the number of
216186 // edges, the callers can normally handle them more efficiently.
233203 return dominates(BBE, UseBB);
234204 }
235205
236 bool DominatorTree::dominates(const Instruction *Def,
237 const Use &U) const {
206 bool DominatorTree::dominates(const Instruction *Def, const Use &U) const {
238207 Instruction *UserInst = cast(U.getUser());
239208 const BasicBlock *DefBB = Def->getParent();
240209
299268 // Everything else uses their operands in their own block.
300269 return isReachableFromEntry(I->getParent());
301270 }
271
272 void DominatorTree::verifyDomTree() const {
273 if (!VerifyDomInfo)
274 return;
275
276 Function &F = *getRoot()->getParent();
277
278 DominatorTree OtherDT;
279 OtherDT.recalculate(F);
280 if (compare(OtherDT)) {
281 errs() << "DominatorTree is not up to date!\nComputed:\n";
282 print(errs());
283 errs() << "\nActual:\n";
284 OtherDT.print(errs());
285 abort();
286 }
287 }
288
289 //===----------------------------------------------------------------------===//
290 // DominatorTreeWrapperPass Implementation
291 //===----------------------------------------------------------------------===//
292 //
293 // The implementation details of the wrapper pass that holds a DominatorTree.
294 //
295 //===----------------------------------------------------------------------===//
296
297 char DominatorTreeWrapperPass::ID = 0;
298 INITIALIZE_PASS(DominatorTreeWrapperPass, "domtree",
299 "Dominator Tree Construction", true, true)
300
301 bool DominatorTreeWrapperPass::runOnFunction(Function &F) {
302 DT.recalculate(F);
303 return false;
304 }
305
306 void DominatorTreeWrapperPass::verifyAnalysis() const { DT.verifyDomTree(); }
307
308 void DominatorTreeWrapperPass::print(raw_ostream &OS, const Module *) const {
309 DT.print(OS);
310 }
311
175175
176176 bool runOnFunction(Function &F) {
177177 // Get dominator information if we are being run by PassManager
178 DT = &getAnalysis>();
178 DT = &getAnalysisWrapperPass>().getDomTree();
179179
180180 Mod = F.getParent();
181181 if (!Context) Context = &F.getContext();
232232 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
233233 AU.setPreservesAll();
234234 AU.addRequiredID(PreVerifyID);
235 AU.addRequired>();
235 AU.addRequiredWrapperPass>();
236236 }
237237
238238 /// abortIfBroken - If the module is broken and we are supposed to abort on
394394 char Verifier::ID = 0;
395395 INITIALIZE_PASS_BEGIN(Verifier, "verify", "Module Verifier", false, false)
396396 INITIALIZE_PASS_DEPENDENCY(PreVerifier)
397 INITIALIZE_PASS_DEPENDENCY(DominatorTree)
397 INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
398398 INITIALIZE_PASS_END(Verifier, "verify", "Module Verifier", false, false)
399399
400400 // Assert - We know that cond should be true, if not print an error message.
9595 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
9696 AU.addRequired();
9797 AU.addPreserved();
98 AU.addRequired();
99 AU.addPreserved>();
98 AU.addRequired>();
99 AU.addPreserved();
100100 AU.addRequired();
101101 }
102102
144144
145145 INITIALIZE_PASS_BEGIN(PPCCTRLoops, "ppc-ctr-loops", "PowerPC CTR Loops",
146146 false, false)
147 INITIALIZE_PASS_DEPENDENCY(DominatorTree)
147 INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
148148 INITIALIZE_PASS_DEPENDENCY(LoopInfo)
149149 INITIALIZE_PASS_DEPENDENCY(ScalarEvolution)
150150 INITIALIZE_PASS_END(PPCCTRLoops, "ppc-ctr-loops", "PowerPC CTR Loops",
169169 bool PPCCTRLoops::runOnFunction(Function &F) {
170170 LI = &getAnalysis();
171171 SE = &getAnalysis();
172 DT = &getAnalysis>();
172 DT = &getAnalysisWrapperPass>().getDomTree();
173173 TD = getAnalysisIfAvailable();
174174 LibInfo = getAnalysisIfAvailable();
175175
9797 }
9898
9999 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
100 AU.addRequired();
101 AU.addPreserved>();
100 AU.addRequired>();
101 AU.addPreserved();
102102 FunctionPass::getAnalysisUsage(AU);
103103 }
104104
288288 /// \brief Annotate the control flow with intrinsics so the backend can
289289 /// recognize if/then/else and loops.
290290 bool SIAnnotateControlFlow::runOnFunction(Function &F) {
291 DT = &getAnalysis>();
291 DT = &getAnalysisWrapperPass>().getDomTree();
292292
293293 for (df_iterator I = df_begin(&F.getEntryBlock()),
294294 E = df_end(&F.getEntryBlock()); I != E; ++I) {
4646 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
4747 AU.addRequiredID(BreakCriticalEdgesID);
4848 AU.addRequiredID(LoopSimplifyID);
49 AU.addRequired>();
49 AU.addRequiredWrapperPass>();
5050 }
5151 };
5252 }
5656 "Extract loops into new functions", false, false)
5757 INITIALIZE_PASS_DEPENDENCY(BreakCriticalEdges)
5858 INITIALIZE_PASS_DEPENDENCY(LoopSimplify)
59 INITIALIZE_PASS_DEPENDENCY(DominatorTree)
59 INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
6060 INITIALIZE_PASS_END(LoopExtractor, "loop-extract",
6161 "Extract loops into new functions", false, false)
6262
8686 if (!L->isLoopSimplifyForm())
8787 return false;
8888
89 DominatorTree &DT = getAnalysis>();
89 DominatorTree &DT = getAnalysisWrapperPass>().getDomTree();
9090 bool Changed = false;
9191
9292 // If there is more than one top-level loop in this function, extract all of
118118
119119 // The CodeExtractor needs a dominator tree.
120120 DominatorTree DT;
121 DT.runOnFunction(*duplicateFunction);
122
121 DT.recalculate(*duplicateFunction);
122
123123 // Extract the body of the if.
124124 Function* extractedFunction
125125 = CodeExtractor(toExtract, &DT).extractCodeRegion();
9494 INITIALIZE_PASS_BEGIN(ObjCARCContract,
9595 "objc-arc-contract", "ObjC ARC contraction", false, false)
9696 INITIALIZE_AG_DEPENDENCY(AliasAnalysis)
97 INITIALIZE_PASS_DEPENDENCY(DominatorTree)
97 INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
9898 INITIALIZE_PASS_END(ObjCARCContract,
9999 "objc-arc-contract", "ObjC ARC contraction", false, false)
100100
104104
105105 void ObjCARCContract::getAnalysisUsage(AnalysisUsage &AU) const {
106106 AU.addRequired();
107 AU.addRequired>();
107 AU.addRequiredWrapperPass>();
108108 AU.setPreservesCFG();
109109 }
110110
322322
323323 Changed = false;
324324 AA = &getAnalysis();
325 DT = &getAnalysis>();
325 DT = &getAnalysisWrapperPass>().getDomTree();
326326
327327 PA.setAA(&getAnalysis());
328328
105105 const char *getPassName() const { return "CodeGen Prepare"; }
106106
107107 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
108 AU.addPreserved>();
108 AU.addPreservedWrapperPass>();
109109 AU.addRequired();
110110 }
111111
144144 ModifiedDT = false;
145145 if (TM) TLI = TM->getTargetLowering();
146146 TLInfo = &getAnalysis();
147 DT = getAnalysisIfAvailable();
147 DominatorTreeWrapperPass *DTWP =
148 getAnalysisIfAvailable();
149 DT = DTWP ? &DTWP->getDomTree() : 0;
148150 OptSize = F.getAttributes().hasAttribute(AttributeSet::FunctionIndex,
149151 Attribute::OptimizeForSize);
150152
218220 }
219221
220222 if (ModifiedDT && DT)
221 DT->DT->recalculate(F);
223 DT->recalculate(F);
222224
223225 return EverMadeChange;
224226 }
5555 virtual bool runOnFunction(Function &F) {
5656 AA = &getAnalysis();
5757 MD = &getAnalysis();
58 DT = &getAnalysis>();
58 DT = &getAnalysisWrapperPass>().getDomTree();
5959 TLI = AA->getTargetLibraryInfo();
6060
6161 bool Changed = false;
7777
7878 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
7979 AU.setPreservesCFG();
80 AU.addRequired>();
80 AU.addRequiredWrapperPass>();
8181 AU.addRequired();
8282 AU.addRequired();
8383 AU.addPreserved();
84 AU.addPreserved>();
84 AU.addPreservedWrapperPass>();
8585 AU.addPreserved();
8686 }
8787 };
8989
9090 char DSE::ID = 0;
9191 INITIALIZE_PASS_BEGIN(DSE, "dse", "Dead Store Elimination", false, false)
92 INITIALIZE_PASS_DEPENDENCY(DominatorTree)
92 INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
9393 INITIALIZE_PASS_DEPENDENCY(MemoryDependenceAnalysis)
9494 INITIALIZE_AG_DEPENDENCY(AliasAnalysis)
9595 INITIALIZE_PASS_END(DSE, "dse", "Dead Store Elimination", false, false)
376376
377377 // This transformation requires dominator postdominator info
378378 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
379 AU.addRequired>();
379 AU.addRequiredWrapperPass>();
380380 AU.addRequired();
381381 AU.setPreservesCFG();
382382 }
391391 }
392392
393393 INITIALIZE_PASS_BEGIN(EarlyCSE, "early-cse", "Early CSE", false, false)
394 INITIALIZE_PASS_DEPENDENCY(DominatorTree)
394 INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
395395 INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfo)
396396 INITIALIZE_PASS_END(EarlyCSE, "early-cse", "Early CSE", false, false)
397397
555555
556556 TD = getAnalysisIfAvailable();
557557 TLI = &getAnalysis();
558 DT = &getAnalysis>();
558 DT = &getAnalysisWrapperPass>().getDomTree();
559559
560560 // Tables that the pass uses when walking the domtree.
561561 ScopedHTType AVTable;
676676
677677 // This transformation requires dominator postdominator info
678678 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
679 AU.addRequired>();
679 AU.addRequiredWrapperPass>();
680680 AU.addRequired();
681681 if (!NoLoads)
682682 AU.addRequired();
683683 AU.addRequired();
684684
685 AU.addPreserved>();
685 AU.addPreservedWrapperPass>();
686686 AU.addPreserved();
687687 }
688688
725725
726726 INITIALIZE_PASS_BEGIN(GVN, "gvn", "Global Value Numbering", false, false)
727727 INITIALIZE_PASS_DEPENDENCY(MemoryDependenceAnalysis)
728 INITIALIZE_PASS_DEPENDENCY(DominatorTree)
728 INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
729729 INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfo)
730730 INITIALIZE_AG_DEPENDENCY(AliasAnalysis)
731731 INITIALIZE_PASS_END(GVN, "gvn", "Global Value Numbering", false, false)
23142314 bool GVN::runOnFunction(Function& F) {
23152315 if (!NoLoads)
23162316 MD = &getAnalysis();
2317 DT = &getAnalysis>();
2317 DT = &getAnalysisWrapperPass>().getDomTree();
23182318 TD = getAnalysisIfAvailable();
23192319 TLI = &getAnalysis();
23202320 VN.setAliasAnalysis(&getAnalysis());
8686 virtual bool runOnLoop(Loop *L, LPPassManager &LPM);
8787
8888 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
89 AU.addRequired>();
89 AU.addRequiredWrapperPass>();
9090 AU.addRequired();
9191 AU.addRequired();
9292 AU.addRequiredID(LoopSimplifyID);
121121 char IndVarSimplify::ID = 0;
122122 INITIALIZE_PASS_BEGIN(IndVarSimplify, "indvars",
123123 "Induction Variable Simplification", false, false)
124 INITIALIZE_PASS_DEPENDENCY(DominatorTree)
124 INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
125125 INITIALIZE_PASS_DEPENDENCY(LoopInfo)
126126 INITIALIZE_PASS_DEPENDENCY(ScalarEvolution)
127127 INITIALIZE_PASS_DEPENDENCY(LoopSimplify)
17971797
17981798 LI = &getAnalysis();
17991799 SE = &getAnalysis();
1800 DT = &getAnalysis>();
1800 DT = &getAnalysisWrapperPass>().getDomTree();
18011801 TD = getAnalysisIfAvailable();
18021802 TLI = getAnalysisIfAvailable();
18031803
8080 ///
8181 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
8282 AU.setPreservesCFG();
83 AU.addRequired>();
83 AU.addRequiredWrapperPass>();
8484 AU.addRequired();
8585 AU.addRequiredID(LoopSimplifyID);
8686 AU.addRequired();
188188
189189 char LICM::ID = 0;
190190 INITIALIZE_PASS_BEGIN(LICM, "licm", "Loop Invariant Code Motion", false, false)
191 INITIALIZE_PASS_DEPENDENCY(DominatorTree)
191 INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
192192 INITIALIZE_PASS_DEPENDENCY(LoopInfo)
193193 INITIALIZE_PASS_DEPENDENCY(LoopSimplify)
194194 INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfo)
207207 // Get our Loop and Alias Analysis information...
208208 LI = &getAnalysis();
209209 AA = &getAnalysis();
210 DT = &getAnalysis>();
210 DT = &getAnalysisWrapperPass>().getDomTree();
211211
212212 TD = getAnalysisIfAvailable();
213213 TLI = &getAnalysis();
3636 bool runOnLoop(Loop *L, LPPassManager &LPM);
3737
3838 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
39 AU.addRequired>();
39 AU.addRequiredWrapperPass>();
4040 AU.addRequired();
4141 AU.addRequired();
4242 AU.addRequiredID(LoopSimplifyID);
4343 AU.addRequiredID(LCSSAID);
4444
4545 AU.addPreserved();
46 AU.addPreserved>();
46 AU.addPreservedWrapperPass>();
4747 AU.addPreserved();
4848 AU.addPreservedID(LoopSimplifyID);
4949 AU.addPreservedID(LCSSAID);
6060 char LoopDeletion::ID = 0;
6161 INITIALIZE_PASS_BEGIN(LoopDeletion, "loop-deletion",
6262 "Delete dead loops", false, false)
63 INITIALIZE_PASS_DEPENDENCY(DominatorTree)
63 INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
6464 INITIALIZE_PASS_DEPENDENCY(LoopInfo)
6565 INITIALIZE_PASS_DEPENDENCY(ScalarEvolution)
6666 INITIALIZE_PASS_DEPENDENCY(LoopSimplify)
201201
202202 // Update the dominator tree and remove the instructions and blocks that will
203203 // be deleted from the reference counting scheme.
204 DominatorTree &DT = getAnalysis>();
204 DominatorTree &DT = getAnalysisWrapperPass>().getDomTree();
205205 SmallVector ChildNodes;
206206 for (Loop::block_iterator LI = L->block_begin(), LE = L->block_end();
207207 LI != LE; ++LI) {
174174 AU.addPreserved();
175175 AU.addRequired();
176176 AU.addPreserved();
177 AU.addPreserved();
178 AU.addRequired>();
177 AU.addPreserved>();
178 AU.addRequired();
179179 AU.addRequired();
180180 AU.addRequired();
181181 }
185185 }
186186
187187 DominatorTree *getDominatorTree() {
188 return DT ? DT : (DT=&getAnalysis());
188 return DT ? DT
189 : (DT = &getAnalysis().getDomTree());
189190 }
190191
191192 ScalarEvolution *getScalarEvolution() {
212213 INITIALIZE_PASS_BEGIN(LoopIdiomRecognize, "loop-idiom", "Recognize loop idioms",
213214 false, false)
214215 INITIALIZE_PASS_DEPENDENCY(LoopInfo)
215 INITIALIZE_PASS_DEPENDENCY(DominatorTree)
216 INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
216217 INITIALIZE_PASS_DEPENDENCY(LoopSimplify)
217218 INITIALIZE_PASS_DEPENDENCY(LCSSA)
218219 INITIALIZE_PASS_DEPENDENCY(ScalarEvolution)
5353 INITIALIZE_PASS_BEGIN(LoopInstSimplify, "loop-instsimplify",
5454 "Simplify instructions in loops", false, false)
5555 INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfo)
56 INITIALIZE_PASS_DEPENDENCY(DominatorTree)
56 INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
5757 INITIALIZE_PASS_DEPENDENCY(LoopInfo)
5858 INITIALIZE_PASS_DEPENDENCY(LCSSA)
5959 INITIALIZE_PASS_END(LoopInstSimplify, "loop-instsimplify",
6464 }
6565
6666 bool LoopInstSimplify::runOnLoop(Loop *L, LPPassManager &LPM) {
67 DominatorTree *DT = getAnalysisIfAvailable();
67 DominatorTreeWrapperPass *DTWP =
68 getAnalysisIfAvailable();
69 DominatorTree *DT = DTWP ? &DTWP->getDomTree() : 0;
6870 LoopInfo *LI = &getAnalysis();
6971 const DataLayout *TD = getAnalysisIfAvailable();
7072 const TargetLibraryInfo *TLI = &getAnalysis();
130130 AU.addRequired();
131131 AU.addRequired();
132132 AU.addPreserved();
133 AU.addRequired();
134 AU.addPreserved>();
133 AU.addRequired>();
134 AU.addPreserved();
135135 AU.addRequired();
136136 AU.addRequired();
137137 }
340340 INITIALIZE_PASS_BEGIN(LoopReroll, "loop-reroll", "Reroll loops", false, false)
341341 INITIALIZE_AG_DEPENDENCY(AliasAnalysis)
342342 INITIALIZE_PASS_DEPENDENCY(LoopInfo)
343 INITIALIZE_PASS_DEPENDENCY(DominatorTree)
343 INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
344344 INITIALIZE_PASS_DEPENDENCY(ScalarEvolution)
345345 INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfo)
346346 INITIALIZE_PASS_END(LoopReroll, "loop-reroll", "Reroll loops", false, false)
11381138 SE = &getAnalysis();
11391139 TLI = &getAnalysis();
11401140 DL = getAnalysisIfAvailable();
1141 DT = &getAnalysis>();
1141 DT = &getAnalysisWrapperPass>().getDomTree();
11421142
11431143 BasicBlock *Header = L->getHeader();
11441144 DEBUG(dbgs() << "LRR: F[" << Header->getParent()->getName() <<
4444
4545 // LCSSA form makes instruction renaming easier.
4646 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
47 AU.addPreserved>();
47 AU.addPreservedWrapperPass>();
4848 AU.addRequired();
4949 AU.addPreserved();
5050 AU.addRequiredID(LoopSimplifyID);
251251 // Nuke the Latch block.
252252 assert(Latch->empty() && "unable to evacuate Latch");
253253 LI->removeBlock(Latch);
254 if (DominatorTree *DT = getAnalysisIfAvailable())
255 DT->eraseNode(Latch);
254 if (DominatorTreeWrapperPass *DTWP =
255 getAnalysisIfAvailable())
256 DTWP->getDomTree().eraseNode(Latch);
256257 Latch->eraseFromParent();
257258 return true;
258259 }
433434 // The conditional branch can't be folded, handle the general case.
434435 // Update DominatorTree to reflect the CFG change we just made. Then split
435436 // edges as necessary to preserve LoopSimplify form.
436 if (DominatorTree *DT = getAnalysisIfAvailable()) {
437 if (DominatorTreeWrapperPass *DTWP =
438 getAnalysisIfAvailable()) {
439 DominatorTree &DT = DTWP->getDomTree();
437440 // Everything that was dominated by the old loop header is now dominated
438441 // by the original loop preheader. Conceptually the header was merged
439442 // into the preheader, even though we reuse the actual block as a new
440443 // loop latch.
441 DomTreeNode *OrigHeaderNode = DT->getNode(OrigHeader);
444 DomTreeNode *OrigHeaderNode = DT.getNode(OrigHeader);
442445 SmallVector HeaderChildren(OrigHeaderNode->begin(),
443446 OrigHeaderNode->end());
444 DomTreeNode *OrigPreheaderNode = DT->getNode(OrigPreheader);
447 DomTreeNode *OrigPreheaderNode = DT.getNode(OrigPreheader);
445448 for (unsigned I = 0, E = HeaderChildren.size(); I != E; ++I)
446 DT->changeImmediateDominator(HeaderChildren[I], OrigPreheaderNode);
447
448 assert(DT->getNode(Exit)->getIDom() == OrigPreheaderNode);
449 assert(DT->getNode(NewHeader)->getIDom() == OrigPreheaderNode);
449 DT.changeImmediateDominator(HeaderChildren[I], OrigPreheaderNode);
450
451 assert(DT.getNode(Exit)->getIDom() == OrigPreheaderNode);
452 assert(DT.getNode(NewHeader)->getIDom() == OrigPreheaderNode);
450453
451454 // Update OrigHeader to be dominated by the new header block.
452 DT->changeImmediateDominator(OrigHeader, OrigLatch);
455 DT.changeImmediateDominator(OrigHeader, OrigLatch);
453456 }
454457
455458 // Right now OrigPreHeader has two successors, NewHeader and ExitBlock, and
471474 PHBI->eraseFromParent();
472475
473476 // With our CFG finalized, update DomTree if it is available.
474 if (DominatorTree *DT = getAnalysisIfAvailable()) {
477 if (DominatorTreeWrapperPass *DTWP =
478 getAnalysisIfAvailable()) {
479 DominatorTree &DT = DTWP->getDomTree();
475480 // Update OrigHeader to be dominated by the new header block.
476 DT->changeImmediateDominator(NewHeader, OrigPreheader);
477 DT->changeImmediateDominator(OrigHeader, OrigLatch);
481 DT.changeImmediateDominator(NewHeader, OrigPreheader);
482 DT.changeImmediateDominator(OrigHeader, OrigLatch);
478483
479484 // Brute force incremental dominator tree update. Call
480485 // findNearestCommonDominator on all CFG predecessors of each child of the
481486 // original header.
482 DomTreeNode *OrigHeaderNode = DT->getNode(OrigHeader);
487 DomTreeNode *OrigHeaderNode = DT.getNode(OrigHeader);
483488 SmallVector HeaderChildren(OrigHeaderNode->begin(),
484489 OrigHeaderNode->end());
485490 bool Changed;
492497 pred_iterator PI = pred_begin(BB);
493498 BasicBlock *NearestDom = *PI;
494499 for (pred_iterator PE = pred_end(BB); PI != PE; ++PI)
495 NearestDom = DT->findNearestCommonDominator(NearestDom, *PI);
500 NearestDom = DT.findNearestCommonDominator(NearestDom, *PI);
496501
497502 // Remember if this changes the DomTree.
498503 if (Node->getIDom()->getBlock() != NearestDom) {
499 DT->changeImmediateDominator(BB, NearestDom);
504 DT.changeImmediateDominator(BB, NearestDom);
500505 Changed = true;
501506 }
502507 }
46934693
46944694 LSRInstance::LSRInstance(Loop *L, Pass *P)
46954695 : IU(P->getAnalysis()), SE(P->getAnalysis()),
4696 DT(P->getAnalysis>()), LI(P->getAnalysis()),
4696 DT(P->getAnalysisWrapperPass>().getDomTree()),
4697 LI(P->getAnalysis()),
46974698 TTI(P->getAnalysis()), L(L), Changed(false),
46984699 IVIncInsertPos(0) {
46994700 // If LoopSimplify form is not available, stay out of trouble.
48724873 INITIALIZE_PASS_BEGIN(LoopStrengthReduce, "loop-reduce",
48734874 "Loop Strength Reduction", false, false)
48744875 INITIALIZE_AG_DEPENDENCY(TargetTransformInfo)
4875 INITIALIZE_PASS_DEPENDENCY(DominatorTree)
4876 INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
48764877 INITIALIZE_PASS_DEPENDENCY(ScalarEvolution)
48774878 INITIALIZE_PASS_DEPENDENCY(IVUsers)
48784879 INITIALIZE_PASS_DEPENDENCY(LoopInfo)
48974898 AU.addRequired();
48984899 AU.addPreserved();
48994900 AU.addRequiredID(LoopSimplifyID);
4900 AU.addRequired();
4901 AU.addPreserved>();
4901 AU.addRequired>();
4902 AU.addPreserved();
49024903 AU.addRequired();
49034904 AU.addPreserved();
49044905 // Requiring LoopSimplify a second time here prevents IVUsers from running
49234924 #ifndef NDEBUG
49244925 Rewriter.setDebugType(DEBUG_TYPE);
49254926 #endif
4926 unsigned numFolded =
4927 Rewriter.replaceCongruentIVs(L, &getAnalysis(),
4928 DeadInsts,
4929 &getAnalysis());
4927 unsigned numFolded = Rewriter.replaceCongruentIVs(
4928 L, &getAnalysis().getDomTree(), DeadInsts,
4929 &getAnalysis());
49304930 if (numFolded) {
49314931 Changed = true;
49324932 DeleteTriviallyDeadInstructions(DeadInsts);
105105 // If loop unroll does not preserve dom info then LCSSA pass on next
106106 // loop will receive invalid dom info.
107107 // For now, recreate dom info, if loop is unrolled.
108 AU.addPreserved>();
108 AU.addPreservedWrapperPass>();
109109 }
110110 };
111111 }
168168 AU.addPreserved();
169169 AU.addRequiredID(LCSSAID);
170170 AU.addPreservedID(LCSSAID);
171 AU.addPreserved>();
171 AU.addPreservedWrapperPass>();
172172 AU.addPreserved();
173173 AU.addRequired();
174174 }
383383 bool LoopUnswitch::runOnLoop(Loop *L, LPPassManager &LPM_Ref) {
384384 LI = &getAnalysis();
385385 LPM = &LPM_Ref;
386 DT = getAnalysisIfAvailable();
386 DominatorTreeWrapperPass *DTWP =
387 getAnalysisIfAvailable();
388 DT = DTWP ? &DTWP->getDomTree() : 0;
387389 currentLoop = L;
388390 Function *F = currentLoop->getHeader()->getParent();
389391 bool Changed = false;
396398 if (Changed) {
397399 // FIXME: Reconstruct dom info, because it is not preserved properly.
398400 if (DT)
399 DT->runOnFunction(*F);
401 DT->recalculate(*F);
400402 }
401403 return Changed;
402404 }
320320 // This transformation requires dominator postdominator info
321321 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
322322 AU.setPreservesCFG();
323 AU.addRequired>();
323 AU.addRequiredWrapperPass>();
324324 AU.addRequired();
325325 AU.addRequired();
326326 AU.addRequired();
352352
353353 INITIALIZE_PASS_BEGIN(MemCpyOpt, "memcpyopt", "MemCpy Optimization",
354354 false, false)
355 INITIALIZE_PASS_DEPENDENCY(DominatorTree)
355 INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
356356 INITIALIZE_PASS_DEPENDENCY(MemoryDependenceAnalysis)
357357 INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfo)
358358 INITIALIZE_AG_DEPENDENCY(AliasAnalysis)
679679
680680 // Since we're changing the parameter to the callsite, we need to make sure
681681 // that what would be the new parameter dominates the callsite.
682 DominatorTree &DT = getAnalysis>();
682 DominatorTree &DT = getAnalysisWrapperPass>().getDomTree();
683683 if (Instruction *cpyDestInst = dyn_cast(cpyDest))
684684 if (!DT.dominates(cpyDestInst, C))
685685 return false;
929929
930930 INITIALIZE_PASS_BEGIN(SROA, "sroa", "Scalar Replacement Of Aggregates",
931931 false, false)
932 INITIALIZE_PASS_DEPENDENCY(DominatorTree)
932 INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
933933 INITIALIZE_PASS_END(SROA, "sroa", "Scalar Replacement Of Aggregates",
934934 false, false)
935935
35443544 DEBUG(dbgs() << " Skipping SROA -- no target data!\n");
35453545 return false;
35463546 }
3547 DT = getAnalysisIfAvailable();
3547 DominatorTreeWrapperPass *DTWP =
3548 getAnalysisIfAvailable();
3549 DT = DTWP ? &DTWP->getDomTree() : 0;
35483550
35493551 BasicBlock &EntryBB = F.getEntryBlock();
35503552 for (BasicBlock::iterator I = EntryBB.begin(), E = llvm::prior(EntryBB.end());
35863588
35873589 void SROA::getAnalysisUsage(AnalysisUsage &AU) const {
35883590 if (RequiresDomTree)
3589 AU.addRequired>();
3591 AU.addRequiredWrapperPass>();
35903592 AU.setPreservesCFG();
35913593 }
253253 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
254254 AU.setPreservesCFG();
255255 AU.addRequired();
256 AU.addRequired>();
256 AU.addRequiredWrapperPass>();
257257 AU.addRequired();
258258 }
259259
627627 // If all those conditions hold, BB2's equivalence class is BB1.
628628 DominatedBBs.clear();
629629 PDT->getDescendants(BB1, DominatedBBs);
630 findEquivalencesFor(BB1, DominatedBBs, DT->DT);
630 findEquivalencesFor(BB1, DominatedBBs, DT);
631631
632632 DEBUG(printBlockEquivalence(dbgs(), BB1));
633633 }
987987 char SampleProfileLoader::ID = 0;
988988 INITIALIZE_PASS_BEGIN(SampleProfileLoader, "sample-profile",
989989 "Sample Profile loader", false, false)
990 INITIALIZE_PASS_DEPENDENCY(DominatorTree)
990 INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
991991 INITIALIZE_PASS_DEPENDENCY(PostDominatorTree)
992992 INITIALIZE_PASS_DEPENDENCY(LoopInfo)
993993 INITIALIZE_PASS_END(SampleProfileLoader, "sample-profile",
10081008 }
10091009
10101010 bool SampleProfileLoader::runOnFunction(Function &F) {
1011 DominatorTree *DT = &getAnalysis>();
1011 DominatorTree *DT = &getAnalysisWrapperPass>().getDomTree();
10121012 PostDominatorTree *PDT = &getAnalysis();
10131013 LoopInfo *LI = &getAnalysis();
10141014 SampleFunctionProfile &FunctionProfile = Profiler->getProfile(F);
195195 // getAnalysisUsage - This pass does not require any passes, but we know it
196196 // will not alter the CFG, so say so.
197197 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
198 AU.addRequired>();
198 AU.addRequiredWrapperPass>();
199199 AU.setPreservesCFG();
200200 }
201201 };
223223
224224 INITIALIZE_PASS_BEGIN(SROA_DT, "scalarrepl",
225225 "Scalar Replacement of Aggregates (DT)", false, false)
226 INITIALIZE_PASS_DEPENDENCY(DominatorTree)
226 INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
227227 INITIALIZE_PASS_END(SROA_DT, "scalarrepl",
228228 "Scalar Replacement of Aggregates (DT)", false, false)
229229
14061406 std::vector Allocas;
14071407 DominatorTree *DT = 0;
14081408 if (HasDomTree)
1409 DT = &getAnalysis>();
1409 DT = &getAnalysisWrapperPass>().getDomTree();
14101410
14111411 BasicBlock &BB = F.getEntryBlock(); // Get the entry node for the function
14121412 DIBuilder DIB(*F.getParent());
4545 AU.setPreservesCFG();
4646 FunctionPass::getAnalysisUsage(AU);
4747 AU.addRequired();
48 AU.addRequired>();
48 AU.addRequiredWrapperPass>();
4949 AU.addRequired();
50 AU.addPreserved>();
50 AU.addPreservedWrapperPass>();
5151 AU.addPreserved();
5252 }
5353 private:
6161 char Sinking::ID = 0;
6262 INITIALIZE_PASS_BEGIN(Sinking, "sink", "Code sinking", false, false)
6363 INITIALIZE_PASS_DEPENDENCY(LoopInfo)
64 INITIALIZE_PASS_DEPENDENCY(DominatorTree)
64 INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
6565 INITIALIZE_AG_DEPENDENCY(AliasAnalysis)
6666 INITIALIZE_PASS_END(Sinking, "sink", "Code sinking", false, false)
6767
9494 }
9595
9696 bool Sinking::runOnFunction(Function &F) {
97 DT = &getAnalysis>();
97 DT = &getAnalysisWrapperPass>().getDomTree();
9898 LI = &getAnalysis();
9999 AA = &getAnalysis();
100100
244244
245245 void getAnalysisUsage(AnalysisUsage &AU) const {
246246 AU.addRequiredID(LowerSwitchID);
247 AU.addRequired();
248 AU.addPreserved>();
247 AU.addRequired>();
248 AU.addPreserved();
249249 RegionPass::getAnalysisUsage(AU);
250250 }
251251 };
257257 INITIALIZE_PASS_BEGIN(StructurizeCFG, "structurizecfg", "Structurize the CFG",
258258 false, false)
259259 INITIALIZE_PASS_DEPENDENCY(LowerSwitch)
260 INITIALIZE_PASS_DEPENDENCY(DominatorTree)
260 INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
261261 INITIALIZE_PASS_DEPENDENCY(RegionInfo)
262262 INITIALIZE_PASS_END(StructurizeCFG, "structurizecfg", "Structurize the CFG",
263263 false, false)
875875 Func = R->getEntry()->getParent();
876876 ParentRegion = R;
877877
878 DT = &getAnalysis>();
878 DT = &getAnalysisWrapperPass>().getDomTree();
879879
880880 orderNodes();
881881 collectInfos();
166166
167167 // Finally, erase the old block and update dominator info.
168168 if (P) {
169 if (DominatorTree *DT = P->getAnalysisIfAvailable()) {
170 if (DomTreeNode *DTN = DT->getNode(BB)) {
171 DomTreeNode *PredDTN = DT->getNode(PredBB);
169 if (DominatorTreeWrapperPass *DTWP =
170 P->getAnalysisIfAvailable()) {
171 DominatorTree &DT = DTWP->getDomTree();
172 if (DomTreeNode *DTN = DT.getNode(BB)) {
173 DomTreeNode *PredDTN = DT.getNode(PredBB);
172174 SmallVector Children(DTN->begin(), DTN->end());
173175 for (SmallVectorImpl::iterator DI = Children.begin(),
174176 DE = Children.end(); DI != DE; ++DI)
175 DT->changeImmediateDominator(*DI, PredDTN);
176
177 DT->eraseNode(BB);
177 DT.changeImmediateDominator(*DI, PredDTN);
178
179 DT.eraseNode(BB);
178180 }
179181
180182 if (LoopInfo *LI = P->getAnalysisIfAvailable())
279281 if (Loop *L = LI->getLoopFor(Old))
280282 L->addBasicBlockToLoop(New, LI->getBase());
281283
282 if (DominatorTree *DT = P->getAnalysisIfAvailable()) {
284 if (DominatorTreeWrapperPass *DTWP =
285 P->getAnalysisIfAvailable()) {
286 DominatorTree &DT = DTWP->getDomTree();
283287 // Old dominates New. New node dominates all other nodes dominated by Old.
284 if (DomTreeNode *OldNode = DT->getNode(Old)) {
288 if (DomTreeNode *OldNode = DT.getNode(Old)) {
285289 std::vector Children;
286290 for (DomTreeNode::iterator I = OldNode->begin(), E = OldNode->end();
287291 I != E; ++I)
288292 Children.push_back(*I);
289293
290 DomTreeNode *NewNode = DT->addNewBlock(New,Old);
294 DomTreeNode *NewNode = DT.addNewBlock(New, Old);
291295 for (std::vector::iterator I = Children.begin(),
292296 E = Children.end(); I != E; ++I)
293 DT->changeImmediateDominator(*I, NewNode);
297 DT.changeImmediateDominator(*I, NewNode);
294298 }
295299 }
296300
335339 }
336340
337341 // Update dominator tree if available.
338 DominatorTree *DT = P->getAnalysisIfAvailable();
339 if (DT)
340 DT->splitBlock(NewBB);
342 if (DominatorTreeWrapperPass *DTWP =
343 P->getAnalysisIfAvailable())
344 DTWP->getDomTree().splitBlock(NewBB);
341345
342346 if (!L) return;
343347
4141 virtual bool runOnFunction(Function &F);
4242
4343 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
44 AU.addPreserved>();
44 AU.addPreservedWrapperPass>();
4545 AU.addPreserved();
4646
4747 // No loop canonicalization guarantees are broken by this pass.
208208 // If we don't have a pass object, we can't update anything...
209209 if (P == 0) return NewBB;
210210
211 DominatorTree *DT = P->getAnalysisIfAvailable();
211 DominatorTreeWrapperPass *DTWP =
212 P->getAnalysisIfAvailable();
213 DominatorTree *DT = DTWP ? &DTWP->getDomTree() : 0;
212214 LoopInfo *LI = P->getAnalysisIfAvailable();
213215
214216 // If we have nothing to update, just return.
6666 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
6767 AU.setPreservesCFG();
6868
69 AU.addRequired>();
69 AU.addRequiredWrapperPass>();
7070 AU.addRequired();
7171 AU.addPreservedID(LoopSimplifyID);
7272 AU.addPreserved();
8585
8686 char LCSSA::ID = 0;
8787 INITIALIZE_PASS_BEGIN(LCSSA, "lcssa", "Loop-Closed SSA Form Pass", false, false)
88 INITIALIZE_PASS_DEPENDENCY(DominatorTree)
88 INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
8989 INITIALIZE_PASS_DEPENDENCY(LoopInfo)
9090 INITIALIZE_PASS_END(LCSSA, "lcssa", "Loop-Closed SSA Form Pass", false, false)
9191
110110 /// runOnFunction - Process all loops in the function, inner-most out.
111111 bool LCSSA::runOnLoop(Loop *TheLoop, LPPassManager &LPM) {
112112 L = TheLoop;
113
114 DT = &getAnalysis();
113
114 DT = &getAnalysis().getDomTree();
115115 LI = &getAnalysis();
116116 SE = getAnalysisIfAvailable();
117117
507507 DestBB->getInstList().splice(DestBB->begin(), PredBB->getInstList());
508508
509509 if (P) {
510 DominatorTree *DT = P->getAnalysisIfAvailable();
511 if (DT) {
512 BasicBlock *PredBBIDom = DT->getNode(PredBB)->getIDom()->getBlock();
513 DT->changeImmediateDominator(DestBB, PredBBIDom);
514 DT->eraseNode(PredBB);
510 if (DominatorTreeWrapperPass *DTWP =
511 P->getAnalysisIfAvailable()) {
512 DominatorTree &DT = DTWP->getDomTree();
513 BasicBlock *PredBBIDom = DT.getNode(PredBB)->getIDom()->getBlock();
514 DT.changeImmediateDominator(DestBB, PredBBIDom);
515 DT.eraseNode(PredBB);
515516 }
516517 }
517518 // Nuke BB.
8282
8383 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
8484 // We need loop information to identify the loops...
85 AU.addRequired();
86 AU.addPreserved>();
85 AU.addRequired>();
86 AU.addPreserved();
8787
8888 AU.addRequired();
8989 AU.addPreserved();
113113 char LoopSimplify::ID = 0;
114114 INITIALIZE_PASS_BEGIN(LoopSimplify, "loop-simplify",
115115 "Canonicalize natural loops", true, false)
116 INITIALIZE_PASS_DEPENDENCY(DominatorTree)
116 INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
117117 INITIALIZE_PASS_DEPENDENCY(LoopInfo)
118118 INITIALIZE_PASS_END(LoopSimplify, "loop-simplify",
119119 "Canonicalize natural loops", true, false)
130130 bool Changed = false;
131131 LI = &getAnalysis();
132132 AA = getAnalysisIfAvailable();
133 DT = &getAnalysis>();
133 DT = &getAnalysisWrapperPass>().getDomTree();
134134 SE = getAnalysisIfAvailable();
135135
136136 Changed |= ProcessLoop(L, LPM);
412412 if (LPM) {
413413 // FIXME: Reconstruct dom info, because it is not preserved properly.
414414 // Incrementally updating domtree after loop unrolling would be easy.
415 if (DominatorTree *DT = LPM->getAnalysisIfAvailable())
416 DT->runOnFunction(*L->getHeader()->getParent());
415 if (DominatorTreeWrapperPass *DTWP =
416 LPM->getAnalysisIfAvailable())
417 DTWP->getDomTree().recalculate(*L->getHeader()->getParent());
417418
418419 // Simplify any new induction variables in the partially unrolled loop.
419420 ScalarEvolution *SE = LPM->getAnalysisIfAvailable();
3636 virtual bool runOnFunction(Function &F);
3737
3838 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
39 AU.addRequired>();
39 AU.addRequiredWrapperPass>();
4040 AU.setPreservesCFG();
4141 // This is a cluster of orthogonal Transforms
4242 AU.addPreserved();
4949 char PromotePass::ID = 0;
5050 INITIALIZE_PASS_BEGIN(PromotePass, "mem2reg", "Promote Memory to Register",
5151 false, false)
52 INITIALIZE_PASS_DEPENDENCY(DominatorTree)
52 INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
5353 INITIALIZE_PASS_END(PromotePass, "mem2reg", "Promote Memory to Register",
5454 false, false)
5555
6060
6161 bool Changed = false;
6262
63 DominatorTree &DT = getAnalysis>();
63 DominatorTree &DT = getAnalysisWrapperPass>().getDomTree();
6464
6565 while (1) {
6666 Allocas.clear();
4444
4545 /// runOnFunction - Remove instructions that simplify.
4646 bool runOnFunction(Function &F) {
47 const DominatorTree *DT = getAnalysisIfAvailable();
47 const DominatorTreeWrapperPass *DTWP =
48 getAnalysisIfAvailable();
49 const DominatorTree *DT = DTWP ? &DTWP->getDomTree() : 0;
4850 const DataLayout *TD = getAnalysisIfAvailable();
4951 const TargetLibraryInfo *TLI = &getAnalysis();
5052 SmallPtrSet S1, S2, *ToSimplify = &S1, *Next = &S2;
198198 BBVectorize(Pass *P, const VectorizeConfig &C)
199199 : BasicBlockPass(ID), Config(C) {
200200 AA = &P->getAnalysis();
201 DT = &P->getAnalysis>();
201 DT = &P->getAnalysisWrapperPass>().getDomTree();
202202 SE = &P->getAnalysis();
203203 TD = P->getAnalysisIfAvailable();
204204 TTI = IgnoreTargetInfo ? 0 : &P->getAnalysis();
429429
430430 virtual bool runOnBasicBlock(BasicBlock &BB) {
431431 AA = &getAnalysis();
432 DT = &getAnalysis>();
432 DT = &getAnalysisWrapperPass>().getDomTree();
433433 SE = &getAnalysis();
434434 TD = getAnalysisIfAvailable();
435435 TTI = IgnoreTargetInfo ? 0 : &getAnalysis();
440440 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
441441 BasicBlockPass::getAnalysisUsage(AU);
442442 AU.addRequired();
443 AU.addRequired>();
443 AU.addRequiredWrapperPass>();
444444 AU.addRequired();
445445 AU.addRequired();
446446 AU.addPreserved();
447 AU.addPreserved>();
447 AU.addPreservedWrapperPass>();
448448 AU.addPreserved();
449449 AU.setPreservesCFG();
450450 }
31403140 INITIALIZE_PASS_BEGIN(BBVectorize, BBV_NAME, bb_vectorize_name, false, false)
31413141 INITIALIZE_AG_DEPENDENCY(AliasAnalysis)
31423142 INITIALIZE_AG_DEPENDENCY(TargetTransformInfo)
3143 INITIALIZE_PASS_DEPENDENCY(DominatorTree)
3143 INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
31443144 INITIALIZE_PASS_DEPENDENCY(ScalarEvolution)
31453145 INITIALIZE_PASS_END(BBVectorize, BBV_NAME, bb_vectorize_name, false, false)
31463146
959959 DL = getAnalysisIfAvailable();
960960 LI = &getAnalysis();
961961 TTI = &getAnalysis();
962 DT = &getAnalysis>();
962 DT = &getAnalysisWrapperPass>().getDomTree();
963963 TLI = getAnalysisIfAvailable();
964964
965965 // If the target claims to have no vector registers don't attempt
10541054 LoopPass::getAnalysisUsage(AU);
10551055 AU.addRequiredID(LoopSimplifyID);
10561056 AU.addRequiredID(LCSSAID);
1057 AU.addRequired>();
1057 AU.addRequiredWrapperPass>();
10581058 AU.addRequired();
10591059 AU.addRequired();
10601060 AU.addRequired();
10611061 AU.addPreserved();
1062 AU.addPreserved>();
1062 AU.addPreservedWrapperPass>();
10631063 }
10641064
10651065 };
29752975 DT->changeImmediateDominator(LoopScalarBody, LoopScalarPreHeader);
29762976 DT->changeImmediateDominator(LoopExitBlock, LoopMiddleBlock);
29772977
2978 DEBUG(DT->verifyAnalysis());
2978 DEBUG(DT->verifyDomTree());
29792979 }
29802980
29812981 /// \brief Check whether it is safe to if-convert this phi node.
53895389 static const char lv_name[] = "Loop Vectorization";
53905390 INITIALIZE_PASS_BEGIN(LoopVectorize, LV_NAME, lv_name, false, false)
53915391 INITIALIZE_AG_DEPENDENCY(TargetTransformInfo)
5392 INITIALIZE_PASS_DEPENDENCY(DominatorTree)
5392 INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
53935393 INITIALIZE_PASS_DEPENDENCY(ScalarEvolution)
53945394 INITIALIZE_PASS_DEPENDENCY(LCSSA)
53955395 INITIALIZE_PASS_DEPENDENCY(LoopInfo)
17751775 TTI = &getAnalysis();
17761776 AA = &getAnalysis();
17771777 LI = &getAnalysis();
1778 DT = &getAnalysis>();
1778 DT = &getAnalysisWrapperPass>().getDomTree();
17791779
17801780 StoreRefs.clear();
17811781 bool Changed = false;
18301830 AU.addRequired();
18311831 AU.addRequired();
18321832 AU.addRequired();
1833 AU.addRequired>();
1833 AU.addRequiredWrapperPass>();
18341834 AU.addPreserved();
1835 AU.addPreserved>();
1835 AU.addPreservedWrapperPass>();
18361836 AU.setPreservesCFG();
18371837 }
18381838
3030
3131 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
3232 AU.setPreservesAll();
33 AU.addRequired();
34
33 AU.addRequired();
3534 }
3635
3736 virtual bool runOnFunction(Function &F) {
38 getAnalysis>().dump();
37 getAnalysisWrapperPass>().dump();
3938 return false;
4039 }
4140 };
7777 "", &ID, 0, true, true);
7878 PassRegistry::getPassRegistry()->registerPass(*PI, false);
7979 initializeLoopInfoPass(*PassRegistry::getPassRegistry());
80 initializeDominatorTreePass(*PassRegistry::getPassRegistry());
80 initializeDominatorTreeWrapperPassPass(
81 *PassRegistry::getPassRegistry());
8182 return 0;
8283 }
8384
8485 void getAnalysisUsage(AnalysisUsage &AU) const {
8586 AU.setPreservesAll();
8687 AU.addRequired();
87 AU.addRequired>();
88 AU.addRequiredWrapperPass>();
8889 }
8990
9091 bool runOnFunction(Function &F) {
9293 return false;
9394
9495 LoopInfo *LI = &getAnalysis();
95 DominatorTree *DT = &getAnalysis();
96 DominatorTree *DT =
97 &getAnalysis().getDomTree();
9698 EXPECT_EQ(isPotentiallyReachable(A, B, 0, 0), ExpectedResult);
9799 EXPECT_EQ(isPotentiallyReachable(A, B, DT, 0), ExpectedResult);
98100 EXPECT_EQ(isPotentiallyReachable(A, B, 0, LI), ExpectedResult);
2525 struct DPass : public FunctionPass {
2626 static char ID;
2727 virtual bool runOnFunction(Function &F) {
28 DominatorTree *DT = &getAnalysis();
28 DominatorTree *DT =
29 &getAnalysis().getDomTree();
2930 PostDominatorTree *PDT = &getAnalysis();
3031 Function::iterator FI = F.begin();
3132
175176 return false;
176177 }
177178 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
178 AU.addRequired>();
179 AU.addRequiredWrapperPass>();
179180 AU.addRequired();
180181 }
181182 DPass() : FunctionPass(ID) {
225226 }
226227
227228 INITIALIZE_PASS_BEGIN(DPass, "dpass", "dpass", false, false)
228 INITIALIZE_PASS_DEPENDENCY(DominatorTree)
229 INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
229230 INITIALIZE_PASS_DEPENDENCY(PostDominatorTree)
230231 INITIALIZE_PASS_END(DPass, "dpass", "dpass", false, false)