forked from OSchip/llvm-project
[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 llvm-svn: 358901
This commit is contained in:
parent
01f8d556aa
commit
37104d7189
|
@ -31,6 +31,7 @@
|
|||
#include "llvm/ADT/Statistic.h"
|
||||
#include "llvm/Analysis/AliasAnalysis.h"
|
||||
#include "llvm/Analysis/BasicAliasAnalysis.h"
|
||||
#include "llvm/Analysis/BranchProbabilityInfo.h"
|
||||
#include "llvm/Analysis/GlobalsModRef.h"
|
||||
#include "llvm/Analysis/LoopPass.h"
|
||||
#include "llvm/Analysis/ScalarEvolution.h"
|
||||
|
@ -442,6 +443,7 @@ struct LCSSAWrapperPass : public FunctionPass {
|
|||
AU.addPreserved<GlobalsAAWrapperPass>();
|
||||
AU.addPreserved<ScalarEvolutionWrapperPass>();
|
||||
AU.addPreserved<SCEVAAWrapperPass>();
|
||||
AU.addPreserved<BranchProbabilityInfoWrapperPass>();
|
||||
|
||||
// This is needed to perform LCSSA verification inside LPPassManager
|
||||
AU.addRequired<LCSSAVerificationPass>();
|
||||
|
@ -485,5 +487,8 @@ PreservedAnalyses LCSSAPass::run(Function &F, FunctionAnalysisManager &AM) {
|
|||
PA.preserve<GlobalsAA>();
|
||||
PA.preserve<SCEVAA>();
|
||||
PA.preserve<ScalarEvolutionAnalysis>();
|
||||
// BPI maps terminators to probabilities, since we don't modify the CFG, no
|
||||
// updates are needed to preserve it.
|
||||
PA.preserve<BranchProbabilityAnalysis>();
|
||||
return PA;
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#include "llvm/Analysis/AliasAnalysis.h"
|
||||
#include "llvm/Analysis/AssumptionCache.h"
|
||||
#include "llvm/Analysis/BasicAliasAnalysis.h"
|
||||
#include "llvm/Analysis/BranchProbabilityInfo.h"
|
||||
#include "llvm/Analysis/DependenceAnalysis.h"
|
||||
#include "llvm/Analysis/GlobalsModRef.h"
|
||||
#include "llvm/Analysis/InstructionSimplify.h"
|
||||
|
@ -740,6 +741,7 @@ namespace {
|
|||
AU.addPreservedID(LCSSAID);
|
||||
AU.addPreserved<DependenceAnalysisWrapperPass>();
|
||||
AU.addPreservedID(BreakCriticalEdgesID); // No critical edges added.
|
||||
AU.addPreserved<BranchProbabilityInfoWrapperPass>();
|
||||
}
|
||||
|
||||
/// verifyAnalysis() - Verify LoopSimplifyForm's guarantees.
|
||||
|
@ -812,6 +814,12 @@ PreservedAnalyses LoopSimplifyPass::run(Function &F,
|
|||
PA.preserve<SCEVAA>();
|
||||
PA.preserve<ScalarEvolutionAnalysis>();
|
||||
PA.preserve<DependenceAnalysis>();
|
||||
// BPI maps conditional terminators to probabilities, LoopSimplify can insert
|
||||
// blocks, but it does so only by splitting existing blocks and edges. This
|
||||
// results in the interesting property that all new terminators inserted are
|
||||
// unconditional branches which do not appear in BPI. All deletions are
|
||||
// handled via ValueHandle callbacks w/in BPI.
|
||||
PA.preserve<BranchProbabilityAnalysis>();
|
||||
return PA;
|
||||
}
|
||||
|
||||
|
|
|
@ -271,7 +271,6 @@
|
|||
; CHECK-NEXT: Basic Alias Analysis (stateless AA impl)
|
||||
; CHECK-NEXT: Function Alias Analysis Results
|
||||
; CHECK-NEXT: Scalar Evolution Analysis
|
||||
; CHECK-NEXT: Branch Probability Analysis
|
||||
; CHECK-NEXT: Block Frequency Analysis
|
||||
; CHECK-NEXT: Loop Pass Manager
|
||||
; CHECK-NEXT: Loop Sink
|
||||
|
|
|
@ -276,7 +276,6 @@
|
|||
; CHECK-NEXT: Basic Alias Analysis (stateless AA impl)
|
||||
; CHECK-NEXT: Function Alias Analysis Results
|
||||
; CHECK-NEXT: Scalar Evolution Analysis
|
||||
; CHECK-NEXT: Branch Probability Analysis
|
||||
; CHECK-NEXT: Block Frequency Analysis
|
||||
; CHECK-NEXT: Loop Pass Manager
|
||||
; CHECK-NEXT: Loop Sink
|
||||
|
|
|
@ -258,7 +258,6 @@
|
|||
; CHECK-NEXT: Basic Alias Analysis (stateless AA impl)
|
||||
; CHECK-NEXT: Function Alias Analysis Results
|
||||
; CHECK-NEXT: Scalar Evolution Analysis
|
||||
; CHECK-NEXT: Branch Probability Analysis
|
||||
; CHECK-NEXT: Block Frequency Analysis
|
||||
; CHECK-NEXT: Loop Pass Manager
|
||||
; CHECK-NEXT: Loop Sink
|
||||
|
|
Loading…
Reference in New Issue