Skip to content

Commit e573b77

Browse files
committedSep 1, 2016
Explicitly require DominatorTreeAnalysis pass for instsimplify pass.
Summary: DominatorTreeAnalysis is always required by instsimplify. Reviewers: davidxl, danielcdh Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D24173 llvm-svn: 280432
1 parent ae4ff45 commit e573b77

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed
 

‎llvm/lib/Transforms/Utils/SimplifyInstructions.cpp

+6-5
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ namespace {
9090

9191
void getAnalysisUsage(AnalysisUsage &AU) const override {
9292
AU.setPreservesCFG();
93+
AU.addRequired<DominatorTreeWrapperPass>();
9394
AU.addRequired<AssumptionCacheTracker>();
9495
AU.addRequired<TargetLibraryInfoWrapperPass>();
9596
}
@@ -99,9 +100,8 @@ namespace {
99100
if (skipFunction(F))
100101
return false;
101102

102-
const DominatorTreeWrapperPass *DTWP =
103-
getAnalysisIfAvailable<DominatorTreeWrapperPass>();
104-
const DominatorTree *DT = DTWP ? &DTWP->getDomTree() : nullptr;
103+
const DominatorTree *DT =
104+
&getAnalysis<DominatorTreeWrapperPass>().getDomTree();
105105
const TargetLibraryInfo *TLI =
106106
&getAnalysis<TargetLibraryInfoWrapperPass>().getTLI();
107107
AssumptionCache *AC =
@@ -115,6 +115,7 @@ char InstSimplifier::ID = 0;
115115
INITIALIZE_PASS_BEGIN(InstSimplifier, "instsimplify",
116116
"Remove redundant instructions", false, false)
117117
INITIALIZE_PASS_DEPENDENCY(AssumptionCacheTracker)
118+
INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
118119
INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfoWrapperPass)
119120
INITIALIZE_PASS_END(InstSimplifier, "instsimplify",
120121
"Remove redundant instructions", false, false)
@@ -127,10 +128,10 @@ FunctionPass *llvm::createInstructionSimplifierPass() {
127128

128129
PreservedAnalyses InstSimplifierPass::run(Function &F,
129130
FunctionAnalysisManager &AM) {
130-
auto *DT = AM.getCachedResult<DominatorTreeAnalysis>(F);
131+
auto &DT = AM.getResult<DominatorTreeAnalysis>(F);
131132
auto &TLI = AM.getResult<TargetLibraryAnalysis>(F);
132133
auto &AC = AM.getResult<AssumptionAnalysis>(F);
133-
bool Changed = runImpl(F, DT, &TLI, &AC);
134+
bool Changed = runImpl(F, &DT, &TLI, &AC);
134135
if (!Changed)
135136
return PreservedAnalyses::all();
136137
// FIXME: This should also 'preserve the CFG'.

0 commit comments

Comments
 (0)