| // RUN: %target-swift-frontend %s -emit-ir | FileCheck %s |
| |
| // REQUIRES: CPU=x86_64 |
| |
| // Generated from |
| // var x : Int32 = 2 |
| // public func f() -> Int32 { return x } |
| // with swiftc -O -parse-as-library -emit-sil |
| |
| import Builtin |
| import Swift |
| |
| struct S { |
| var m : Int32 |
| } |
| |
| public struct S2 { |
| public var i, j : Int32 |
| var s : S |
| } |
| |
| // CHECK: %Vs5Int32 = type <{ i32 }> |
| // CHECK: %V18static_initializer2S2 = type <{ %Vs5Int32, %Vs5Int32, %V18static_initializer1S }> |
| // CHECK: %V18static_initializer1S = type <{ %Vs5Int32 }> |
| |
| sil_global @_Tv2ch1xSi : $Int32, @globalinit_func0 : $@convention(thin) () -> () |
| // CHECK: @_Tv2ch1xSi = {{(protected )?}}global %Vs5Int32 <{ i32 2 }>, align 4 |
| |
| sil_global @_Tv6nested1xVS_2S2 : $S2, @globalinit_func1 : $@convention(thin) () -> () |
| // CHECK: @_Tv6nested1xVS_2S2 = {{(protected )?}}global %V18static_initializer2S2 <{ %Vs5Int32 <{ i32 2 }>, %Vs5Int32 <{ i32 3 }>, %V18static_initializer1S <{ %Vs5Int32 <{ i32 4 }> }> }>, align 4 |
| |
| sil private @globalinit_func0 : $@convention(thin) () -> () { |
| bb0: |
| %0 = global_addr @_Tv2ch1xSi : $*Int32 |
| %1 = integer_literal $Builtin.Int32, 2 |
| %2 = struct $Int32 (%1 : $Builtin.Int32) |
| store %2 to %0 : $*Int32 |
| %4 = tuple () |
| return %4 : $() |
| } |
| |
| // CHECK-LABEL: define{{( protected)?}} i8* @_TF2cha1xSi() {{.*}} { |
| // CHECK-NEXT: entry: |
| // CHECK-NEXT: ret i8* bitcast (%Vs5Int32* @_Tv2ch1xSi to i8*) |
| sil [global_init] @_TF2cha1xSi : $@convention(thin) () -> Builtin.RawPointer { |
| bb0: |
| %0 = global_addr @_Tv2ch1xSi : $*Int32 |
| %1 = address_to_pointer %0 : $*Int32 to $Builtin.RawPointer |
| return %1 : $Builtin.RawPointer |
| } |
| |
| // CHECK-LABEL: define{{( protected)?}} i32 @_TF2ch1fFT_Si() {{.*}} { |
| // CHECK-NEXT: entry: |
| // CHECK-NEXT: load i32, i32* getelementptr inbounds (%Vs5Int32, %Vs5Int32* @_Tv2ch1xSi, i32 0, i32 0) |
| // CHECK-NEXT: ret |
| sil @_TF2ch1fFT_Si : $@convention(thin) () -> Int32 { |
| bb0: |
| %0 = global_addr @_Tv2ch1xSi : $*Int32 |
| %1 = load %0 : $*Int32 |
| return %1 : $Int32 |
| } |
| |
| sil private @globalinit_func1 : $@convention(thin) () -> () { |
| bb0: |
| %0 = global_addr @_Tv6nested1xVS_2S2 : $*S2 |
| %1 = integer_literal $Builtin.Int32, 2 |
| %2 = struct $Int32 (%1 : $Builtin.Int32) |
| %3 = integer_literal $Builtin.Int32, 3 |
| %4 = struct $Int32 (%3 : $Builtin.Int32) |
| %5 = integer_literal $Builtin.Int32, 4 |
| %6 = struct $Int32 (%5 : $Builtin.Int32) |
| %7 = struct $S (%6 : $Int32) |
| %8 = struct $S2 (%2 : $Int32, %4 : $Int32, %7 : $S) |
| store %8 to %0 : $*S2 |
| %10 = tuple () |
| return %10 : $() |
| } |
| |
| // CHECK-LABEL: define{{( protected)?}} i8* @_TF6nesteda1xVS_2S2() {{.*}} { |
| // CHECK-NEXT: entry: |
| // CHECK-NEXT: ret i8* bitcast (%V18static_initializer2S2* @_Tv6nested1xVS_2S2 to i8*) |
| sil [global_init] @_TF6nesteda1xVS_2S2 : $@convention(thin) () -> Builtin.RawPointer { |
| bb0: |
| %0 = global_addr @_Tv6nested1xVS_2S2 : $*S2 |
| %1 = address_to_pointer %0 : $*S2 to $Builtin.RawPointer |
| return %1 : $Builtin.RawPointer |
| } |
| |
| // CHECK-LABEL: define{{( protected)?}} { i32, i32, i32 } @_TF6nested1fFT_VS_2S2() {{.*}} { |
| // CHECK-NEXT: entry: |
| // CHECK-NEXT: load i32, i32* getelementptr inbounds (%V18static_initializer2S2, %V18static_initializer2S2* @_Tv6nested1xVS_2S2, i32 0, i32 0, i32 0) |
| // CHECK-NEXT: load i32, i32* getelementptr inbounds (%V18static_initializer2S2, %V18static_initializer2S2* @_Tv6nested1xVS_2S2, i32 0, i32 1, i32 0) |
| // CHECK-NEXT: load i32, i32* getelementptr inbounds (%V18static_initializer2S2, %V18static_initializer2S2* @_Tv6nested1xVS_2S2, i32 0, i32 2, i32 0, i32 0) |
| sil @_TF6nested1fFT_VS_2S2 : $@convention(thin) () -> S2 { |
| bb0: |
| %0 = global_addr @_Tv6nested1xVS_2S2 : $*S2 |
| %1 = load %0 : $*S2 |
| return %1 : $S2 |
| } |