1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00

[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

llvm-svn: 346618
This commit is contained in:
Florian Hahn 2018-11-11 20:22:45 +00:00
parent 92467441d1
commit 2f913c647c
4 changed files with 18 additions and 23 deletions

View File

@ -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,

View File

@ -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 &M, ModuleAnalysisManager &AM) {
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 &M, ModuleAnalysisManager &AM) {
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);

View File

@ -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

View File

@ -3,31 +3,24 @@
; 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: -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='ipsccp,function(verify<domtree>)' -S %s | FileCheck -check-prefixes='IR' %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-NEXT: Running pass: IPSCCPPass
; NEW-PM-DAG: Running analysis: TargetLibraryAnalysis
; NEW-PM-DAG: Running analysis: InnerAnalysisManagerProxy
; 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: 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:
; NEW-PM-NEXT: Running pass: ModuleToFunctionPassAdaptor
; NEW-PM-NOT: Running analysis:
; IR-LABEL: @f1
; IR-LABEL: entry: