1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
// RUN: %target-sil-opt -enable-sil-verify-all -sil-print-debuginfo -sroa %s | %FileCheck --check-prefix=CHECK-SROA %s
sil_stage canonical
import Builtin
import Swift
struct MyStruct {
@_hasStorage var x: Int64 { get set }
@_hasStorage var y: Int64 { get set }
init(x: Int64, y: Int64)
}
struct MyContainer {
@_hasStorage var z: MyStruct { get set }
}
sil_scope 1 { loc "sroa.swift":2:8 parent @MyStructInit : $@convention(method) (Int64, Int64, @thin MyStruct.Type) -> MyStruct }
// MyStruct.init(x:y:)
sil hidden @MyStructInit : $@convention(method) (Int64, Int64, @thin MyStruct.Type) -> MyStruct {
bb0(%0 : $Int64, %1 : $Int64, %2 : $@thin MyStruct.Type):
%3 = struct $MyStruct (%0 : $Int64, %1 : $Int64), loc "sroa.swift":2:8, scope 1
return %3 : $MyStruct, loc "sroa.swift":2:8, scope 1
} // end sil function 'MyStructInit'
sil_scope 2 { loc "sroa.swift":7:6 parent @foo : $@convention(thin) (Int64, Int64) -> Int64 }
// foo(in_x:in_y:)
sil hidden @foo : $@convention(thin) (Int64, Int64) -> Int64 {
bb0(%0 : $Int64, %1 : $Int64):
debug_value %0 : $Int64, let, name "in_x", argno 1, loc "sroa.swift":7:10, scope 2
debug_value %1 : $Int64, let, name "in_y", argno 2, loc "sroa.swift":7:21, scope 2
%4 = alloc_stack $MyStruct, var, name "my_struct", type $*MyContainer, expr op_fragment:#MyContainer.z, loc "sroa.swift":8:9, scope 2
// CHECK-SROA: alloc_stack $Int64
// CHECK-SROA-SAME: var,
// CHECK-SROA: alloc_stack $Int64
// CHECK-SROA-SAME: var,
// CHECK-SROA: metatype
%5 = metatype $@thin MyStruct.Type, loc "sroa.swift":8:21, scope 2
%6 = integer_literal $Builtin.Int64, 0, loc "sroa.swift":8:33, scope 2
%7 = struct $Int64 (%6 : $Builtin.Int64), loc "sroa.swift":8:33, scope 2
%8 = integer_literal $Builtin.Int64, 0, loc "sroa.swift":8:39, scope 2
%9 = struct $Int64 (%8 : $Builtin.Int64), loc "sroa.swift":8:39, scope 2
// function_ref MyStruct.init(x:y:)
%10 = function_ref @MyStructInit : $@convention(method) (Int64, Int64, @thin MyStruct.Type) -> MyStruct, loc "sroa.swift":8:21, scope 2
%11 = apply %10(%7, %9, %5) : $@convention(method) (Int64, Int64, @thin MyStruct.Type) -> MyStruct, loc "sroa.swift":8:21, scope 2
store %11 to %4 : $*MyStruct, loc "sroa.swift":8:21, scope 2
%13 = struct_element_addr %4 : $*MyStruct, #MyStruct.x, loc "sroa.swift":9:17, scope 2
store %0 to %13 : $*Int64, loc "sroa.swift":9:17, scope 2
%15 = struct_element_addr %4 : $*MyStruct, #MyStruct.y, loc "sroa.swift":10:17, scope 2
store %1 to %15 : $*Int64, loc "sroa.swift":10:17, scope 2
dealloc_stack %4 : $*MyStruct, loc "sroa.swift":8:9, scope 2
return %0 : $Int64, loc "sroa.swift":11:5, scope 2
} // end sil function 'foo'
|