Skip to content
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

[cxx-interop] Mark C++ reference parameters @addressable #78759

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Xazax-hun
Copy link
Contributor

C++ code can return values that depend on the storage that backs the references that were passed in as argument. Thus, swift should not introdue temporary copies of that storage before invoking those functions as they could result in lifetime issues.

@Xazax-hun Xazax-hun added the c++ interop Feature: Interoperability with C++ label Jan 20, 2025
@@ -120,6 +121,21 @@ CaptureView getCaptureView(const Owner& owner [[clang::lifetimebound]]) {
// CHECK: sil [clang CaptureView.captureView] {{.*}} : $@convention(cxx_method) (View, @lifetime(copy 0) @inout CaptureView) -> ()
// CHECK: sil [clang CaptureView.handOut] {{.*}} : $@convention(cxx_method) (@lifetime(copy 1) @inout View, @in_guaranteed CaptureView) -> ()

// CHECK-ADDRESSABLE: sil [clang makeOwner] {{.*}}: $@convention(c) () -> Owner
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jckarter do you know what would be the best way to test if @addressable is properly applied? I do not see this reflected in the emitted SIL. Is this an oversight or intentional?

C++ code can return values that depend on the storage that backs the
references that were passed in as argument. Thus, swift should not
introdue temporary copies of that storage before invoking those
functions as they could result in lifetime issues.
@Xazax-hun Xazax-hun force-pushed the gaborh/addressable-references branch from 3f61c98 to e3b229f Compare January 20, 2025 17:13
@Xazax-hun
Copy link
Contributor Author

@swift-ci please smoke test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ interop Feature: Interoperability with C++
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant