// RUN: %target-swift-frontend %s -emit-ir | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize --check-prefix=CHECK-%target-runtime import Swift // CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swiftcc {{i[0-9]+}} @open_boxed_existential(%swift.error* %0) sil @open_boxed_existential : $@convention(thin) (@owned Error) -> Int { entry(%b : $Error): // CHECK: call void @swift_getErrorValue(%swift.error* %0, i8** {{%.*}}, [[TRIPLE:{ %swift.opaque\*, %swift.type\*, i8\*\* }]]* [[OUT:%.*]]) // CHECK: [[OUT_ADDR:%.*]] = getelementptr inbounds {{.*}} [[OUT]], i32 0, i32 0 // CHECK: [[ADDR:%.*]] = load {{.*}} [[OUT_ADDR]] // CHECK: [[OUT_TYPE:%.*]] = getelementptr inbounds {{.*}} [[OUT]], i32 0, i32 1 // CHECK: [[TYPE:%.*]] = load {{.*}} [[OUT_TYPE]] // CHECK: [[OUT_WITNESS:%.*]] = getelementptr inbounds {{.*}} [[OUT]], i32 0, i32 2 // CHECK: [[WITNESS:%.*]] = load {{.*}} [[OUT_WITNESS]] %o = open_existential_box %b : $Error to $*@opened("01234567-89AB-CDEF-0123-000000000000") Error %m = witness_method $@opened("01234567-89AB-CDEF-0123-000000000000") Error, #Error._code!getter, %o : $*@opened("01234567-89AB-CDEF-0123-000000000000") Error : $@convention(witness_method: Error) (@in_guaranteed Self) -> Int // CHECK: [[RESULT:%.*]] = call swiftcc [[INT:i[0-9]+]] @"$ss5ErrorP5_codeSivgTj"(%swift.opaque* noalias nocapture swiftself [[ADDR]], %swift.type* [[TYPE]], i8** [[WITNESS]]) %c = apply %m<@opened("01234567-89AB-CDEF-0123-000000000000") Error>(%o) : $@convention(witness_method: Error) (@in_guaranteed Self) -> Int // CHECK: ret [[INT]] [[RESULT]] return %c : $Int }