|
1 |
| -// RUN: %target-sil-opt -enable-sil-verify-all %s -initialize-static-globals | %FileCheck %s |
| 1 | +// RUN: %target-sil-opt -enable-sil-verify-all %s -enable-experimental-feature RawLayout -initialize-static-globals | %FileCheck %s |
2 | 2 |
|
3 | 3 | // REQUIRES: swift_in_compiler
|
| 4 | +// REQUIRES: swift_feature_RawLayout |
4 | 5 |
|
5 | 6 | sil_stage canonical
|
6 | 7 |
|
@@ -36,6 +37,12 @@ struct TwoFields {
|
36 | 37 | let b: Int32
|
37 | 38 | }
|
38 | 39 |
|
| 40 | +@_rawLayout(like: Int32) |
| 41 | +struct Raw: ~Copyable {} |
| 42 | + |
| 43 | +@_rawLayout(likeArrayOf: Int32, count: 2) |
| 44 | +struct RawArray: ~Copyable {} |
| 45 | + |
39 | 46 | let nontrivialglobal: TClass
|
40 | 47 |
|
41 | 48 | // CHECK-LABEL: sil_global hidden [let] @$trivialglobal : $TStruct = {
|
@@ -149,6 +156,18 @@ sil_global [let] @inline_array_empty_elements : $InlineArray<3, ()>
|
149 | 156 | // CHECK-NEXT: }
|
150 | 157 | sil_global [let] @gint : $Int32
|
151 | 158 |
|
| 159 | +// CHECK-LABEL: sil_global [let] @graw : $Raw = { |
| 160 | +// CHECK-NEXT: %0 = integer_literal $Builtin.Int32, 1 |
| 161 | +// CHECK-NEXT: %initval = struct $Int32 (%0) |
| 162 | +// CHECK-NEXT: } |
| 163 | +sil_global [let] @graw: $Raw |
| 164 | + |
| 165 | +// CHECK-LABEL: sil_global [let] @graw2 : $Raw{{$}} |
| 166 | +sil_global [let] @graw2: $Raw |
| 167 | + |
| 168 | +// CHECK-LABEL: sil_global [let] @grawArray : $RawArray{{$}} |
| 169 | +sil_global [let] @grawArray: $RawArray |
| 170 | + |
152 | 171 | sil @unknownfunc : $@convention(thin) () -> ()
|
153 | 172 |
|
154 | 173 | // CHECK-LABEL: sil [global_init_once_fn] [ossa] @globalinit_trivialglobal_func :
|
@@ -521,3 +540,42 @@ bb0(%0 : $Builtin.RawPointer):
|
521 | 540 | return %21
|
522 | 541 | }
|
523 | 542 |
|
| 543 | +sil [global_init_once_fn] [ossa] @globalinit_raw_layout: $@convention(c) (Builtin.RawPointer) -> () { |
| 544 | +bb0(%0 : $Builtin.RawPointer): |
| 545 | + alloc_global @graw |
| 546 | + %2 = global_addr @graw : $*Raw |
| 547 | + %3 = integer_literal $Builtin.Int32, 1 |
| 548 | + %4 = struct $Int32 (%3) |
| 549 | + %5 = builtin "addressOfRawLayout"<Raw>(%2) : $Builtin.RawPointer |
| 550 | + %6 = pointer_to_address %5 to $*Int32 |
| 551 | + store %4 to [trivial] %6 |
| 552 | + %21 = tuple () |
| 553 | + return %21 |
| 554 | +} |
| 555 | + |
| 556 | +sil [global_init_once_fn] [ossa] @no_globalinit_raw_layout_wrong_like_type: $@convention(c) (Builtin.RawPointer) -> () { |
| 557 | +bb0(%0 : $Builtin.RawPointer): |
| 558 | + alloc_global @graw |
| 559 | + %2 = global_addr @graw : $*Raw |
| 560 | + %3 = integer_literal $Builtin.Int16, 1 |
| 561 | + %4 = struct $Int16 (%3) |
| 562 | + %5 = builtin "addressOfRawLayout"<Raw>(%2) : $Builtin.RawPointer |
| 563 | + %6 = pointer_to_address %5 to $*Int16 |
| 564 | + store %4 to [trivial] %6 |
| 565 | + %21 = tuple () |
| 566 | + return %21 |
| 567 | +} |
| 568 | + |
| 569 | +sil [global_init_once_fn] [ossa] @no_globalinit_raw_layout_array: $@convention(c) (Builtin.RawPointer) -> () { |
| 570 | +bb0(%0 : $Builtin.RawPointer): |
| 571 | + alloc_global @grawArray |
| 572 | + %2 = global_addr @grawArray : $*RawArray |
| 573 | + %3 = integer_literal $Builtin.Int32, 1 |
| 574 | + %4 = struct $Int32 (%3) |
| 575 | + %5 = builtin "addressOfRawLayout"<RawArray>(%2) : $Builtin.RawPointer |
| 576 | + %6 = pointer_to_address %5 to $*Int32 |
| 577 | + store %4 to [trivial] %6 |
| 578 | + %21 = tuple () |
| 579 | + return %21 |
| 580 | +} |
| 581 | + |
0 commit comments