Files
swift-mirror/test/SILAnalysis/alias-crash.sil
Joe Groff c0a2994564 AST: Start printing function types with @convention instead of old attributes.
And update tests to match.

Swift SVN r27262
2015-04-13 22:51:34 +00:00

42 lines
1.2 KiB
Plaintext

// RUN: %target-sil-opt %s -global-load-store-opts | FileCheck %s
sil_stage canonical
import Builtin
struct MyStruct {
var value : Builtin.FPIEEE64
}
enum MyEnum {
case Some(MyStruct)
case None
}
// Check if alias analysis can handle unchecked_take_enum_data_addr correctly
// and does not crash with a stack overflow.
// CHECK-LABEL: sil @testit
// CHECK: load
// CHECK: load
// CHECK: return
sil @testit : $@convention(method) (MyEnum) -> Builtin.FPIEEE64 {
bb0(%0 : $MyEnum):
%x1 = alloc_stack $MyEnum
store %0 to %x1#1 : $*MyEnum
%x7 = unchecked_take_enum_data_addr %x1#1 : $*MyEnum, #MyEnum.Some!enumelt.1
%x8 = struct_element_addr %x7 : $*MyStruct, #MyStruct.value
%x11 = alloc_stack $MyEnum
store %0 to %x11#1 : $*MyEnum
%x19 = unchecked_take_enum_data_addr %x11#1 : $*MyEnum, #MyEnum.Some!enumelt.1
%x20 = struct_element_addr %x19 : $*MyStruct, #MyStruct.value
%x24 = load %x20 : $*Builtin.FPIEEE64
%x27 = load %x8 : $*Builtin.FPIEEE64
%x28 = builtin "fsub_FPIEEE64"(%x27 : $Builtin.FPIEEE64, %x24 : $Builtin.FPIEEE64) : $Builtin.FPIEEE64
dealloc_stack %x11#0 : $*@local_storage MyEnum
dealloc_stack %x1#0 : $*@local_storage MyEnum
return %x28 : $Builtin.FPIEEE64
}