[llvm] r346618 - [IPSCCP,PM] Preserve PDT in the new pass manager.
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 11 12:22:46 PST 2018
Author: fhahn
Date: Sun Nov 11 12:22:45 2018
New Revision: 346618
URL: http://llvm.org/viewvc/llvm-project?rev=346618&view=rev
Log:
[IPSCCP,PM] Preserve PDT in the new pass manager.
Reviewers: kuhar, chandlerc, NutshellySima, brzycki
Reviewed By: NutshellySima, brzycki
Differential Revision: https://reviews.llvm.org/D54317
Added:
llvm/trunk/test/Transforms/SCCP/ipsccp-preserve-analysis.ll
Removed:
llvm/trunk/test/Transforms/SCCP/ipsccp-preserve-domtree.ll
Modified:
llvm/trunk/include/llvm/Transforms/Scalar/SCCP.h
llvm/trunk/lib/Transforms/IPO/SCCP.cpp
llvm/trunk/lib/Transforms/Scalar/SCCP.cpp
Modified: llvm/trunk/include/llvm/Transforms/Scalar/SCCP.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Scalar/SCCP.h?rev=346618&r1=346617&r2=346618&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Transforms/Scalar/SCCP.h (original)
+++ llvm/trunk/include/llvm/Transforms/Scalar/SCCP.h Sun Nov 11 12:22:45 2018
@@ -43,6 +43,7 @@ public:
struct AnalysisResultsForFn {
std::unique_ptr<PredicateInfo> PredInfo;
DominatorTree *DT;
+ PostDominatorTree *PDT;
};
bool runIPSCCP(Module &M, const DataLayout &DL, const TargetLibraryInfo *TLI,
Modified: llvm/trunk/lib/Transforms/IPO/SCCP.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/SCCP.cpp?rev=346618&r1=346617&r2=346618&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/SCCP.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/SCCP.cpp Sun Nov 11 12:22:45 2018
@@ -1,5 +1,6 @@
#include "llvm/Transforms/IPO/SCCP.h"
#include "llvm/Analysis/AssumptionCache.h"
+#include "llvm/Analysis/PostDominators.h"
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/Transforms/IPO.h"
#include "llvm/Transforms/Scalar/SCCP.h"
@@ -14,7 +15,7 @@ PreservedAnalyses IPSCCPPass::run(Module
DominatorTree &DT = FAM.getResult<DominatorTreeAnalysis>(F);
return {
make_unique<PredicateInfo>(F, DT, FAM.getResult<AssumptionAnalysis>(F)),
- &DT};
+ &DT, FAM.getCachedResult<PostDominatorTreeAnalysis>(F)};
};
if (!runIPSCCP(M, DL, &TLI, getAnalysis))
@@ -22,6 +23,7 @@ PreservedAnalyses IPSCCPPass::run(Module
PreservedAnalyses PA;
PA.preserve<DominatorTreeAnalysis>();
+ PA.preserve<PostDominatorTreeAnalysis>();
PA.preserve<FunctionAnalysisManagerModuleProxy>();
return PA;
}
@@ -56,8 +58,8 @@ public:
F, DT,
this->getAnalysis<AssumptionCacheTracker>().getAssumptionCache(
F)),
- nullptr}; // We cannot preserve the DT with the legacy pass manager,
- // so so set it to nullptr.
+ nullptr, // We cannot preserve the DT or PDT with the legacy pass
+ nullptr}; // manager, so set them to nullptr.
};
return runIPSCCP(M, DL, TLI, getAnalysis);
Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCP.cpp?rev=346618&r1=346617&r2=346618&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/SCCP.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Sun Nov 11 12:22:45 2018
@@ -262,10 +262,10 @@ public:
return A->second.PredInfo->getPredicateInfoFor(I);
}
- DominatorTree *getDomTree(Function &F) {
+ DomTreeUpdater getDTU(Function &F) {
auto A = AnalysisResults.find(&F);
assert(A != AnalysisResults.end() && "Need analysis results for function.");
- return A->second.DT;
+ return {A->second.DT, A->second.PDT, DomTreeUpdater::UpdateStrategy::Lazy};
}
SCCPSolver(const DataLayout &DL, const TargetLibraryInfo *tli)
@@ -2036,8 +2036,7 @@ bool llvm::runIPSCCP(
}
}
- DomTreeUpdater DTU(Solver.getDomTree(F),
- DomTreeUpdater::UpdateStrategy::Lazy);
+ DomTreeUpdater DTU = Solver.getDTU(F);
// Change dead blocks to unreachable. We do it after replacing constants
// in all executable blocks, because changeToUnreachable may remove PHI
// nodes in executable blocks we found values for. The function's entry
Added: llvm/trunk/test/Transforms/SCCP/ipsccp-preserve-analysis.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SCCP/ipsccp-preserve-analysis.ll?rev=346618&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/SCCP/ipsccp-preserve-analysis.ll (added)
+++ llvm/trunk/test/Transforms/SCCP/ipsccp-preserve-analysis.ll Sun Nov 11 12:22:45 2018
@@ -0,0 +1,56 @@
+; Basic test to check that DominatorTreeAnalysis is preserved by IPSCCP and
+; the following analysis can re-use it. The test contains two trivial functions
+; IPSCCP can simplify, so we can test the case where IPSCCP makes changes.
+
+; RUN: opt -disable-verify -debug-pass-manager \
+; RUN: -passes='function(require<domtree>,require<postdomtree>),ipsccp,function(require<domtree>,require<postdomtree>)' -S %s 2>&1 \
+; RUN: | FileCheck -check-prefixes='IR,NEW-PM' %s
+
+; RUN: opt -passes='function(require<postdomtree>),ipsccp,function(verify<domtree>)' -S %s | FileCheck -check-prefixes='IR' %s
+
+; NEW-PM: Starting llvm::Module pass manager run.
+; NEW-PM: Running analysis: DominatorTreeAnalysis on f1
+; NEW-PM: Running analysis: PostDominatorTreeAnalysis on f1
+; NEW-PM: Running analysis: DominatorTreeAnalysis on f2
+; NEW-PM: Running analysis: PostDominatorTreeAnalysis on f2
+; NEW-PM: Running pass: IPSCCPPass
+; NEW-PM-DAG: Running analysis: AssumptionAnalysis on f1
+; NEW-PM-DAG: Running analysis: AssumptionAnalysis on f2
+; NEW-PM-NEXT: Invalidating all non-preserved analyses for:
+; NEW-PM-NEXT: Invalidating all non-preserved analyses for: f1
+; NEW-PM-NEXT: Invalidating all non-preserved analyses for: f2
+; NEW-PM-NEXT: Running pass: ModuleToFunctionPassAdaptor
+; NEW-PM-NOT: Running analysis:
+
+; IR-LABEL: @f1
+; IR-LABEL: entry:
+; IR-NEXT: br label %bb2
+; IR-LABEL: bb2:
+; IR-NEXT: undef
+
+; IR-LABEL: @f2
+; IR-NOT: icmp
+; IR: br label %bbtrue
+; IR-LABEL: bbtrue:
+; IR-NEXT: ret i32 0
+define internal i32 @f1() readnone {
+entry:
+ br i1 false, label %bb1, label %bb2
+bb1:
+ ret i32 10
+bb2:
+ ret i32 10
+}
+
+define i32 @f2(i32 %n) {
+ %i = call i32 @f1()
+ %cmp = icmp eq i32 %i, 10
+ br i1 %cmp, label %bbtrue, label %bbfalse
+
+bbtrue:
+ ret i32 0
+
+bbfalse:
+ %res = add i32 %n, %i
+ ret i32 %res
+}
Removed: llvm/trunk/test/Transforms/SCCP/ipsccp-preserve-domtree.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SCCP/ipsccp-preserve-domtree.ll?rev=346617&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/SCCP/ipsccp-preserve-domtree.ll (original)
+++ llvm/trunk/test/Transforms/SCCP/ipsccp-preserve-domtree.ll (removed)
@@ -1,63 +0,0 @@
-; Basic test to check that DominatorTreeAnalysis is preserved by IPSCCP and
-; the following analysis can re-use it. The test contains two trivial functions
-; IPSCCP can simplify, so we can test the case where IPSCCP makes changes.
-
-; RUN: opt -disable-verify -debug-pass-manager \
-; RUN: -passes='ipsccp,globalopt' -S %s 2>&1 \
-; RUN: | FileCheck -check-prefixes='IR,NEW-PM' %s
-
-; RUN: opt -passes='ipsccp,function(verify<domtree>)' -S %s | FileCheck -check-prefixes='IR' %s
-
-; NEW-PM: Starting llvm::Module pass manager run.
-; NEW-PM-NEXT: Running pass: IPSCCPPass
-; NEW-PM-DAG: Running analysis: TargetLibraryAnalysis
-; NEW-PM-DAG: Running analysis: InnerAnalysisManagerProxy
-; NEW-PM-DAG: Running analysis: AssumptionAnalysis on f1
-; NEW-PM-DAG: Running analysis: DominatorTreeAnalysis on f1
-; NEW-PM-DAG: Running analysis: PassInstrumentationAnalysis on f1
-; NEW-PM-DAG: Running analysis: DominatorTreeAnalysis on f2
-; NEW-PM-DAG: Running analysis: AssumptionAnalysis on f2
-; NEW-PM-DAG: Running analysis: PassInstrumentationAnalysis on f2
-; NEW-PM-NEXT: Invalidating all non-preserved analyses for:
-; NEW-PM-NEXT: Invalidating all non-preserved analyses for: f1
-; NEW-PM-NEXT: Invalidating all non-preserved analyses for: f2
-; NEW-PM-NEXT: Running pass: GlobalOptPass on
-; NEW-PM-DAG: Running analysis: BlockFrequencyAnalysis on f2
-; NEW-PM-DAG: Running analysis: LoopAnalysis on f2
-; NEW-PM-DAG: Running analysis: BranchProbabilityAnalysis on f2
-; NEW-PM-DAG: Running analysis: TargetLibraryAnalysis on f2
-; NEW-PM-NEXT: Running analysis: TargetIRAnalysis on f1
-; NEW-PM-NEXT: Invalidating all non-preserved analyses for:
-
-; IR-LABEL: @f1
-; IR-LABEL: entry:
-; IR-NEXT: br label %bb2
-; IR-LABEL: bb2:
-; IR-NEXT: undef
-
-; IR-LABEL: @f2
-; IR-NOT: icmp
-; IR: br label %bbtrue
-; IR-LABEL: bbtrue:
-; IR-NEXT: ret i32 0
-define internal i32 @f1() readnone {
-entry:
- br i1 false, label %bb1, label %bb2
-bb1:
- ret i32 10
-bb2:
- ret i32 10
-}
-
-define i32 @f2(i32 %n) {
- %i = call i32 @f1()
- %cmp = icmp eq i32 %i, 10
- br i1 %cmp, label %bbtrue, label %bbfalse
-
-bbtrue:
- ret i32 0
-
-bbfalse:
- %res = add i32 %n, %i
- ret i32 %res
-}
More information about the llvm-commits
mailing list