aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Scalar/LoopPredication.cpp
diff options
context:
space:
mode:
authorAlina Sbirlea <asbirlea@google.com>2020-01-16 15:32:30 -0800
committerAlina Sbirlea <asbirlea@google.com>2020-02-12 09:15:18 -0800
commit4f33a68973bfd9fa429b57528c3fe5443f59a734 (patch)
treea2559ea9582732022491f7d5f959eadf78dbddfa /llvm/lib/Transforms/Scalar/LoopPredication.cpp
parentfa7cd549d604bfd8f9dce5d649a19720cbc39cca (diff)
downloadllvm-4f33a68973bfd9fa429b57528c3fe5443f59a734.zip
llvm-4f33a68973bfd9fa429b57528c3fe5443f59a734.tar.gz
llvm-4f33a68973bfd9fa429b57528c3fe5443f59a734.tar.bz2
Compute ORE, BPI, BFI in Loop passes.
Summary: Passes ORE, BPI, BFI are not being preserved by Loop passes, hence it is incorrect to retrieve these passes as cached. This patch makes the loop passes in question compute a new instance. In some of these cases, however, it may be beneficial to change the Loop pass to a Function pass instead, similar to the change for LoopUnrollAndJam. Reviewers: chandlerc, dmgreen, jdoerfert, reames Subscribers: mehdi_amini, hiraditya, zzheng, steven_wu, dexonsmith, Whitney, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D72891
Diffstat (limited to 'llvm/lib/Transforms/Scalar/LoopPredication.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/LoopPredication.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopPredication.cpp b/llvm/lib/Transforms/Scalar/LoopPredication.cpp
index d87c775..4f83205 100644
--- a/llvm/lib/Transforms/Scalar/LoopPredication.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopPredication.cpp
@@ -358,11 +358,13 @@ Pass *llvm::createLoopPredicationPass() {
PreservedAnalyses LoopPredicationPass::run(Loop &L, LoopAnalysisManager &AM,
LoopStandardAnalysisResults &AR,
LPMUpdater &U) {
- const auto &FAM =
- AM.getResult<FunctionAnalysisManagerLoopProxy>(L, AR).getManager();
Function *F = L.getHeader()->getParent();
- auto *BPI = FAM.getCachedResult<BranchProbabilityAnalysis>(*F);
- LoopPredication LP(&AR.AA, &AR.DT, &AR.SE, &AR.LI, BPI);
+ // For the new PM, we also can't use BranchProbabilityInfo as an analysis
+ // pass. Function analyses need to be preserved across loop transformations
+ // but BPI is not preserved, hence a newly built one is needed.
+ BranchProbabilityInfo BPI;
+ BPI.calculate(*F, AR.LI);
+ LoopPredication LP(&AR.AA, &AR.DT, &AR.SE, &AR.LI, &BPI);
if (!LP.runOnLoop(&L))
return PreservedAnalyses::all();