Skip to content

[cxx-interop] use raw pointer metadata for dynamic FRT field metadata #69424

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions lib/IRGen/MetadataRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3735,8 +3735,7 @@ namespace {
llvm_unreachable("classes shouldn't have this kind of refcounting");
case ReferenceCounting::None:
case ReferenceCounting::Custom:
llvm_unreachable(
"Foreign reference types don't conform to 'AnyClass'.");
return emitFromValueWitnessTable(IGF.IGM.Context.TheRawPointerType);
}

llvm_unreachable("Not a valid ReferenceCounting.");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// RUN: %empty-directory(%t)
// RUN: split-file %s %t


// RUN: %target-build-swift %t/struct.swift -emit-module -emit-library -static -module-name OpaqueStruct -emit-module-path %t/Inputs/OpaqueStruct.swiftmodule -enable-library-evolution

// RUN: %target-swift-emit-irgen %t/test.swift -I %t/Inputs -enable-experimental-cxx-interop -disable-availability-checking | %FileCheck %s

//--- Inputs/module.modulemap
module CxxModule {
header "header.h"
requires cplusplus
}

//--- Inputs/header.h

class
__attribute__((swift_attr("import_reference")))
__attribute__((swift_attr("retain:immortal")))
__attribute__((swift_attr("release:immortal")))
SingletonReference {
public:
SingletonReference(const SingletonReference &) = delete;

void method();
};

class
__attribute__((swift_attr("import_reference")))
__attribute__((swift_attr("retain:retainS")))
__attribute__((swift_attr("release:releaseS")))
SingletonReferenceRef {
public:
SingletonReferenceRef(const SingletonReferenceRef &) = delete;

void method();
};

void retainS(SingletonReferenceRef *);
void releaseS(SingletonReferenceRef *);

//--- struct.swift

public struct ResilientStruct {
let x: Int
}

//--- test.swift

import OpaqueStruct
import CxxModule

public struct ImmortalFRT_OpaqueLayout {
public let y: SingletonReference
public let x: ResilientStruct
}

public struct SharedFRT_OpaqueLayout {
public let x: ResilientStruct
public let y: SingletonReferenceRef
}

// CHECK: define{{.*}} @"$s4test24ImmortalFRT_OpaqueLayoutVMr"
// CHECK: store ptr getelementptr inbounds (ptr, ptr @"$sBpWV", i32

// CHECK: define{{.*}} @"$s4test22SharedFRT_OpaqueLayoutVMr"
// CHECK: store ptr getelementptr inbounds (ptr, ptr @"$sBpWV", i32
1 change: 0 additions & 1 deletion test/Interop/Cxx/foreign-reference/pod.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// RUN: %target-run-simple-swift(-I %S/Inputs/ -Xfrontend -enable-experimental-cxx-interop -Xfrontend -validate-tbd-against-ir=none -Xfrontend -disable-llvm-verify -g -Xfrontend -disable-availability-checking)
//
// REQUIRES: executable_test
// XFAIL: OS=windows-msvc

import StdlibUnittest
import POD
Expand Down