Skip to content

Commit abcb0d6

Browse files
authored
Merge pull request #77805 from eeckstein/sil-printer2
SILPrinter: don't print operand types in static initializers of globals
2 parents ca50c55 + a133497 commit abcb0d6

File tree

8 files changed

+28
-9
lines changed

8 files changed

+28
-9
lines changed

lib/SIL/IR/SILPrinter.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,10 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
809809
/*needPrintType=*/true};
810810
}
811811

812+
void markBlockAsPrinted(const SILBasicBlock *block) {
813+
printedBlocks.insert(block);
814+
}
815+
812816
//===--------------------------------------------------------------------===//
813817
// Big entrypoints.
814818
void print(const SILFunction *F) {
@@ -932,7 +936,7 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
932936
#endif
933937

934938
void print(const SILBasicBlock *BB) {
935-
printedBlocks.insert(BB);
939+
markBlockAsPrinted(BB);
936940

937941
// Output uses for BB arguments. These are put into place as comments before
938942
// the block header.
@@ -3677,6 +3681,7 @@ void SILGlobalVariable::print(llvm::raw_ostream &OS, bool Verbose) const {
36773681
{
36783682
SILPrintContext Ctx(OS);
36793683
SILPrinter Printer(Ctx);
3684+
Printer.markBlockAsPrinted(&StaticInitializerBlock);
36803685
for (const SILInstruction &I : StaticInitializerBlock) {
36813686
Printer.print(&I);
36823687
}

test/Concurrency/global_function_pointer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend -enable-experimental-feature SymbolLinkageMarkers -emit-sil -target %target-swift-5.1-abi-triple -parse-as-library %s | %FileCheck %s --check-prefix=CHECK-SIL
1+
// RUN: %target-swift-frontend -enable-experimental-feature SymbolLinkageMarkers -Xllvm -sil-print-types -emit-sil -target %target-swift-5.1-abi-triple -parse-as-library %s | %FileCheck %s --check-prefix=CHECK-SIL
22
// RUN: %target-build-swift -enable-experimental-feature SymbolLinkageMarkers -target %target-swift-5.1-abi-triple -Xfrontend -parse-as-library %s -o %t_binary
33
// RUN: %target-codesign %t_binary
44
// RUN: %target-run %t_binary | %FileCheck %s --check-prefix=CHECK-EXEC

test/SIL/Parser/pure_mode.sil

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,20 @@ import SwiftShims
88

99
sil_global hidden @$s3nix2ggSSvp : $String
1010

11+
class C {
12+
@_hasStorage var a: Builtin.Int64
13+
@_hasStorage var b: Builtin.Int64
14+
}
15+
16+
sil_global [let] @gc : $C = {
17+
%0 = integer_literal $Builtin.Int64, 0
18+
%1 = integer_literal $Builtin.Int64, 1
19+
%2 = integer_literal $Builtin.Int64, 2
20+
%3 = integer_literal $Builtin.Int64, 3
21+
// CHECK: %initval = object $C (%0, %1, [tail_elems] %2, %3)
22+
%initval = object $C (%0, %1, [tail_elems] %2, %3)
23+
}
24+
1125
sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 {
1226
[%1: noescape **]
1327
[global: read,write,copy,deinit_barrier]

test/SIL/Parser/static_initializer.sil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-sil-opt %s | %FileCheck %s
1+
// RUN: %target-sil-opt -sil-print-types %s | %FileCheck %s
22

33
// Generated from
44
// var x : Int32 = 2

test/SIL/Serialization/globals.sil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: %empty-directory(%t)
22
// RUN: %target-swift-frontend %s -Xllvm -sil-disable-pass=simplification -emit-module -o %t/tmp.swiftmodule
3-
// RUN: %target-sil-opt %t/tmp.swiftmodule | %FileCheck %s
3+
// RUN: %target-sil-opt -sil-print-types %t/tmp.swiftmodule | %FileCheck %s
44

55
sil_stage canonical
66

test/SILOptimizer/global-functionptr.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
// Second test (bonus): check if the optimization is done: statically initialize the array of function pointers.
1414

15-
// RUN: %target-build-swift -O -wmo -parse-as-library -module-name=Test %s -emit-sil | %FileCheck %s -check-prefix=CHECK-SIL
15+
// RUN: %target-build-swift -O -wmo -parse-as-library -module-name=Test %s -Xllvm -sil-print-types -emit-sil | %FileCheck %s -check-prefix=CHECK-SIL
1616

1717
// REQUIRES: executable_test
1818
// REQUIRES: swift_stdlib_no_asserts,optimized_stdlib

test/SILOptimizer/globalopt_resilience_testing.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %target-swift-frontend -emit-sil -O -enable-library-evolution -primary-file %s | %FileCheck %s
2-
// RUN: %target-swift-frontend -emit-sil -O -enable-library-evolution -enable-testing -primary-file %s | %FileCheck %s --check-prefix=CHECK-TESTING
1+
// RUN: %target-swift-frontend -Xllvm -sil-print-types -emit-sil -O -enable-library-evolution -primary-file %s | %FileCheck %s
2+
// RUN: %target-swift-frontend -Xllvm -sil-print-types -emit-sil -O -enable-library-evolution -enable-testing -primary-file %s | %FileCheck %s --check-prefix=CHECK-TESTING
33

44
// REQUIRES: swift_in_compiler
55

test/SILOptimizer/optionset.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %target-swift-frontend -parse-as-library -primary-file %s -O -sil-verify-all -module-name=test -emit-sil | grep -v debug_value | %FileCheck %s
2-
// RUN: %target-swift-frontend -parse-as-library -primary-file %s -Osize -sil-verify-all -module-name=test -emit-sil | grep -v debug_value | %FileCheck %s
1+
// RUN: %target-swift-frontend -parse-as-library -primary-file %s -O -sil-verify-all -module-name=test -Xllvm -sil-print-types -emit-sil | grep -v debug_value | %FileCheck %s
2+
// RUN: %target-swift-frontend -parse-as-library -primary-file %s -Osize -sil-verify-all -module-name=test -Xllvm -sil-print-types -emit-sil | grep -v debug_value | %FileCheck %s
33
// REQUIRES: swift_stdlib_no_asserts,optimized_stdlib
44
// REQUIRES: swift_in_compiler
55

0 commit comments

Comments
 (0)