diff --git a/llvm/lib/Passes/StandardInstrumentations.cpp b/llvm/lib/Passes/StandardInstrumentations.cpp --- a/llvm/lib/Passes/StandardInstrumentations.cpp +++ b/llvm/lib/Passes/StandardInstrumentations.cpp @@ -346,6 +346,13 @@ template void ChangeReporter::saveIRBeforePass(Any IR, StringRef PassID, StringRef PassName) { + // Is this the initial IR? + if (InitialIR) { + InitialIR = false; + if (VerboseMode) + handleInitialIR(IR); + } + // Always need to place something on the stack because invalidated passes // are not given the IR so it cannot be determined whether the pass was for // something that was filtered out. @@ -353,12 +360,6 @@ if (!isInteresting(IR, PassID, PassName)) return; - // Is this the initial IR? - if (InitialIR) { - InitialIR = false; - if (VerboseMode) - handleInitialIR(IR); - } // Save the IR representation on the stack. T &Data = BeforeStack.back(); diff --git a/llvm/test/Other/ChangePrinters/DotCfg/print-changed-dot-cfg.ll b/llvm/test/Other/ChangePrinters/DotCfg/print-changed-dot-cfg.ll --- a/llvm/test/Other/ChangePrinters/DotCfg/print-changed-dot-cfg.ll +++ b/llvm/test/Other/ChangePrinters/DotCfg/print-changed-dot-cfg.ll @@ -5,7 +5,7 @@ ; Simple functionality check. ; RUN: rm -rf %t && mkdir -p %t ; RUN: opt -disable-verify -S -print-changed=dot-cfg -passes=instsimplify -dot-cfg-dir=%t < %s -o /dev/null -; RUN: ls %t/*.pdf %t/passes.html | count 4 +; RUN: ls %t/*.pdf %t/passes.html | count 5 ; RUN: FileCheck %s -input-file=%t/passes.html --check-prefix=CHECK-DOT-CFG-SIMPLE ; ; Check that only the passes that change the IR are printed and that the @@ -19,25 +19,25 @@ ; -print-module-scope ; RUN: rm -rf %t && mkdir -p %t ; RUN: opt -disable-verify -S -print-changed=dot-cfg -passes=instsimplify -print-module-scope -dot-cfg-dir=%t < %s -o /dev/null -; RUN: ls %t/*.pdf %t/passes.html | count 4 +; RUN: ls %t/*.pdf %t/passes.html | count 5 ; RUN: FileCheck %s -input-file=%t/passes.html --check-prefix=CHECK-DOT-CFG-PRINT-MOD-SCOPE ; ; Check that reporting of multiple functions happens ; RUN: rm -rf %t && mkdir -p %t ; RUN: opt -disable-verify -S -print-changed=dot-cfg -passes=instsimplify -filter-print-funcs="f,g" -dot-cfg-dir=%t < %s -o /dev/null -; RUN: ls %t/*.pdf %t/passes.html | count 4 +; RUN: ls %t/*.pdf %t/passes.html | count 5 ; RUN: FileCheck %s -input-file=%t/passes.html --check-prefix=CHECK-DOT-CFG-FILTER-MULT-FUNC ; ; Check that the reporting of IRs respects -filter-passes ; RUN: rm -rf %t && mkdir -p %t ; RUN: opt -disable-verify -S -print-changed=dot-cfg -passes="instsimplify,no-op-function" -filter-passes="no-op-function" -dot-cfg-dir=%t < %s -o /dev/null -; RUN: ls %t/*.pdf %t/passes.html | count 2 +; RUN: ls %t/*.pdf %t/passes.html | count 3 ; RUN: FileCheck %s -input-file=%t/passes.html --check-prefix=CHECK-DOT-CFG-FILTER-PASSES ; ; Check that the reporting of IRs respects -filter-passes with multiple passes ; RUN: rm -rf %t && mkdir -p %t ; RUN: opt -disable-verify -S -print-changed=dot-cfg -passes="instsimplify,no-op-function" -filter-passes="no-op-function,instsimplify" -dot-cfg-dir=%t < %s -o /dev/null -; RUN: ls %t/*.pdf %t/passes.html | count 4 +; RUN: ls %t/*.pdf %t/passes.html | count 5 ; RUN: FileCheck %s -input-file=%t/passes.html --check-prefix=CHECK-DOT-CFG-FILTER-MULT-PASSES ; ; Check that the reporting of IRs respects both -filter-passes and -filter-print-funcs @@ -126,7 +126,8 @@ ; CHECK-DOT-CFG-SIMPLE-NEXT: ; CHECK-DOT-CFG-SIMPLE-NEXT:
; CHECK-DOT-CFG-SIMPLE-NEXT:

-; CHECK-DOT-CFG-SIMPLE-NEXT: 0. Initial IR
+; CHECK-DOT-CFG-SIMPLE-NEXT: 0.0. Initial IR
+; CHECK-DOT-CFG-SIMPLE-NEXT: 0.1. Initial IR
; CHECK-DOT-CFG-SIMPLE-NEXT:

; CHECK-DOT-CFG-SIMPLE-NEXT:

; CHECK-DOT-CFG-SIMPLE-NEXT: 1. Pass InstSimplifyPass on g
@@ -140,14 +141,14 @@ ; CHECK-DOT-CFG-SIMPLE-NEXT: ; CHECK-DOT-CFG-FUNC-FILTER: passes.html -; CHECK-DOT-CFG-FUNC-FILTER-NEXT: 0. Pass InstSimplifyPass on g filtered out
-; CHECK-DOT-CFG-FUNC-FILTER-NEXT: 1. PassManager{{.*}} on g ignored
-; CHECK-DOT-CFG-FUNC-FILTER-NEXT: +; CHECK-DOT-CFG-FUNC-FILTER-NEXT: ; CHECK-DOT-CFG-FUNC-FILTER-NEXT:
; CHECK-DOT-CFG-FUNC-FILTER-NEXT:

-; CHECK-DOT-CFG-FUNC-FILTER-NEXT: 2. Initial IR
+; CHECK-DOT-CFG-FUNC-FILTER-NEXT: 0.0. Initial IR
; CHECK-DOT-CFG-FUNC-FILTER-NEXT:

; CHECK-DOT-CFG-FUNC-FILTER-NEXT:

+; CHECK-DOT-CFG-FUNC-FILTER-NEXT: 1. Pass InstSimplifyPass on g filtered out
+; CHECK-DOT-CFG-FUNC-FILTER-NEXT: 2. PassManager{{.*}} on g ignored
; CHECK-DOT-CFG-FUNC-FILTER-NEXT: 3. Pass InstSimplifyPass on f
; CHECK-DOT-CFG-FUNC-FILTER-NEXT:

; CHECK-DOT-CFG-FUNC-FILTER-NEXT: 4. PassManager{{.*}} on f ignored
@@ -159,7 +160,8 @@ ; CHECK-DOT-CFG-PRINT-MOD-SCOPE-NEXT: ; CHECK-DOT-CFG-PRINT-MOD-SCOPE-NEXT:
; CHECK-DOT-CFG-PRINT-MOD-SCOPE-NEXT:

-; CHECK-DOT-CFG-PRINT-MOD-SCOPE-NEXT: 0. Initial IR
+; CHECK-DOT-CFG-PRINT-MOD-SCOPE-NEXT: 0.0. Initial IR
+; CHECK-DOT-CFG-PRINT-MOD-SCOPE-NEXT: 0.1. Initial IR
; CHECK-DOT-CFG-PRINT-MOD-SCOPE-NEXT:

; CHECK-DOT-CFG-PRINT-MOD-SCOPE-NEXT:

; CHECK-DOT-CFG-PRINT-MOD-SCOPE-NEXT: 1. Pass InstSimplifyPass on g
@@ -176,7 +178,8 @@ ; CHECK-DOT-CFG-FILTER-MULT-FUNC-NEXT: ; CHECK-DOT-CFG-FILTER-MULT-FUNC-NEXT:
; CHECK-DOT-CFG-FILTER-MULT-FUNC-NEXT:

-; CHECK-DOT-CFG-FILTER-MULT-FUNC-NEXT: 0. Initial IR
+; CHECK-DOT-CFG-FILTER-MULT-FUNC-NEXT: 0.0. Initial IR
+; CHECK-DOT-CFG-FILTER-MULT-FUNC-NEXT: 0.1. Initial IR
; CHECK-DOT-CFG-FILTER-MULT-FUNC-NEXT:

; CHECK-DOT-CFG-FILTER-MULT-FUNC-NEXT:

; CHECK-DOT-CFG-FILTER-MULT-FUNC-NEXT: 1. Pass InstSimplifyPass on g
@@ -190,13 +193,14 @@ ; CHECK-DOT-CFG-FILTER-MULT-FUNC-NEXT: ; CHECK-DOT-CFG-FILTER-PASSES: passes.html -; CHECK-DOT-CFG-FILTER-PASSES-NEXT: 0. Pass InstSimplifyPass on g filtered out
-; CHECK-DOT-CFG-FILTER-PASSES-NEXT: +; CHECK-DOT-CFG-FILTER-PASSES-NEXT: ; CHECK-DOT-CFG-FILTER-PASSES-NEXT:
; CHECK-DOT-CFG-FILTER-PASSES-NEXT:

-; CHECK-DOT-CFG-FILTER-PASSES-NEXT: 1. Initial IR
+; CHECK-DOT-CFG-FILTER-PASSES-NEXT: 0.0. Initial IR
+; CHECK-DOT-CFG-FILTER-PASSES-NEXT: 0.1. Initial IR
; CHECK-DOT-CFG-FILTER-PASSES-NEXT:

; CHECK-DOT-CFG-FILTER-PASSES-NEXT:

+; CHECK-DOT-CFG-FILTER-PASSES-NEXT: 1. Pass InstSimplifyPass on g filtered out
; CHECK-DOT-CFG-FILTER-PASSES-NEXT: 2. Pass NoOpFunctionPass on g omitted because no change
; CHECK-DOT-CFG-FILTER-PASSES-NEXT: 3. PassManager{{.*}} on g ignored
; CHECK-DOT-CFG-FILTER-PASSES-NEXT: 4. Pass InstSimplifyPass on f filtered out
@@ -212,7 +216,8 @@ ; CHECK-DOT-CFG-FILTER-MULT-PASSES-NEXT: ; CHECK-DOT-CFG-FILTER-MULT-PASSES-NEXT:
; CHECK-DOT-CFG-FILTER-MULT-PASSES-NEXT:

-; CHECK-DOT-CFG-FILTER-MULT-PASSES-NEXT: 0. Initial IR
+; CHECK-DOT-CFG-FILTER-MULT-PASSES-NEXT: 0.0. Initial IR
+; CHECK-DOT-CFG-FILTER-MULT-PASSES-NEXT: 0.1. Initial IR
; CHECK-DOT-CFG-FILTER-MULT-PASSES-NEXT:

; CHECK-DOT-CFG-FILTER-MULT-PASSES-NEXT:

; CHECK-DOT-CFG-FILTER-MULT-PASSES-NEXT: 1. Pass InstSimplifyPass on g
@@ -228,15 +233,15 @@ ; CHECK-DOT-CFG-FILTER-MULT-PASSES-NEXT: ; CHECK-DOT-CFG-FILTER-FUNC-PASSES: passes.html -; CHECK-DOT-CFG-FILTER-FUNC-PASSES-NEXT: 0. Pass InstSimplifyPass on g filtered out
-; CHECK-DOT-CFG-FILTER-FUNC-PASSES-NEXT: 1. Pass NoOpFunctionPass on g filtered out
-; CHECK-DOT-CFG-FILTER-FUNC-PASSES-NEXT: 2. PassManager{{.*}} on g ignored
; CHECK-DOT-CFG-FILTER-FUNC-PASSES-NEXT: ; CHECK-DOT-CFG-FILTER-FUNC-PASSES-NEXT:
; CHECK-DOT-CFG-FILTER-FUNC-PASSES-NEXT:

-; CHECK-DOT-CFG-FILTER-FUNC-PASSES-NEXT: 3. Initial IR
+; CHECK-DOT-CFG-FILTER-FUNC-PASSES-NEXT: 0.0. Initial IR
; CHECK-DOT-CFG-FILTER-FUNC-PASSES-NEXT:

; CHECK-DOT-CFG-FILTER-FUNC-PASSES-NEXT:

+; CHECK-DOT-CFG-FILTER-FUNC-PASSES-NEXT: 1. Pass InstSimplifyPass on g filtered out
+; CHECK-DOT-CFG-FILTER-FUNC-PASSES-NEXT: 2. Pass NoOpFunctionPass on g filtered out
+; CHECK-DOT-CFG-FILTER-FUNC-PASSES-NEXT: 3. PassManager{{.*}} on g ignored
; CHECK-DOT-CFG-FILTER-FUNC-PASSES-NEXT: 4. Pass InstSimplifyPass on f
; CHECK-DOT-CFG-FILTER-FUNC-PASSES-NEXT:

; CHECK-DOT-CFG-FILTER-FUNC-PASSES-NEXT: 5. Pass NoOpFunctionPass on f omitted because no change
@@ -247,15 +252,15 @@ ; CHECK-DOT-CFG-MULT-PASSES-FILTER-FUNC: passes.html -; CHECK-DOT-CFG-MULT-PASSES-FILTER-FUNC-NEXT: 0. Pass InstSimplifyPass on g filtered out
-; CHECK-DOT-CFG-MULT-PASSES-FILTER-FUNC-NEXT: 1. Pass InstSimplifyPass on g filtered out
-; CHECK-DOT-CFG-MULT-PASSES-FILTER-FUNC-NEXT: 2. PassManager{{.*}} on g ignored
; CHECK-DOT-CFG-MULT-PASSES-FILTER-FUNC-NEXT: ; CHECK-DOT-CFG-MULT-PASSES-FILTER-FUNC-NEXT:
; CHECK-DOT-CFG-MULT-PASSES-FILTER-FUNC-NEXT:

-; CHECK-DOT-CFG-MULT-PASSES-FILTER-FUNC-NEXT: 3. Initial IR
+; CHECK-DOT-CFG-MULT-PASSES-FILTER-FUNC-NEXT: 0.0. Initial IR
; CHECK-DOT-CFG-MULT-PASSES-FILTER-FUNC-NEXT:

; CHECK-DOT-CFG-MULT-PASSES-FILTER-FUNC-NEXT:

+; CHECK-DOT-CFG-MULT-PASSES-FILTER-FUNC-NEXT: 1. Pass InstSimplifyPass on g filtered out
+; CHECK-DOT-CFG-MULT-PASSES-FILTER-FUNC-NEXT: 2. Pass InstSimplifyPass on g filtered out
+; CHECK-DOT-CFG-MULT-PASSES-FILTER-FUNC-NEXT: 3. PassManager{{.*}} on g ignored
; CHECK-DOT-CFG-MULT-PASSES-FILTER-FUNC-NEXT: 4. Pass InstSimplifyPass on f
; CHECK-DOT-CFG-MULT-PASSES-FILTER-FUNC-NEXT:

; CHECK-DOT-CFG-MULT-PASSES-FILTER-FUNC-NEXT: 5. Pass InstSimplifyPass on f omitted because no change
diff --git a/llvm/test/Other/ChangePrinters/print-changed-diff.ll b/llvm/test/Other/ChangePrinters/print-changed-diff.ll --- a/llvm/test/Other/ChangePrinters/print-changed-diff.ll +++ b/llvm/test/Other/ChangePrinters/print-changed-diff.ll @@ -212,8 +212,8 @@ ; CHECK-DIFF-FILTER-MULT-FUNC: *** IR Dump After VerifierPass on [module] omitted because no change *** ; CHECK-DIFF-FILTER-MULT-FUNC: *** IR Dump After PrintModulePass on [module] omitted because no change *** -; CHECK-DIFF-FILTER-PASSES: *** IR Dump After InstSimplifyPass on g filtered out *** ; CHECK-DIFF-FILTER-PASSES: *** IR Dump At Start *** +; CHECK-DIFF-FILTER-PASSES: *** IR Dump After InstSimplifyPass on g filtered out *** ; CHECK-DIFF-FILTER-PASSES: *** IR Dump After NoOpFunctionPass on g omitted because no change *** ; CHECK-DIFF-FILTER-PASSES: *** IR Dump After InstSimplifyPass on f filtered out *** ; CHECK-DIFF-FILTER-PASSES: *** IR Dump After NoOpFunctionPass on f omitted because no change *** @@ -234,9 +234,9 @@ ; CHECK-DIFF-FILTER-MULT-PASSES:+ ret i32 5 ; CHECK-DIFF-FILTER-MULT-PASSES: *** IR Dump After NoOpFunctionPass on f omitted because no change *** +; CHECK-DIFF-FILTER-FUNC-PASSES: *** IR Dump At Start *** ; CHECK-DIFF-FILTER-FUNC-PASSES: *** IR Dump After InstSimplifyPass on g filtered out *** ; CHECK-DIFF-FILTER-FUNC-PASSES: *** IR Dump After NoOpFunctionPass on g filtered out *** -; CHECK-DIFF-FILTER-FUNC-PASSES: *** IR Dump At Start *** ; CHECK-DIFF-FILTER-FUNC-PASSES: *** IR Dump After InstSimplifyPass on f *** ; CHECK-DIFF-FILTER-FUNC-PASSES-NOT: ModuleID = {{.+}} ; CHECK-DIFF-FILTER-FUNC-PASSES: entry: @@ -425,8 +425,8 @@ ; CHECK-CDIFF-FILTER-MULT-FUNC: *** IR Dump After VerifierPass on [module] omitted because no change *** ; CHECK-CDIFF-FILTER-MULT-FUNC: *** IR Dump After PrintModulePass on [module] omitted because no change *** -; CHECK-CDIFF-FILTER-PASSES: *** IR Dump After InstSimplifyPass on g filtered out *** ; CHECK-CDIFF-FILTER-PASSES: *** IR Dump At Start *** +; CHECK-CDIFF-FILTER-PASSES: *** IR Dump After InstSimplifyPass on g filtered out *** ; CHECK-CDIFF-FILTER-PASSES: *** IR Dump After NoOpFunctionPass on g omitted because no change *** ; CHECK-CDIFF-FILTER-PASSES: *** IR Dump After InstSimplifyPass on f filtered out *** ; CHECK-CDIFF-FILTER-PASSES: *** IR Dump After NoOpFunctionPass on f omitted because no change *** @@ -447,9 +447,9 @@ ; CHECK-CDIFF-FILTER-MULT-PASSES:{{.\[32m\+}} ret i32 5{{.\[0m}} ; CHECK-CDIFF-FILTER-MULT-PASSES: *** IR Dump After NoOpFunctionPass on f omitted because no change *** +; CHECK-CDIFF-FILTER-FUNC-PASSES: *** IR Dump At Start *** ; CHECK-CDIFF-FILTER-FUNC-PASSES: *** IR Dump After InstSimplifyPass on g filtered out *** ; CHECK-CDIFF-FILTER-FUNC-PASSES: *** IR Dump After NoOpFunctionPass on g filtered out *** -; CHECK-CDIFF-FILTER-FUNC-PASSES: *** IR Dump At Start *** ; CHECK-CDIFF-FILTER-FUNC-PASSES: *** IR Dump After InstSimplifyPass on f *** ; CHECK-CDIFF-FILTER-FUNC-PASSES-NOT: ModuleID = {{.+}} ; CHECK-CDIFF-FILTER-FUNC-PASSES: entry: diff --git a/llvm/test/Other/change-printer.ll b/llvm/test/Other/change-printer.ll --- a/llvm/test/Other/change-printer.ll +++ b/llvm/test/Other/change-printer.ll @@ -147,9 +147,9 @@ ; CHECK-FILTER-MULT-FUNC: *** IR Dump After InstSimplifyPass on f *** ; CHECK-FILTER-MULT-FUNC-NEXT: define i32 @f() -; CHECK-FILTER-PASSES: *** IR Dump After InstSimplifyPass on g filtered out *** ; CHECK-FILTER-PASSES: *** IR Dump At Start *** ; CHECK-FILTER-PASSES-NEXT: ; ModuleID = {{.+}} +; CHECK-FILTER-PASSES: *** IR Dump After InstSimplifyPass on g filtered out *** ; CHECK-FILTER-PASSES: *** IR Dump After NoOpFunctionPass on g omitted because no change *** ; CHECK-FILTER-PASSES: *** IR Dump After InstSimplifyPass on f filtered out *** ; CHECK-FILTER-PASSES: *** IR Dump After NoOpFunctionPass on f omitted because no change *** @@ -163,18 +163,18 @@ ; CHECK-FILTER-MULT-PASSES-NEXT: define i32 @f() ; CHECK-FILTER-MULT-PASSES: *** IR Dump After NoOpFunctionPass on f omitted because no change *** -; CHECK-FILTER-FUNC-PASSES: *** IR Dump After InstSimplifyPass on g filtered out *** -; CHECK-FILTER-FUNC-PASSES: *** IR Dump After NoOpFunctionPass on g filtered out *** ; CHECK-FILTER-FUNC-PASSES: *** IR Dump At Start *** ; CHECK-FILTER-FUNC-PASSES-NEXT: ; ModuleID = {{.+}} +; CHECK-FILTER-FUNC-PASSES: *** IR Dump After InstSimplifyPass on g filtered out *** +; CHECK-FILTER-FUNC-PASSES: *** IR Dump After NoOpFunctionPass on g filtered out *** ; CHECK-FILTER-FUNC-PASSES: *** IR Dump After InstSimplifyPass on f *** ; CHECK-FILTER-FUNC-PASSES-NEXT: define i32 @f() ; CHECK-FILTER-FUNC-PASSES: *** IR Dump After NoOpFunctionPass on f omitted because no change *** -; CHECK-FILTER-FUNC-PASSES-MOD-SCOPE: *** IR Dump After InstSimplifyPass on g filtered out *** -; CHECK-FILTER-FUNC-PASSES-MOD-SCOPE: *** IR Dump After NoOpFunctionPass on g filtered out *** ; CHECK-FILTER-FUNC-PASSES-MOD-SCOPE: *** IR Dump At Start *** ; CHECK-FILTER-FUNC-PASSES-MOD-SCOPE-NEXT: ; ModuleID = {{.+}} +; CHECK-FILTER-FUNC-PASSES-MOD-SCOPE: *** IR Dump After InstSimplifyPass on g filtered out *** +; CHECK-FILTER-FUNC-PASSES-MOD-SCOPE: *** IR Dump After NoOpFunctionPass on g filtered out *** ; CHECK-FILTER-FUNC-PASSES-MOD-SCOPE: *** IR Dump After InstSimplifyPass on f *** ; CHECK-FILTER-FUNC-PASSES-MOD-SCOPE-NEXT: ModuleID = {{.+}} ; CHECK-FILTER-FUNC-PASSES-MOD-SCOPE: *** IR Dump After NoOpFunctionPass on f omitted because no change ***