mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
This is a follow-up to d3e43bbe which resolved the issue for value types, but not for foreign reference types.
This change teaches IRGen that a base type of a C++ type might occupy less memory than its `sizeof`, specifically, it might only use `dsize` amount of memory.
rdar://147527755
43 lines
1.4 KiB
Swift
43 lines
1.4 KiB
Swift
// RUN: %target-swift-emit-ir -Onone %s -I %S/Inputs -cxx-interoperability-mode=default -validate-tbd-against-ir=none -disable-llvm-verify -Xcc -fignore-exceptions -disable-availability-checking | %FileCheck %s
|
|
|
|
// This ensured we do not crash during IRGen for inherited C++ foreign reference types.
|
|
|
|
import Inheritance
|
|
|
|
@inline(never)
|
|
public func blackHole<T>(_ _: T) {}
|
|
|
|
let x = DerivedOutOfOrder.getInstance()
|
|
|
|
blackHole(x.baseField)
|
|
blackHole(x.derivedField)
|
|
blackHole(x.leafField)
|
|
|
|
let y = DerivedUsesBaseTailPadding.getInstance()
|
|
|
|
blackHole(y.field2)
|
|
blackHole(y.field4)
|
|
|
|
// CHECK: call ptr @{{.*}}returnValueType{{.*}}
|
|
// CHECK-NOT: call void @{{.*}}RCRetain@{{.*}}ValueType(ptr @{{.*}})
|
|
var x1 = BasicInheritanceExample.returnValueType()
|
|
|
|
// CHECK: call ptr @{{.*}}returnRefType{{.*}}
|
|
// CHECK: call void @{{.*}}RCRetain{{.*}}RefType{{.*}}(ptr {{.*}})
|
|
var x2 = BasicInheritanceExample.returnRefType()
|
|
|
|
// CHECK: call ptr @{{.*}}returnDerivedFromRefType{{.*}}
|
|
// CHECK: call void @{{.*}}RCRetain{{.*}}RefType{{.*}}(ptr {{.*}})
|
|
var x3 = BasicInheritanceExample.returnDerivedFromRefType()
|
|
|
|
func foo(
|
|
x1: BasicInheritanceExample.ValueType, x2: BasicInheritanceExample.RefType,
|
|
x3: BasicInheritanceExample.DerivedFromRefType
|
|
) {
|
|
}
|
|
|
|
foo(x1: x1.pointee, x2: x2, x3: x3)
|
|
|
|
// CHECK: call void @{{.*}}RCRelease{{.*}}RefType{{.*}}(ptr {{.*}})
|
|
// CHECK: call void @{{.*}}RCRelease{{.*}}RefType{{.*}}(ptr {{.*}})
|