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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
|
// RUN: %target-swift-frontend -emit-ir %s | %FileCheck %s -DINT=i%target-ptrsize
// REQUIRES: CPU=i386 || CPU=x86_64
// We have to claim this is raw SIL because there are critical edges from non
// cond_br instructions.
sil_stage raw
import Builtin
import Swift
protocol P {
func f() -> Self
}
struct S {
var v: Int
}
// CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swiftcc void @testUnconditional0(
sil @testUnconditional0 : $@convention(thin) (@in P) -> () {
bb0(%0 : $*P):
// CHECK: [[T0:%.*]] = alloca [[S:%.*]], align
// CHECK: [[T4:%.*]] = call {{.*}}@"$s12dynamic_cast1P_pMD"
// CHECK: call zeroext i1 @swift_dynamicCast(ptr [[T0]], ptr {{%.*}}, ptr [[T4]], ptr {{.*}}, [[INT]] 7)
%1 = alloc_stack $S
unconditional_checked_cast_addr P in %0 : $*P to S in %1 : $*S
destroy_addr %1 : $*S
dealloc_stack %1 : $*S
%2 = tuple ()
return %2 : $()
}
// CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swiftcc void @testUnconditional1(
sil @testUnconditional1 : $@convention(thin) (@in P) -> () {
bb0(%0 : $*P):
// CHECK: [[T0:%.*]] = alloca [[S:%.*]], align
// CHECK: [[T4:%.*]] = call {{.*}}@"$s12dynamic_cast1P_pMD"
// CHECK: call zeroext i1 @swift_dynamicCast(ptr [[T0]], ptr {{%.*}}, ptr [[T4]], ptr {{.*}}, [[INT]] 7)
%1 = alloc_stack $S
unconditional_checked_cast_addr P in %0 : $*P to S in %1 : $*S
destroy_addr %1 : $*S
dealloc_stack %1 : $*S
%2 = tuple ()
return %2 : $()
}
// CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swiftcc void @testConditional0(
sil @testConditional0 : $@convention(thin) (@in P) -> () {
bb0(%0 : $*P):
// CHECK: [[T0:%.*]] = alloca [[S:%.*]], align
// CHECK: [[T4:%.*]] = call {{.*}}@"$s12dynamic_cast1P_pMD"
// CHECK: [[T5:%.*]] = call zeroext i1 @swift_dynamicCast(ptr [[T0]], ptr {{%.*}}, ptr [[T4]], ptr {{.*}}, [[INT]] 6)
// CHECK: br i1 [[T5]],
%1 = alloc_stack $S
checked_cast_addr_br take_always P in %0 : $*P to S in %1 : $*S, bb1, bb2
bb1:
br bb3
bb2:
br bb3
bb3:
destroy_addr %1 : $*S
dealloc_stack %1 : $*S
%2 = tuple ()
return %2 : $()
}
// CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swiftcc void @testConditional1(
sil @testConditional1 : $@convention(thin) (@in P) -> () {
bb0(%0 : $*P):
// CHECK: [[T0:%.*]] = alloca [[S:%.*]], align
// CHECK: [[T4:%.*]] = call {{.*}}@"$s12dynamic_cast1P_pMD"
// CHECK: [[T5:%.*]] = call zeroext i1 @swift_dynamicCast(ptr [[T0]], ptr {{%.*}}, ptr [[T4]], ptr {{.*}}, [[INT]] 2)
// CHECK: br i1 [[T5]],
%1 = alloc_stack $S
checked_cast_addr_br take_on_success P in %0 : $*P to S in %1 : $*S, bb1, bb2
bb1:
br bb3
bb2:
br bb3
bb3:
destroy_addr %1 : $*S
dealloc_stack %1 : $*S
%2 = tuple ()
return %2 : $()
}
// CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swiftcc void @testConditional2(
sil @testConditional2 : $@convention(thin) (@in P) -> () {
bb0(%0 : $*P):
// CHECK: [[T0:%.*]] = alloca [[S:%.*]], align
// CHECK: [[T4:%.*]] = call {{.*}}@"$s12dynamic_cast1P_pMD"
// CHECK: [[T5:%.*]] = call zeroext i1 @swift_dynamicCast(ptr [[T0]], ptr {{%.*}}, ptr [[T4]], ptr {{.*}}, [[INT]] 0)
// CHECK: br i1 [[T5]],
%1 = alloc_stack $S
checked_cast_addr_br copy_on_success P in %0 : $*P to S in %1 : $*S, bb1, bb2
bb1:
br bb3
bb2:
br bb3
bb3:
destroy_addr %1 : $*S
dealloc_stack %1 : $*S
%2 = tuple ()
return %2 : $()
}
|