From: Dehao Chen Date: Tue, 6 Sep 2016 22:17:16 +0000 (+0000) Subject: Explicitly require DominatorTreeAnalysis pass for instsimplify pass. X-Git-Tag: llvmorg-4.0.0-rc1~10509 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3857f8f0ac48b6b702d0f04e72b286a9ef453d31;p=platform%2Fupstream%2Fllvm.git Explicitly require DominatorTreeAnalysis pass for instsimplify pass. Summary: DominatorTreeAnalysis is always required by instsimplify. Reviewers: danielcdh, davidxl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D24173 llvm-svn: 280760 --- diff --git a/llvm/lib/Transforms/Utils/SimplifyInstructions.cpp b/llvm/lib/Transforms/Utils/SimplifyInstructions.cpp index 3099c49..0be0b65 100644 --- a/llvm/lib/Transforms/Utils/SimplifyInstructions.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyInstructions.cpp @@ -90,6 +90,7 @@ namespace { void getAnalysisUsage(AnalysisUsage &AU) const override { AU.setPreservesCFG(); + AU.addRequired(); AU.addRequired(); AU.addRequired(); } @@ -99,9 +100,8 @@ namespace { if (skipFunction(F)) return false; - const DominatorTreeWrapperPass *DTWP = - getAnalysisIfAvailable(); - const DominatorTree *DT = DTWP ? &DTWP->getDomTree() : nullptr; + const DominatorTree *DT = + &getAnalysis().getDomTree(); const TargetLibraryInfo *TLI = &getAnalysis().getTLI(); AssumptionCache *AC = @@ -115,6 +115,7 @@ char InstSimplifier::ID = 0; INITIALIZE_PASS_BEGIN(InstSimplifier, "instsimplify", "Remove redundant instructions", false, false) INITIALIZE_PASS_DEPENDENCY(AssumptionCacheTracker) +INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass) INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfoWrapperPass) INITIALIZE_PASS_END(InstSimplifier, "instsimplify", "Remove redundant instructions", false, false) @@ -127,10 +128,10 @@ FunctionPass *llvm::createInstructionSimplifierPass() { PreservedAnalyses InstSimplifierPass::run(Function &F, FunctionAnalysisManager &AM) { - auto *DT = AM.getCachedResult(F); + auto &DT = AM.getResult(F); auto &TLI = AM.getResult(F); auto &AC = AM.getResult(F); - bool Changed = runImpl(F, DT, &TLI, &AC); + bool Changed = runImpl(F, &DT, &TLI, &AC); if (!Changed) return PreservedAnalyses::all(); // FIXME: This should also 'preserve the CFG'.