// 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{{( dllexport)?}}{{( protected)?}} swiftcc void @downcast_test(ptr noalias{{( nocapture)?}} sret({{.*}}){{( captures\(none\))?}} %0, ptr {{(nocapture|captures\(none\))}} dereferenceable({{.*}}) %1) {{.*}} { // CHECK: entry: // CHECK-NEXT: [[INPUTPTR:%[0-9]+]] = load ptr, ptr [[INPUTPTRPTR:%[0-9]+]], align 8 // CHECK-NEXT: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$s26unconditional_checked_cast1DCMa"(i64 0) // CHECK-NEXT: [[T0:%.*]] = extractvalue %swift.metadata_response [[TMP]], 0 // CHECK-NEXT: [[I8RESULTPTR:%.*]] = call ptr @swift_dynamicCastClassUnconditional(ptr [[INPUTPTR]], ptr [[T0]], {{.*}}) // CHECK-NEXT: store ptr [[I8RESULTPTR]], ptr {{%[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 : $() }