[llvm] r335820 - [SCCP] Mark CFG as preserved.

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 28 02:53:38 PDT 2018


Author: fhahn
Date: Thu Jun 28 02:53:38 2018
New Revision: 335820

URL: http://llvm.org/viewvc/llvm-project?rev=335820&view=rev
Log:
[SCCP] Mark CFG as preserved.

SCCP does not change the CFG, so we can mark it as preserved.

Reviewers: dberlin, efriedma, davide

Reviewed By: davide

Differential Revision: https://reviews.llvm.org/D47149

Added:
    llvm/trunk/test/Transforms/SCCP/preserve-analysis.ll
Modified:
    llvm/trunk/lib/Transforms/Scalar/SCCP.cpp
    llvm/trunk/test/Other/opt-O2-pipeline.ll
    llvm/trunk/test/Other/opt-O3-pipeline.ll
    llvm/trunk/test/Other/opt-Os-pipeline.ll

Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCP.cpp?rev=335820&r1=335819&r2=335820&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/SCCP.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Thu Jun 28 02:53:38 2018
@@ -1777,6 +1777,7 @@ PreservedAnalyses SCCPPass::run(Function
 
   auto PA = PreservedAnalyses();
   PA.preserve<GlobalsAA>();
+  PA.preserveSet<CFGAnalyses>();
   return PA;
 }
 
@@ -1799,6 +1800,7 @@ public:
   void getAnalysisUsage(AnalysisUsage &AU) const override {
     AU.addRequired<TargetLibraryInfoWrapperPass>();
     AU.addPreserved<GlobalsAAWrapperPass>();
+    AU.setPreservesCFG();
   }
 
   // runOnFunction - Run the Sparse Conditional Constant Propagation

Modified: llvm/trunk/test/Other/opt-O2-pipeline.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Other/opt-O2-pipeline.ll?rev=335820&r1=335819&r2=335820&view=diff
==============================================================================
--- llvm/trunk/test/Other/opt-O2-pipeline.ll (original)
+++ llvm/trunk/test/Other/opt-O2-pipeline.ll Thu Jun 28 02:53:38 2018
@@ -132,10 +132,8 @@
 ; CHECK-NEXT:         Memory Dependence Analysis
 ; CHECK-NEXT:         MemCpy Optimization
 ; CHECK-NEXT:         Sparse Conditional Constant Propagation
-; CHECK-NEXT:         Dominator Tree Construction
 ; CHECK-NEXT:         Demanded bits analysis
 ; CHECK-NEXT:         Bit-Tracking Dead Code Elimination
-; CHECK-NEXT:         Basic Alias Analysis (stateless AA impl)
 ; CHECK-NEXT:         Function Alias Analysis Results
 ; CHECK-NEXT:         Natural Loop Information
 ; CHECK-NEXT:         Lazy Branch Probability Analysis

Modified: llvm/trunk/test/Other/opt-O3-pipeline.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Other/opt-O3-pipeline.ll?rev=335820&r1=335819&r2=335820&view=diff
==============================================================================
--- llvm/trunk/test/Other/opt-O3-pipeline.ll (original)
+++ llvm/trunk/test/Other/opt-O3-pipeline.ll Thu Jun 28 02:53:38 2018
@@ -136,10 +136,8 @@
 ; CHECK-NEXT:         Memory Dependence Analysis
 ; CHECK-NEXT:         MemCpy Optimization
 ; CHECK-NEXT:         Sparse Conditional Constant Propagation
-; CHECK-NEXT:         Dominator Tree Construction
 ; CHECK-NEXT:         Demanded bits analysis
 ; CHECK-NEXT:         Bit-Tracking Dead Code Elimination
-; CHECK-NEXT:         Basic Alias Analysis (stateless AA impl)
 ; CHECK-NEXT:         Function Alias Analysis Results
 ; CHECK-NEXT:         Natural Loop Information
 ; CHECK-NEXT:         Lazy Branch Probability Analysis

Modified: llvm/trunk/test/Other/opt-Os-pipeline.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Other/opt-Os-pipeline.ll?rev=335820&r1=335819&r2=335820&view=diff
==============================================================================
--- llvm/trunk/test/Other/opt-Os-pipeline.ll (original)
+++ llvm/trunk/test/Other/opt-Os-pipeline.ll Thu Jun 28 02:53:38 2018
@@ -118,10 +118,8 @@
 ; CHECK-NEXT:         Memory Dependence Analysis
 ; CHECK-NEXT:         MemCpy Optimization
 ; CHECK-NEXT:         Sparse Conditional Constant Propagation
-; CHECK-NEXT:         Dominator Tree Construction
 ; CHECK-NEXT:         Demanded bits analysis
 ; CHECK-NEXT:         Bit-Tracking Dead Code Elimination
-; CHECK-NEXT:         Basic Alias Analysis (stateless AA impl)
 ; CHECK-NEXT:         Function Alias Analysis Results
 ; CHECK-NEXT:         Natural Loop Information
 ; CHECK-NEXT:         Lazy Branch Probability Analysis

Added: llvm/trunk/test/Transforms/SCCP/preserve-analysis.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SCCP/preserve-analysis.ll?rev=335820&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/SCCP/preserve-analysis.ll (added)
+++ llvm/trunk/test/Transforms/SCCP/preserve-analysis.ll Thu Jun 28 02:53:38 2018
@@ -0,0 +1,36 @@
+; RUN: opt < %s -debug-pass=Structure -globals-aa -loop-vectorize -sccp -loop-vectorize -globals-aa 2>&1 -S | FileCheck %s
+; RUN: opt < %s -debug-pass-manager -passes='loop-vectorize,sccp,loop-vectorize' 2>&1 -S | FileCheck --check-prefix=NEW-PM %s
+
+; Check CFG-only analysis are preserved by SCCP by running it between 2
+; loop-vectorize runs.
+
+; CHECK: Globals Alias Analysis
+; CHECK: Dominator Tree Construction
+; CHECK: Natural Loop Information
+; CHECK: Basic Alias Analysis (stateless AA impl)
+; CHECK: Sparse Conditional Constant Propagation
+; CHECK-NOT: Dominator Tree Construction
+; CHECK-NOT: Natural Loop Information
+; CHECK-NOT: Basic Alias Analysis (stateless AA impl)
+; CHECK-NOT: Globals Alias Analysis
+; CHECK: Loop Vectorization
+
+; NEW-PM-DAG: Running analysis: LoopAnalysis on test
+; NEW-PM-DAG: Running analysis: DominatorTreeAnalysis on test
+; NEW-PM-DAG: Running analysis: AssumptionAnalysis on test
+; NEW-PM-DAG: Running analysis: TargetLibraryAnalysis on test
+; NEW-PM-DAG: Running analysis: TargetIRAnalysis on test
+; NEW-PM: Running pass: SCCPPass on test
+; NEW-PM-NOT: Running analysis: LoopAnalysis on test
+; NEW-PM-NOT: Running analysis: DominatorTreeAnalysis on test
+; NEW-PM-NOT: Running analysis: AssumptionAnalysis on test
+; NEW-PM-NOT: Running analysis: TargetLibraryAnalysis on test
+; NEW-PM-NOT: Running analysis: TargetIRAnalysis on test
+; NEW-PM: Finished llvm::Function pass manager run.
+
+
+define i32 @test() {
+entry:
+  %res = add i32 1, 10
+  ret i32 %res
+}




More information about the llvm-commits mailing list