blob: 9eb37f8afd4a931237de38c11d954f5fca404918 [file] [log] [blame]
// RUN: %target-swift-frontend %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)?}} void @downcast_test(%C26unconditional_checked_cast1D** noalias nocapture sret, %C26unconditional_checked_cast1C** nocapture dereferenceable({{.*}})) {{.*}} {
// CHECK: entry:
// CHECK-NEXT: [[INPUTPTR:%[0-9]+]] = load %C26unconditional_checked_cast1C*, %C26unconditional_checked_cast1C** [[INPUTPTRPTR:%[0-9]+]], align 8
// CHECK-NEXT: [[I8INPUTPTR:%[0-9]+]] = bitcast %C26unconditional_checked_cast1C* [[INPUTPTR]] to i8*
// CHECK-NEXT: [[T0:%.*]] = call %swift.type* @_TMaC26unconditional_checked_cast1D()
// 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 %C26unconditional_checked_cast1D*
// CHECK-NEXT: store %C26unconditional_checked_cast1D* [[DOWNCASTINPUTPTR]], %C26unconditional_checked_cast1D** {{%[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 : $()
}