mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
32 lines
1.5 KiB
Plaintext
32 lines
1.5 KiB
Plaintext
// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil %s -emit-ir | %FileCheck %s
|
|
|
|
// REQUIRES: CPU=x86_64
|
|
|
|
// Make sure that we are able to lower unconditional_checked_cast
|
|
// addresses for the super_to_archetype case and the downcast case.
|
|
|
|
class C {}
|
|
sil_vtable C {}
|
|
class D : C {}
|
|
sil_vtable D {}
|
|
|
|
// CHECK-LABEL: define{{( protected)?}} swiftcc void @downcast_test(%T26unconditional_checked_cast1DC** noalias nocapture sret, %T26unconditional_checked_cast1CC** nocapture dereferenceable({{.*}})) {{.*}} {
|
|
// CHECK: entry:
|
|
// CHECK-NEXT: [[INPUTPTR:%[0-9]+]] = load %T26unconditional_checked_cast1CC*, %T26unconditional_checked_cast1CC** [[INPUTPTRPTR:%[0-9]+]], align 8
|
|
// CHECK-NEXT: [[I8INPUTPTR:%[0-9]+]] = bitcast %T26unconditional_checked_cast1CC* [[INPUTPTR]] to i8*
|
|
// CHECK-NEXT: [[T0:%.*]] = call %swift.type* @_T026unconditional_checked_cast1DCMa()
|
|
// CHECK-NEXT: [[T1:%.*]] = bitcast %swift.type* [[T0]] to i8*
|
|
// CHECK-NEXT: [[I8RESULTPTR:%.*]] = call i8* @swift_dynamicCastClassUnconditional(i8* [[I8INPUTPTR]], i8* [[T1]])
|
|
// CHECK-NEXT: [[DOWNCASTINPUTPTR:%[0-9]+]] = bitcast i8* [[I8RESULTPTR]] to %T26unconditional_checked_cast1DC*
|
|
// CHECK-NEXT: store %T26unconditional_checked_cast1DC* [[DOWNCASTINPUTPTR]], %T26unconditional_checked_cast1DC** {{%[0-9]+}}, align 8
|
|
// CHECK-NEXT: ret void
|
|
|
|
sil @downcast_test : $@convention(thin) (@inout C) -> @out D {
|
|
bb0(%0 : $*D, %1 : $*C):
|
|
%a = load %1 : $*C
|
|
%2 = unconditional_checked_cast %a : $C to $D
|
|
store %2 to %0 : $*D
|
|
%33 = tuple()
|
|
return %33 : $()
|
|
}
|