From 340ad683c830e13f5deb881442bd0fee7c9cf7ed Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Sat, 14 Jan 2017 23:25:22 +0000 Subject: [PATCH] [PM] Fix instcombine's analysis preservation in the new pass manager to cover domtree and alias analysis. These are the pretty clear analyses that we would always want to survive this pass. To make these survive, we also need to preserve the assumption cache. Added a test that verifies the important bits of this preservation. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292037 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../InstCombine/InstructionCombining.cpp | 3 ++ .../InstCombine/preserved-analyses.ll | 33 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 test/Transforms/InstCombine/preserved-analyses.ll diff --git a/lib/Transforms/InstCombine/InstructionCombining.cpp b/lib/Transforms/InstCombine/InstructionCombining.cpp index 27fc34d2317..b2c4baae99b 100644 --- a/lib/Transforms/InstCombine/InstructionCombining.cpp +++ b/lib/Transforms/InstCombine/InstructionCombining.cpp @@ -3178,7 +3178,10 @@ PreservedAnalyses InstCombinePass::run(Function &F, // Mark all the analyses that instcombine updates as preserved. // FIXME: This should also 'preserve the CFG'. PreservedAnalyses PA; + PA.preserve(); + PA.preserve(); PA.preserve(); + PA.preserve(); return PA; } diff --git a/test/Transforms/InstCombine/preserved-analyses.ll b/test/Transforms/InstCombine/preserved-analyses.ll new file mode 100644 index 00000000000..767304aecf3 --- /dev/null +++ b/test/Transforms/InstCombine/preserved-analyses.ll @@ -0,0 +1,33 @@ +; This is really testing that instcombine preserves analyses correctly, so we +; don't care much about the code other than it is something instcombine can +; transform. +; +; RUN: opt < %s -disable-output -debug-pass-manager 2>&1 -aa-pipeline=basic-aa,globals-aa \ +; RUN: -passes='require,function(require,instcombine),function(require)' \ +; RUN: | FileCheck %s --check-prefix=AA +; AA: Running analysis: GlobalsAA +; AA: Running analysis: AAManager +; AA: Running analysis: BasicAA +; AA: Running pass: InstCombinePass on test +; AA-NOT: Invalidating analysis: GlobalsAA +; AA-NOT: Invalidating analysis: AAmanager +; AA-NOT: Invalidating analysis: BasicAA +; AA: Running pass: RequireAnalysisPass<{{.*}}AAManager +; AA-NOT: Running analysis: GlobalsAA +; AA-NOT: Running analysis: AAmanager +; AA-NOT: Running analysis: BasicAA +; +; RUN: opt < %s -disable-output -debug-pass-manager 2>&1 \ +; RUN: -passes='require,instcombine,require' \ +; RUN: | FileCheck %s --check-prefix=DT +; DT: Running analysis: DominatorTreeAnalysis +; DT: Running pass: InstCombinePass on test +; DT-NOT: Invalidating analysis: DominatorTreeAnalysis +; DT: Running pass: RequireAnalysisPass<{{.*}}DominatorTreeAnalysis +; DT-NOT: Running analysis: DominatorTreeAnalysis + +define i32 @test(i32 %A) { + %B = add i32 %A, 5 + %C = add i32 %B, -5 + ret i32 %C +} -- 2.50.1