5
5
// CHECK: sil_global @counter : $Int32
6
6
7
7
// CHECK: sil hidden @$s4main10getCounters5Int32VyF : $@convention(thin) () -> Int32
8
- // CHECK: %0 = global_addr @counter : $*Int32
9
- // CHECK: begin_access [read] [dynamic] %0 : $*Int32
8
+ // CHECK: [[COUNTER:%.*]] = global_addr @counter : $*Int32
9
+ // CHECK: [[ACCESS:%.*]] = begin_access [read] [dynamic] [[COUNTER]] : $*Int32
10
+ // CHECK: [[LOAD:%.*]] = load [[ACCESS]] : $*Int32
11
+ // CHECK: return [[LOAD]] : $Int32
10
12
11
13
// CHECK: sil hidden @$s4main10setCounteryys5Int32VF : $@convention(thin) (Int32) -> ()
12
- // CHECK: %1 = global_addr @counter : $*Int32
13
- // CHECK: %3 = begin_access [modify] [dynamic] %1 : $*Int32
14
+ // CHECK: [[COUNTER:%.*]] = global_addr @counter : $*Int32
15
+ // CHECK: [[ACCESS:%.*]] = begin_access [modify] [dynamic] [[COUNTER]] : $*Int32
16
+ // CHECK: store %0 to [[ACCESS]] : $*Int32
14
17
15
18
// sil hidden @$s4main20getNamespacedCounters5Int32VyF : $@convention(thin) () -> Int32
16
19
//FIXME mangle non-top-level var names to prevent name collisions
17
20
// %0 = global_addr @Namespaced.counter : $*Int32
18
- // CHECK: begin_access [read] [dynamic] %0 : $*Int32
21
+ // CHECK: [[ACCESS:%.*]] = begin_access [read] [dynamic] %0 : $*Int32
22
+ // CHECK: [[LOAD:%.*]] = load [[ACCESS]] : $*Int32
23
+ // CHECK: return [[LOAD]] : $Int32
19
24
20
25
// CHECK: sil hidden @$s4main20setNamespacedCounteryys5Int32VF : $@convention(thin) (Int32) -> ()
21
26
//FIXME mangle non-top-level var names to prevent name collisions
22
27
// %1 = global_addr @Namespaced.counter : $*Int32
23
- // CHECK: %4 = begin_access [modify] [dynamic] %1 : $*Int32
28
+ // CHECK: [[ACCESS:%.*]] = begin_access [modify] [dynamic] %1 : $*Int32
29
+ // CHECK: store %0 to [[ACCESS]] : $*Int32
30
+
31
+ // CHECK: sil hidden @$s4main17passingVarAsInoutyyF : $@convention(thin) () -> ()
32
+ // CHECK: [[COUNTER:%.*]] = global_addr @counter : $*Int32
33
+ // CHECK: [[ACCESS:%.*]] = begin_access [modify] [dynamic] [[COUNTER]] : $*Int32
34
+ // CHECK: [[FUNCTION:%.*]] = function_ref @$s4main11modifyInoutyys5Int32VzF : $@convention(thin) (@inout Int32) -> ()
35
+ // CHECK: apply [[FUNCTION]]([[ACCESS]]) : $@convention(thin) (@inout Int32) -> ()
24
36
25
37
import ExternVar
26
38
@@ -39,3 +51,11 @@ func getNamespacedCounter() -> CInt {
39
51
func setNamespacedCounter( _ c: CInt ) {
40
52
Namespaced . counter = c
41
53
}
54
+
55
+ func modifyInout( _ c: inout CInt ) {
56
+ c = 42
57
+ }
58
+
59
+ func passingVarAsInout( ) {
60
+ modifyInout ( & counter)
61
+ }
0 commit comments