llvm.org GIT mirror llvm / eca46e6
[LPM] Factor all of the loop analysis usage updates into a common helper routine. We were getting this wrong in small ways and generally being very inconsistent about it across loop passes. Instead, let's have a common place where we do this. One minor downside is that this will require some analyses like SCEV in more places than they are strictly needed. However, this seems benign as these analyses are complete no-ops, and without this consistency we can in many cases end up with the legacy pass manager scheduling deciding to split up a loop pass pipeline in order to run the function analysis half-way through. It is very, very annoying to fix these without just being very pedantic across the board. The only loop passes I've not updated here are ones that use AU.setPreservesAll() such as IVUsers (an analysis) and the pass printer. They seemed less relevant. With this patch, almost all of the problems in PR24804 around loop pass pipelines are fixed. The one remaining issue is that we run simplify-cfg and instcombine in the middle of the loop pass pipeline. We've recently added some loop variants of these passes that would seem substantially cleaner to use, but this at least gets us much closer to the previous state. Notably, the seven loop pass managers is down to three. I've not updated the loop passes using LoopAccessAnalysis because that analysis hasn't been fully wired into LoopSimplify/LCSSA, and it isn't clear that those transforms want to support those forms anyways. They all run late anyways, so this is harmless. Similarly, LSR is left alone because it already carefully manages its forms and doesn't need to get fused into a single loop pass manager with a bunch of other loop passes. LoopReroll didn't use loop simplified form previously, and I've updated the test case to match the trivially different output. Finally, I've also factored all the pass initialization for the passes that use this technique as well, so that should be done regularly and reliably. Thanks to James for the help reviewing and thinking about this stuff, and Ben for help thinking about it as well! Differential Revision: http://reviews.llvm.org/D17435 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@261316 91177308-0d34-0410-b5e6-96231b3b80d8 Chandler Carruth 3 years ago
16 changed file(s) with 109 addition(s) and 188 deletion(s). Raw diff Collapse all Expand all
162162 void initializeLiveVariablesPass(PassRegistry&);
163163 void initializeLoaderPassPass(PassRegistry&);
164164 void initializeLocalStackSlotPassPass(PassRegistry&);
165 void initializeLoopPassPass(PassRegistry&);
165166 void initializeLoopDeletionPass(PassRegistry&);
166167 void initializeLoopExtractorPass(PassRegistry&);
167168 void initializeLoopInfoWrapperPassPass(PassRegistry&);
384384 /// \brief Set input string into loop metadata by keeping other values intact.
385385 void addStringMetadataToLoop(Loop *TheLoop, const char *MDString,
386386 unsigned V = 0);
387
388 /// Helper to consistently add the set of standard passes to a loop pass's \c
389 /// AnalysisUsage.
390 ///
391 /// All loop passes should call this as part of implementing their \c
392 /// getAnalysisUsage.
393 void getLoopAnalysisUsage(AnalysisUsage &AU);
394
387395 }
388396
389397 #endif
106106 bool runOnLoop(Loop *L, LPPassManager &LPM) override;
107107
108108 void getAnalysisUsage(AnalysisUsage &AU) const override {
109 AU.addRequired();
110 AU.addRequired();
111 AU.addRequired();
112 AU.addRequiredID(LoopSimplifyID);
113 AU.addRequiredID(LCSSAID);
114 AU.addPreserved();
115 AU.addPreserved();
116 AU.addPreservedID(LoopSimplifyID);
117 AU.addPreservedID(LCSSAID);
118109 AU.setPreservesCFG();
110 getLoopAnalysisUsage(AU);
119111 }
120112
121113 private:
147139 char IndVarSimplify::ID = 0;
148140 INITIALIZE_PASS_BEGIN(IndVarSimplify, "indvars",
149141 "Induction Variable Simplification", false, false)
150 INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
151 INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass)
152 INITIALIZE_PASS_DEPENDENCY(ScalarEvolutionWrapperPass)
153 INITIALIZE_PASS_DEPENDENCY(LoopSimplify)
154 INITIALIZE_PASS_DEPENDENCY(LCSSA)
142 INITIALIZE_PASS_DEPENDENCY(LoopPass)
155143 INITIALIZE_PASS_END(IndVarSimplify, "indvars",
156144 "Induction Variable Simplification", false, false)
157145
210210 }
211211
212212 void getAnalysisUsage(AnalysisUsage &AU) const override {
213 AU.addRequired();
214 AU.addRequiredID(LoopSimplifyID);
215 AU.addRequiredID(LCSSAID);
216 AU.addRequired();
217213 AU.addRequired();
214 getLoopAnalysisUsage(AU);
218215 }
219216
220217 bool runOnLoop(Loop *L, LPPassManager &LPM) override;
225222
226223 INITIALIZE_PASS_BEGIN(InductiveRangeCheckElimination, "irce",
227224 "Inductive range check elimination", false, false)
228 INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass)
229 INITIALIZE_PASS_DEPENDENCY(LoopSimplify)
230 INITIALIZE_PASS_DEPENDENCY(LCSSA)
231 INITIALIZE_PASS_DEPENDENCY(ScalarEvolutionWrapperPass)
232225 INITIALIZE_PASS_DEPENDENCY(BranchProbabilityInfoWrapperPass)
226 INITIALIZE_PASS_DEPENDENCY(LoopPass)
233227 INITIALIZE_PASS_END(InductiveRangeCheckElimination, "irce",
234228 "Inductive range check elimination", false, false)
235229
117117 ///
118118 void getAnalysisUsage(AnalysisUsage &AU) const override {
119119 AU.setPreservesCFG();
120 AU.addRequired();
121 AU.addRequired();
122 AU.addRequiredID(LoopSimplifyID);
123 AU.addPreservedID(LoopSimplifyID);
124 AU.addRequiredID(LCSSAID);
125 AU.addPreservedID(LCSSAID);
126 AU.addRequired();
127 AU.addPreserved();
128 AU.addPreserved();
129 AU.addPreserved();
130 AU.addPreserved();
131 AU.addPreserved();
132120 AU.addRequired();
121 getLoopAnalysisUsage(AU);
133122 }
134123
135124 using llvm::Pass::doFinalization;
173162
174163 char LICM::ID = 0;
175164 INITIALIZE_PASS_BEGIN(LICM, "licm", "Loop Invariant Code Motion", false, false)
176 INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
177 INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass)
178 INITIALIZE_PASS_DEPENDENCY(LoopSimplify)
179 INITIALIZE_PASS_DEPENDENCY(LCSSA)
180 INITIALIZE_PASS_DEPENDENCY(ScalarEvolutionWrapperPass)
165 INITIALIZE_PASS_DEPENDENCY(LoopPass)
181166 INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfoWrapperPass)
182 INITIALIZE_PASS_DEPENDENCY(BasicAAWrapperPass)
183 INITIALIZE_PASS_DEPENDENCY(AAResultsWrapperPass)
184 INITIALIZE_PASS_DEPENDENCY(GlobalsAAWrapperPass)
185 INITIALIZE_PASS_DEPENDENCY(SCEVAAWrapperPass)
186167 INITIALIZE_PASS_END(LICM, "licm", "Loop Invariant Code Motion", false, false)
187168
188169 Pass *llvm::createLICMPass() { return new LICM(); }
2020 #include "llvm/Analysis/LoopPass.h"
2121 #include "llvm/Analysis/ScalarEvolution.h"
2222 #include "llvm/IR/Dominators.h"
23 #include "llvm/Transforms/Utils/LoopUtils.h"
2324 using namespace llvm;
2425
2526 #define DEBUG_TYPE "loop-delete"
3839 bool runOnLoop(Loop *L, LPPassManager &) override;
3940
4041 void getAnalysisUsage(AnalysisUsage &AU) const override {
41 AU.addRequired();
42 AU.addRequired();
43 AU.addRequired();
44 AU.addRequiredID(LoopSimplifyID);
45 AU.addRequiredID(LCSSAID);
46
47 AU.addPreserved();
48 AU.addPreserved();
49 AU.addPreserved();
50 AU.addPreserved();
51 AU.addPreservedID(LoopSimplifyID);
52 AU.addPreservedID(LCSSAID);
42 getLoopAnalysisUsage(AU);
5343 }
5444
5545 private:
6353 char LoopDeletion::ID = 0;
6454 INITIALIZE_PASS_BEGIN(LoopDeletion, "loop-deletion",
6555 "Delete dead loops", false, false)
66 INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
67 INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass)
68 INITIALIZE_PASS_DEPENDENCY(ScalarEvolutionWrapperPass)
69 INITIALIZE_PASS_DEPENDENCY(LoopSimplify)
70 INITIALIZE_PASS_DEPENDENCY(LCSSA)
56 INITIALIZE_PASS_DEPENDENCY(LoopPass)
7157 INITIALIZE_PASS_END(LoopDeletion, "loop-deletion",
7258 "Delete dead loops", false, false)
7359
5353 #include "llvm/Support/Debug.h"
5454 #include "llvm/Support/raw_ostream.h"
5555 #include "llvm/Transforms/Utils/Local.h"
56 #include "llvm/Transforms/Utils/LoopUtils.h"
5657 using namespace llvm;
5758
5859 #define DEBUG_TYPE "loop-idiom"
8485 /// loop preheaders be inserted into the CFG.
8586 ///
8687 void getAnalysisUsage(AnalysisUsage &AU) const override {
87 AU.addRequired();
88 AU.addPreserved();
89 AU.addRequiredID(LoopSimplifyID);
90 AU.addPreservedID(LoopSimplifyID);
91 AU.addRequiredID(LCSSAID);
92 AU.addPreservedID(LCSSAID);
93 AU.addRequired();
94 AU.addPreserved();
95 AU.addRequired();
96 AU.addPreserved();
97 AU.addPreserved();
98 AU.addRequired();
99 AU.addPreserved();
10088 AU.addRequired();
10189 AU.addRequired();
102 AU.addPreserved();
103 AU.addPreserved();
90 getLoopAnalysisUsage(AU);
10491 }
10592
10693 private:
153140 char LoopIdiomRecognize::ID = 0;
154141 INITIALIZE_PASS_BEGIN(LoopIdiomRecognize, "loop-idiom", "Recognize loop idioms",
155142 false, false)
156 INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass)
157 INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
158 INITIALIZE_PASS_DEPENDENCY(LoopSimplify)
159 INITIALIZE_PASS_DEPENDENCY(LCSSA)
160 INITIALIZE_PASS_DEPENDENCY(ScalarEvolutionWrapperPass)
143 INITIALIZE_PASS_DEPENDENCY(LoopPass)
161144 INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfoWrapperPass)
162 INITIALIZE_PASS_DEPENDENCY(BasicAAWrapperPass)
163 INITIALIZE_PASS_DEPENDENCY(AAResultsWrapperPass)
164 INITIALIZE_PASS_DEPENDENCY(GlobalsAAWrapperPass)
165 INITIALIZE_PASS_DEPENDENCY(SCEVAAWrapperPass)
166145 INITIALIZE_PASS_DEPENDENCY(TargetTransformInfoWrapperPass)
167146 INITIALIZE_PASS_END(LoopIdiomRecognize, "loop-idiom", "Recognize loop idioms",
168147 false, false)
2424 #include "llvm/Support/Debug.h"
2525 #include "llvm/Analysis/TargetLibraryInfo.h"
2626 #include "llvm/Transforms/Utils/Local.h"
27 #include "llvm/Transforms/Utils/LoopUtils.h"
2728 using namespace llvm;
2829
2930 #define DEBUG_TYPE "loop-instsimplify"
4142 bool runOnLoop(Loop*, LPPassManager&) override;
4243
4344 void getAnalysisUsage(AnalysisUsage &AU) const override {
45 AU.addRequired();
46 AU.addRequired();
4447 AU.setPreservesCFG();
45 AU.addRequired();
46 AU.addRequired();
47 AU.addRequiredID(LoopSimplifyID);
48 AU.addPreservedID(LoopSimplifyID);
49 AU.addPreservedID(LCSSAID);
50 AU.addPreserved();
51 AU.addRequired();
48 getLoopAnalysisUsage(AU);
5249 }
5350 };
5451 }
5754 INITIALIZE_PASS_BEGIN(LoopInstSimplify, "loop-instsimplify",
5855 "Simplify instructions in loops", false, false)
5956 INITIALIZE_PASS_DEPENDENCY(AssumptionCacheTracker)
57 INITIALIZE_PASS_DEPENDENCY(LoopPass)
6058 INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfoWrapperPass)
61 INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
62 INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass)
63 INITIALIZE_PASS_DEPENDENCY(LCSSA)
6459 INITIALIZE_PASS_END(LoopInstSimplify, "loop-instsimplify",
6560 "Simplify instructions in loops", false, false)
6661
146146 bool runOnLoop(Loop *L, LPPassManager &LPM) override;
147147
148148 void getAnalysisUsage(AnalysisUsage &AU) const override {
149 AU.addRequired();
150 AU.addRequired();
151 AU.addPreserved();
152 AU.addRequired();
153 AU.addPreserved();
154 AU.addRequired();
155149 AU.addRequired();
150 getLoopAnalysisUsage(AU);
156151 }
157152
158153 protected:
438433
439434 char LoopReroll::ID = 0;
440435 INITIALIZE_PASS_BEGIN(LoopReroll, "loop-reroll", "Reroll loops", false, false)
441 INITIALIZE_PASS_DEPENDENCY(AAResultsWrapperPass)
442 INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass)
443 INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
444 INITIALIZE_PASS_DEPENDENCY(ScalarEvolutionWrapperPass)
436 INITIALIZE_PASS_DEPENDENCY(LoopPass)
445437 INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfoWrapperPass)
446438 INITIALIZE_PASS_END(LoopReroll, "loop-reroll", "Reroll loops", false, false)
447439
3333 #include "llvm/Support/raw_ostream.h"
3434 #include "llvm/Transforms/Utils/BasicBlockUtils.h"
3535 #include "llvm/Transforms/Utils/Local.h"
36 #include "llvm/Transforms/Utils/LoopUtils.h"
3637 #include "llvm/Transforms/Utils/SSAUpdater.h"
3738 #include "llvm/Transforms/Utils/ValueMapper.h"
3839 using namespace llvm;
577578
578579 // LCSSA form makes instruction renaming easier.
579580 void getAnalysisUsage(AnalysisUsage &AU) const override {
580 AU.addPreserved();
581581 AU.addRequired();
582 AU.addPreserved();
583 AU.addRequired();
584 AU.addPreserved();
585 AU.addRequiredID(LoopSimplifyID);
586 AU.addPreservedID(LoopSimplifyID);
587 AU.addRequiredID(LCSSAID);
588 AU.addPreservedID(LCSSAID);
589 AU.addPreserved();
590 AU.addPreserved();
591582 AU.addRequired();
592 AU.addPreserved();
593 AU.addPreserved();
583 getLoopAnalysisUsage(AU);
594584 }
595585
596586 bool runOnLoop(Loop *L, LPPassManager &LPM) override {
613603
614604 char LoopRotate::ID = 0;
615605 INITIALIZE_PASS_BEGIN(LoopRotate, "loop-rotate", "Rotate Loops", false, false)
606 INITIALIZE_PASS_DEPENDENCY(AssumptionCacheTracker)
607 INITIALIZE_PASS_DEPENDENCY(LoopPass)
616608 INITIALIZE_PASS_DEPENDENCY(TargetTransformInfoWrapperPass)
617 INITIALIZE_PASS_DEPENDENCY(AssumptionCacheTracker)
618 INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass)
619 INITIALIZE_PASS_DEPENDENCY(LoopSimplify)
620 INITIALIZE_PASS_DEPENDENCY(LCSSA)
621 INITIALIZE_PASS_DEPENDENCY(SCEVAAWrapperPass)
622 INITIALIZE_PASS_DEPENDENCY(BasicAAWrapperPass)
623 INITIALIZE_PASS_DEPENDENCY(GlobalsAAWrapperPass)
624609 INITIALIZE_PASS_END(LoopRotate, "loop-rotate", "Rotate Loops", false, false)
625610
626611 Pass *llvm::createLoopRotatePass(int MaxHeaderSize) {
2828 #include "llvm/Analysis/TargetTransformInfo.h"
2929 #include "llvm/IR/Dominators.h"
3030 #include "llvm/Transforms/Utils/Local.h"
31 #include "llvm/Transforms/Utils/LoopUtils.h"
3132 using namespace llvm;
3233
3334 #define DEBUG_TYPE "loop-simplifycfg"
4344 bool runOnLoop(Loop *L, LPPassManager &) override;
4445
4546 void getAnalysisUsage(AnalysisUsage &AU) const override {
46 AU.addRequired();
47 AU.addRequired();
48
49 AU.addPreserved();
50 AU.addPreserved();
51 AU.addPreserved();
52 AU.addPreserved();
53 AU.addPreserved();
54 AU.addPreserved();
55 AU.addPreserved();
5647 AU.addPreserved();
57 AU.addPreservedID(LoopSimplifyID);
58 AU.addPreservedID(LCSSAID);
48 getLoopAnalysisUsage(AU);
5949 }
6050 };
6151 }
6353 char LoopSimplifyCFG::ID = 0;
6454 INITIALIZE_PASS_BEGIN(LoopSimplifyCFG, "loop-simplifycfg", "Simplify loop CFG",
6555 false, false)
66 INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
67 INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass)
56 INITIALIZE_PASS_DEPENDENCY(LoopPass)
6857 INITIALIZE_PASS_END(LoopSimplifyCFG, "loop-simplifycfg", "Simplify loop CFG",
6958 false, false)
7059
3131 #include "llvm/Support/CommandLine.h"
3232 #include "llvm/Support/Debug.h"
3333 #include "llvm/Support/raw_ostream.h"
34 #include "llvm/Transforms/Utils/LoopUtils.h"
3435 #include "llvm/Transforms/Utils/UnrollLoop.h"
3536 #include
3637
743744 ///
744745 void getAnalysisUsage(AnalysisUsage &AU) const override {
745746 AU.addRequired();
746 AU.addRequired();
747 AU.addRequired();
748 AU.addPreserved();
749 AU.addRequiredID(LoopSimplifyID);
750 AU.addPreservedID(LoopSimplifyID);
751 AU.addRequiredID(LCSSAID);
752 AU.addPreservedID(LCSSAID);
753 AU.addRequired();
754 AU.addPreserved();
755747 AU.addRequired();
756 // FIXME: Loop unroll requires LCSSA. And LCSSA requires dom info.
757 // If loop unroll does not preserve dom info then LCSSA pass on next
758 // loop will receive invalid dom info.
759 // For now, recreate dom info, if loop is unrolled.
760 AU.addPreserved();
761 AU.addPreserved();
748 // FIXME: Loop passes are required to preserve domtree, and for now we just
749 // recreate dom info if anything gets unrolled.
750 getLoopAnalysisUsage(AU);
762751 }
763752 };
764753 }
765754
766755 char LoopUnroll::ID = 0;
767756 INITIALIZE_PASS_BEGIN(LoopUnroll, "loop-unroll", "Unroll loops", false, false)
757 INITIALIZE_PASS_DEPENDENCY(AssumptionCacheTracker)
758 INITIALIZE_PASS_DEPENDENCY(LoopPass)
768759 INITIALIZE_PASS_DEPENDENCY(TargetTransformInfoWrapperPass)
769 INITIALIZE_PASS_DEPENDENCY(AssumptionCacheTracker)
770 INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
771 INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass)
772 INITIALIZE_PASS_DEPENDENCY(LoopSimplify)
773 INITIALIZE_PASS_DEPENDENCY(LCSSA)
774 INITIALIZE_PASS_DEPENDENCY(ScalarEvolutionWrapperPass)
775760 INITIALIZE_PASS_END(LoopUnroll, "loop-unroll", "Unroll loops", false, false)
776761
777762 Pass *llvm::createLoopUnrollPass(int Threshold, int Count, int AllowPartial,
5454 #include "llvm/Transforms/Utils/BasicBlockUtils.h"
5555 #include "llvm/Transforms/Utils/Cloning.h"
5656 #include "llvm/Transforms/Utils/Local.h"
57 #include "llvm/Transforms/Utils/LoopUtils.h"
5758 #include
5859 #include
5960 #include
210211 ///
211212 void getAnalysisUsage(AnalysisUsage &AU) const override {
212213 AU.addRequired();
213 AU.addRequiredID(LoopSimplifyID);
214 AU.addPreservedID(LoopSimplifyID);
215 AU.addRequired();
216 AU.addPreserved();
217 AU.addRequiredID(LCSSAID);
218 AU.addPreservedID(LCSSAID);
219 AU.addRequired();
220 AU.addPreserved();
221 AU.addPreserved();
222214 AU.addRequired();
223 AU.addPreserved();
215 getLoopAnalysisUsage(AU);
224216 }
225217
226218 private:
381373 char LoopUnswitch::ID = 0;
382374 INITIALIZE_PASS_BEGIN(LoopUnswitch, "loop-unswitch", "Unswitch loops",
383375 false, false)
376 INITIALIZE_PASS_DEPENDENCY(AssumptionCacheTracker)
377 INITIALIZE_PASS_DEPENDENCY(LoopPass)
384378 INITIALIZE_PASS_DEPENDENCY(TargetTransformInfoWrapperPass)
385 INITIALIZE_PASS_DEPENDENCY(AssumptionCacheTracker)
386 INITIALIZE_PASS_DEPENDENCY(LoopSimplify)
387 INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass)
388 INITIALIZE_PASS_DEPENDENCY(LCSSA)
389379 INITIALIZE_PASS_END(LoopUnswitch, "loop-unswitch", "Unswitch loops",
390380 false, false)
391381
1010 //
1111 //===----------------------------------------------------------------------===//
1212
13 #include "llvm/Analysis/AliasAnalysis.h"
14 #include "llvm/Analysis/BasicAliasAnalysis.h"
1315 #include "llvm/Analysis/LoopInfo.h"
16 #include "llvm/Analysis/GlobalsModRef.h"
1417 #include "llvm/Analysis/ScalarEvolution.h"
1518 #include "llvm/Analysis/ScalarEvolutionExpressions.h"
19 #include "llvm/Analysis/ScalarEvolutionAliasAnalysis.h"
20 #include "llvm/IR/Dominators.h"
1621 #include "llvm/IR/Instructions.h"
1722 #include "llvm/IR/Module.h"
1823 #include "llvm/IR/PatternMatch.h"
1924 #include "llvm/IR/ValueHandle.h"
25 #include "llvm/Pass.h"
2026 #include "llvm/Support/Debug.h"
2127 #include "llvm/Transforms/Utils/LoopUtils.h"
2228
726732
727733 return UsedOutside;
728734 }
735
736 void llvm::getLoopAnalysisUsage(AnalysisUsage &AU) {
737 // By definition, all loop passes need the LoopInfo analysis and the
738 // Dominator tree it depends on. Because they all participate in the loop
739 // pass manager, they must also preserve these.
740 AU.addRequired();
741 AU.addPreserved();
742 AU.addRequired();
743 AU.addPreserved();
744
745 // We must also preserve LoopSimplify and LCSSA. We locally access their IDs
746 // here because users shouldn't directly get them from this header.
747 extern char &LoopSimplifyID;
748 extern char &LCSSAID;
749 AU.addRequiredID(LoopSimplifyID);
750 AU.addPreservedID(LoopSimplifyID);
751 AU.addRequiredID(LCSSAID);
752 AU.addPreservedID(LCSSAID);
753
754 // Loop passes are designed to run inside of a loop pass manager which means
755 // that any function analyses they require must be required by the first loop
756 // pass in the manager (so that it is computed before the loop pass manager
757 // runs) and preserved by all loop pasess in the manager. To make this
758 // reasonably robust, the set needed for most loop passes is maintained here.
759 // If your loop pass requires an analysis not listed here, you will need to
760 // carefully audit the loop pass manager nesting structure that results.
761 AU.addRequired();
762 AU.addPreserved();
763 AU.addPreserved();
764 AU.addPreserved();
765 AU.addPreserved();
766 AU.addRequired();
767 AU.addPreserved();
768 }
769
770 /// Manually defined generic "LoopPass" dependency initialization. This is used
771 /// to initialize the exact set of passes from above in \c
772 /// getLoopAnalysisUsage. It can be used within a loop pass's initialization
773 /// with:
774 ///
775 /// INITIALIZE_PASS_DEPENDENCY(LoopPass)
776 ///
777 /// As-if "LoopPass" were a pass.
778 void llvm::initializeLoopPassPass(PassRegistry &Registry) {
779 INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
780 INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass)
781 INITIALIZE_PASS_DEPENDENCY(LoopSimplify)
782 INITIALIZE_PASS_DEPENDENCY(LCSSA)
783 INITIALIZE_PASS_DEPENDENCY(AAResultsWrapperPass)
784 INITIALIZE_PASS_DEPENDENCY(BasicAAWrapperPass)
785 INITIALIZE_PASS_DEPENDENCY(GlobalsAAWrapperPass)
786 INITIALIZE_PASS_DEPENDENCY(SCEVAAWrapperPass)
787 INITIALIZE_PASS_DEPENDENCY(ScalarEvolutionWrapperPass)
788 }
3737 ; CHECK-O2-NOT: Manager
3838 ; CHECK-O2: Loop Pass Manager
3939 ; CHECK-O2-NOT: Manager
40 ; FIXME: We shouldn't have this extra loop pass manager!
41 ; CHECK-O2: Loop Pass Manager
42 ; CHECK-O2-NOT: Manager
43 ; FIXME: Yet another pointless loop pass manager!
44 ; CHECK-O2: Loop Pass Manager
45 ; CHECK-O2-NOT: Manager
4640 ; FIXME: We shouldn't be pulling out to simplify-cfg and instcombine and
4741 ; causing new loop pass managers.
4842 ; CHECK-O2: Simplify the CFG
4943 ; CHECK-O2-NOT: Manager
5044 ; CHECK-O2: Combine redundant instructions
5145 ; CHECK-O2-NOT: Manager
52 ; CHECK-O2: Loop Pass Manager
53 ; CHECK-O2-NOT: Manager
54 ; FIXME: Yet another pointless loop pass manager!
55 ; CHECK-O2: Loop Pass Manager
56 ; CHECK-O2-NOT: Manager
57 ; FIXME: Yet another pointless loop pass manager!
5846 ; CHECK-O2: Loop Pass Manager
5947 ; CHECK-O2-NOT: Manager
6048 ; FIXME: It isn't clear that we need yet another loop pass pipeline
5757 ; CHECK: br label %for.body
5858
5959 ; CHECK: for.body: ; preds = %for.body, %for.body.preheader
60 ; CHECK: %indvar = phi i32 [ %indvar.next, %for.body ], [ 0, %for.body.preheader ]
60 ; CHECK: %indvar = phi i32 [ 0, %for.body.preheader ], [ %indvar.next, %for.body ]
6161 ; CHECK: %6 = add i32 %m, %indvar
6262 ; CHECK: %arrayidx = getelementptr inbounds i32, i32* %B, i32 %6
6363 ; CHECK: %7 = load i32, i32* %arrayidx, align 4
6666 ; CHECK: store i32 %mul, i32* %arrayidx2, align 4
6767 ; CHECK: %indvar.next = add i32 %indvar, 1
6868 ; CHECK: %exitcond = icmp eq i32 %6, %5
69 ; CHECK: br i1 %exitcond, label %for.end, label %for.body
69 ; CHECK: br i1 %exitcond, label %for.end.loopexit, label %for.body
7070
7171 ;void daxpy_ur(int n,float da,float *dx,float *dy)
7272 ; {
137137 ; CHECK: br label %for.body
138138
139139 ; CHECK: for.body:
140 ; CHECK: %indvar = phi i32 [ %indvar.next, %for.body ], [ 0, %for.body.preheader ]
140 ; CHECK: %indvar = phi i32 [ 0, %for.body.preheader ], [ %indvar.next, %for.body ]
141141 ; CHECK: %6 = add i32 %rem, %indvar
142142 ; CHECK: %arrayidx = getelementptr inbounds float, float* %dy, i32 %6
143143 ; CHECK: %7 = load float, float* %arrayidx, align 4
148148 ; CHECK: store float %add, float* %arrayidx, align 4
149149 ; CHECK: %indvar.next = add i32 %indvar, 1
150150 ; CHECK: %exitcond = icmp eq i32 %6, %5
151 ; CHECK: br i1 %exitcond, label %for.end, label %for.body
151 ; CHECK: br i1 %exitcond, label %for.end.loopexit, label %for.body