|
1 | | -// RUN: %empty-directory(%t) |
2 | | -// RUN: %target-build-swift %s -I %S/Inputs -emit-ir -o %t/extern-var.ir -Xfrontend -enable-cxx-interop |
3 | | -// RUN: %FileCheck < %t/extern-var.ir %s |
| 1 | +// RUN: %target-swift-emit-ir %s -I %S/Inputs -enable-cxx-interop -o %t/output.ir |
| 2 | +// RUN: %target-swift-emit-ir %s -I %S/Inputs -enable-cxx-interop | %FileCheck %s |
4 | 3 |
|
5 | 4 | import ExternVar |
6 | 5 |
|
7 | | -func getCounter() -> CInt { |
| 6 | +public func getCounter() -> CInt { |
8 | 7 | return counter |
9 | 8 | } |
10 | 9 |
|
11 | 10 | // CHECK: @counter = external global i32, align 4 |
12 | 11 |
|
13 | | -// CHECK: define hidden swiftcc i32 @"$s4main10getCounters5Int32VyF"() #0 |
| 12 | +// CHECK: define protected swiftcc i32 @"$s4main10getCounters5Int32VyF"() #0 |
14 | 13 | // CHECK: [[LOAD:%.*]] = load i32, i32* getelementptr inbounds (%Ts5Int32V, %Ts5Int32V* bitcast (i32* @counter to %Ts5Int32V*), i32 0, i32 0), align 4 |
15 | 14 | // CHECK: ret i32 [[LOAD]] |
16 | 15 |
|
17 | | -func setCounter(_ c: CInt) { |
| 16 | +public func setCounter(_ c: CInt) { |
18 | 17 | counter = c |
19 | 18 | } |
20 | 19 |
|
21 | | -// CHECK: define hidden swiftcc void @"$s4main10setCounteryys5Int32VF"(i32 %0) #0 |
| 20 | +// CHECK: define protected swiftcc void @"$s4main10setCounteryys5Int32VF"(i32 %0) #0 |
22 | 21 | // CHECK: store i32 %0, i32* getelementptr inbounds (%Ts5Int32V, %Ts5Int32V* bitcast (i32* @counter to %Ts5Int32V*), i32 0, i32 0), align 4 |
23 | 22 |
|
24 | | -func getNamespacedCounter() -> CInt { |
| 23 | +public func getNamespacedCounter() -> CInt { |
25 | 24 | return Namespaced.counter |
26 | 25 | } |
27 | 26 |
|
28 | | -// CHECK: define hidden swiftcc i32 @"$s4main20getNamespacedCounters5Int32VyF"() #0 |
| 27 | +// CHECK: define protected swiftcc i32 @"$s4main20getNamespacedCounters5Int32VyF"() #0 |
29 | 28 | //FIXME mangle non-top-level var names to prevent name collisions and check: |
30 | 29 | // load i32, i32* getelementptr inbounds (%Ts5Int32V, %Ts5Int32V* bitcast (i32* @Namespaced.counter to %Ts5Int32V*), i32 0, i32 0), align 4 |
31 | 30 | // CHECK: ret i32 %1 |
32 | 31 |
|
33 | | -func setNamespacedCounter(_ c: CInt) { |
| 32 | +public func setNamespacedCounter(_ c: CInt) { |
34 | 33 | Namespaced.counter = c |
35 | 34 | } |
36 | 35 |
|
37 | | -// CHECK: define hidden swiftcc void @"$s4main20setNamespacedCounteryys5Int32VF"(i32 %0) #0 |
| 36 | +// CHECK: define protected swiftcc void @"$s4main20setNamespacedCounteryys5Int32VF"(i32 %0) #0 |
38 | 37 | //FIXME mangle non-top-level var names to prevent name collisions and check: |
39 | 38 | // store i32 %0, i32* getelementptr inbounds (%Ts5Int32V, %Ts5Int32V* bitcast (i32* @Namespaced.counter to %Ts5Int32V*), i32 0, i32 0), align 4 |
40 | 39 |
|
41 | 40 | func modifyInout(_ c: inout CInt) { |
42 | 41 | c = 42 |
43 | 42 | } |
44 | 43 |
|
45 | | -func passingVarAsInout() { |
| 44 | +public func passingVarAsInout() { |
46 | 45 | modifyInout(&counter) |
47 | 46 | } |
48 | 47 |
|
49 | | -// CHECK: define hidden swiftcc void @"$s4main17passingVarAsInoutyyF"() #0 |
| 48 | +// CHECK: define protected swiftcc void @"$s4main17passingVarAsInoutyyF"() #0 |
50 | 49 | // CHECK: call swiftcc void @"$s4main11modifyInoutyys5Int32VzF"(%Ts5Int32V* nocapture dereferenceable(4) bitcast (i32* @counter to %Ts5Int32V*)) |
51 | 50 |
|
0 commit comments