[llvm] r292037 - [PM] Fix instcombine's analysis preservation in the new pass manager to

Chandler Carruth via llvm-commits llvm-commits at lists.llvm.org
Sat Jan 14 15:25:22 PST 2017


Author: chandlerc
Date: Sat Jan 14 17:25:22 2017
New Revision: 292037

URL: http://llvm.org/viewvc/llvm-project?rev=292037&view=rev
Log:
[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.

Added:
    llvm/trunk/test/Transforms/InstCombine/preserved-analyses.ll
Modified:
    llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp

Modified: llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp?rev=292037&r1=292036&r2=292037&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp Sat Jan 14 17:25:22 2017
@@ -3178,7 +3178,10 @@ PreservedAnalyses InstCombinePass::run(F
   // Mark all the analyses that instcombine updates as preserved.
   // FIXME: This should also 'preserve the CFG'.
   PreservedAnalyses PA;
+  PA.preserve<AAManager>();
+  PA.preserve<AssumptionAnalysis>();
   PA.preserve<DominatorTreeAnalysis>();
+  PA.preserve<GlobalsAA>();
   return PA;
 }
 

Added: llvm/trunk/test/Transforms/InstCombine/preserved-analyses.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/preserved-analyses.ll?rev=292037&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/preserved-analyses.ll (added)
+++ llvm/trunk/test/Transforms/InstCombine/preserved-analyses.ll Sat Jan 14 17:25:22 2017
@@ -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<globals-aa>,function(require<aa>,instcombine),function(require<aa>)' \
+; 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<domtree>,instcombine,require<domtree>' \
+; 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
+}




More information about the llvm-commits mailing list