// RUN: %empty-directory(%t) // RUN: %target-swift-frontend -emit-module -enable-resilience -emit-module-path=%t/resilient_struct.swiftmodule -module-name=resilient_struct %S/../Inputs/resilient_struct.swift // RUN: %target-swift-frontend -emit-module -enable-resilience -emit-module-path=%t/resilient_class.swiftmodule -module-name=resilient_class %S/../Inputs/resilient_class.swift -I %t // RUN: %target-swift-frontend -I %t -emit-ir -enable-resilience %s | %FileCheck %s // RUN: %target-swift-frontend -I %t -emit-ir -enable-resilience -O %s // REQUIRES: CPU=x86_64 sil_stage canonical import Builtin import Swift import SwiftShims import resilient_class // Make sure that an alloc_ref of a resilient class loads the size and alignment // of the instance from metadata. // // Perhaps we should not serialize allocating initializers, then this would not // be an issue. // CHECK-LABEL: define {{(protected )?}}swiftcc void @allocResilientOutsideParent() // CHECK: [[META:%.*]] = call %swift.type* @_T015resilient_class22ResilientOutsideParentCMa() // CHECK-NEXT: [[META_ADDR:%.*]] = bitcast %swift.type* [[META]] to i8* // CHECK-NEXT: [[SIZE_ADDR:%.*]] = getelementptr inbounds i8, i8* [[META_ADDR]], i32 48 // CHECK-NEXT: [[SIZE_PTR:%.*]] = bitcast i8* [[SIZE_ADDR]] to i32* // CHECK-NEXT: [[SIZE_2:%.*]] = load i32, i32* [[SIZE_PTR]], align 8 // CHECK-NEXT: [[SIZE:%.*]] = zext i32 [[SIZE_2]] to i64 // CHECK-NEXT: [[ALIGN_ADDR:%.*]] = getelementptr inbounds i8, i8* [[META_ADDR]], i32 52 // CHECK-NEXT: [[ALIGN_PTR:%.*]] = bitcast i8* [[ALIGN_ADDR]] to i16* // CHECK-NEXT: [[ALIGN_2:%.*]] = load i16, i16* [[ALIGN_PTR]], align 4 // CHECK-NEXT: [[ALIGN:%.*]] = zext i16 [[ALIGN_2]] to i64 // CHECK-NEXT: call noalias %swift.refcounted* @swift_rt_swift_allocObject(%swift.type* [[META]], i64 [[SIZE]], i64 [[ALIGN]]) sil @allocResilientOutsideParent : $@convention(thin) () -> () { bb0: %c = alloc_ref $ResilientOutsideParent dealloc_ref %c : $ResilientOutsideParent %result = tuple () return %result : $() }