llvm.org GIT mirror llvm / 0d5f624
[LPM/BPI] Preserve BPI through trivial loop pass pipeline (e.g. LCSSA, LoopSimplify) Currently, we do not expose BPI to loop passes at all. In the old pass manager, we appear to have been ignoring the fact that LCSSA and/or LoopSimplify didn't preserve BPI, and making it available to the following loop passes anyways. In the new one, it's invalidated before running any loop pass if either LCSSA or LoopSimplify actually make changes. If they don't make changes, then BPI is valid and available. So, we go ahead and teach LCSSA and LoopSimplify how to preserve BPI for consistency between old and new pass managers. This patch avoids an invalidation between the two requires in the following trivial pass pipeline: opt -passes="requires<branch-prob>,loop(no-op-loop),requires<branch-prob>" (when the input file is one which requires either LCSSA or LoopSimplify to canonicalize the loops) Differential Revision: https://reviews.llvm.org/D60790 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358901 91177308-0d34-0410-b5e6-96231b3b80d8 Philip Reames 4 months ago
5 changed file(s) with 13 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
3030 #include "llvm/ADT/Statistic.h"
3131 #include "llvm/Analysis/AliasAnalysis.h"
3232 #include "llvm/Analysis/BasicAliasAnalysis.h"
33 #include "llvm/Analysis/BranchProbabilityInfo.h"
3334 #include "llvm/Analysis/GlobalsModRef.h"
3435 #include "llvm/Analysis/LoopPass.h"
3536 #include "llvm/Analysis/ScalarEvolution.h"
441442 AU.addPreserved();
442443 AU.addPreserved();
443444 AU.addPreserved();
445 AU.addPreserved();
444446
445447 // This is needed to perform LCSSA verification inside LPPassManager
446448 AU.addRequired();
484486 PA.preserve();
485487 PA.preserve();
486488 PA.preserve();
489 // BPI maps terminators to probabilities, since we don't modify the CFG, no
490 // updates are needed to preserve it.
491 PA.preserve();
487492 return PA;
488493 }
4747 #include "llvm/Analysis/AliasAnalysis.h"
4848 #include "llvm/Analysis/AssumptionCache.h"
4949 #include "llvm/Analysis/BasicAliasAnalysis.h"
50 #include "llvm/Analysis/BranchProbabilityInfo.h"
5051 #include "llvm/Analysis/DependenceAnalysis.h"
5152 #include "llvm/Analysis/GlobalsModRef.h"
5253 #include "llvm/Analysis/InstructionSimplify.h"
739740 AU.addPreservedID(LCSSAID);
740741 AU.addPreserved();
741742 AU.addPreservedID(BreakCriticalEdgesID); // No critical edges added.
743 AU.addPreserved();
742744 }
743745
744746 /// verifyAnalysis() - Verify LoopSimplifyForm's guarantees.
811813 PA.preserve();
812814 PA.preserve();
813815 PA.preserve();
816 // BPI maps conditional terminators to probabilities, LoopSimplify can insert
817 // blocks, but it does so only by splitting existing blocks and edges. This
818 // results in the interesting property that all new terminators inserted are
819 // unconditional branches which do not appear in BPI. All deletions are
820 // handled via ValueHandle callbacks w/in BPI.
821 PA.preserve();
814822 return PA;
815823 }
816824
270270 ; CHECK-NEXT: Basic Alias Analysis (stateless AA impl)
271271 ; CHECK-NEXT: Function Alias Analysis Results
272272 ; CHECK-NEXT: Scalar Evolution Analysis
273 ; CHECK-NEXT: Branch Probability Analysis
274273 ; CHECK-NEXT: Block Frequency Analysis
275274 ; CHECK-NEXT: Loop Pass Manager
276275 ; CHECK-NEXT: Loop Sink
275275 ; CHECK-NEXT: Basic Alias Analysis (stateless AA impl)
276276 ; CHECK-NEXT: Function Alias Analysis Results
277277 ; CHECK-NEXT: Scalar Evolution Analysis
278 ; CHECK-NEXT: Branch Probability Analysis
279278 ; CHECK-NEXT: Block Frequency Analysis
280279 ; CHECK-NEXT: Loop Pass Manager
281280 ; CHECK-NEXT: Loop Sink
257257 ; CHECK-NEXT: Basic Alias Analysis (stateless AA impl)
258258 ; CHECK-NEXT: Function Alias Analysis Results
259259 ; CHECK-NEXT: Scalar Evolution Analysis
260 ; CHECK-NEXT: Branch Probability Analysis
261260 ; CHECK-NEXT: Block Frequency Analysis
262261 ; CHECK-NEXT: Loop Pass Manager
263262 ; CHECK-NEXT: Loop Sink