Files
swift-mirror/test/SILAnalysis/alias-crash.sil
Dmitri Hrybenko 3b04d1b013 tests: reorganize tests so that they actually use the target platform
Most tests were using %swift or similar substitutions, which did not
include the target triple and SDK.  The driver was defaulting to the
host OS.  Thus, we could not run the tests when the standard library was
not built for OS X.

Swift SVN r24504
2015-01-19 06:52:49 +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 : $@cc(method) @thin (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
}