Skip to content

[cxx-interop] Use a synthesized C++ method when invoking a base metho… #68846

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 4 commits into from
Oct 17, 2023

Conversation

hyp
Copy link
Contributor

@hyp hyp commented Sep 28, 2023

…d from a derived class synthesized method

The use of a synthesized C++ method allows us to avoid making a copy of self when invoking the base method from Swift

@hyp hyp added the c++ interop Feature: Interoperability with C++ label Sep 28, 2023
@hyp
Copy link
Contributor Author

hyp commented Sep 28, 2023

@swift-ci please test

@hyp
Copy link
Contributor Author

hyp commented Sep 28, 2023

Still also should do that for field accessors.

@hyp
Copy link
Contributor Author

hyp commented Sep 29, 2023

@swift-ci please test linux platform

hyp added 2 commits September 29, 2023 13:52
…d from a derived class synthesized method

The use of a synthesized C++ method allows us to avoid making a copy of self when invoking the base method from Swift
@hyp hyp force-pushed the eng/base-member-cxx-synthesized-accessor branch from 7383886 to 82f8d5d Compare September 29, 2023 21:20
@hyp
Copy link
Contributor Author

hyp commented Sep 29, 2023

@swift-ci please test

Copy link
Contributor

@egorzhdan egorzhdan left a comment

Choose a reason for hiding this comment

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

Awesome! 👍

@hyp
Copy link
Contributor Author

hyp commented Oct 11, 2023

@swift-ci please test

@hyp hyp force-pushed the eng/base-member-cxx-synthesized-accessor branch from 14814d7 to 0851fa2 Compare October 11, 2023 21:30
@hyp
Copy link
Contributor Author

hyp commented Oct 11, 2023

@swift-ci please test

@hyp hyp force-pushed the eng/base-member-cxx-synthesized-accessor branch from 0851fa2 to dda039d Compare October 12, 2023 22:32
@hyp
Copy link
Contributor Author

hyp commented Oct 12, 2023

@swift-ci please test

hyp added 2 commits October 16, 2023 14:34
…d or subscript from a derived class synthesized method

The use of a synthesized C++ method allows us to avoid making a copy of self when accessing the base field or subscript from Swift
…t a retainable FRT value

This matches the semantics of accessing the same field from the base class
@hyp hyp force-pushed the eng/base-member-cxx-synthesized-accessor branch from dda039d to f7ce9aa Compare October 16, 2023 21:42
@hyp
Copy link
Contributor Author

hyp commented Oct 16, 2023

@swift-ci please test

@hyp
Copy link
Contributor Author

hyp commented Oct 16, 2023

@swift-ci please test source compatibility

@hyp hyp merged commit 41dc466 into swiftlang:main Oct 17, 2023
@finagolfin
Copy link
Member

It looks like this pull introduced 5 IRGen tests that assume a 64-bit platform, causing them to fail on Android armv7:

/home/ubuntu/jenkins/workspace/oss-swift-RA-linux-ubuntu-16.04-android/swift/test/Interop/Cxx/class/inheritance/fields-irgen.swift:13:11: error: CHECK: expected string not found in input
// CHECK: %[[ADD_PTR:.*]] = getelementptr inbounds i8, ptr %{{.*}}, i64 4
          ^
<stdin>:119:183: note: scanning from here
define linkonce_odr noundef i32 @_ZNK30CopyTrackedDerivedDerivedClass55__synthesizedBaseCall___synthesizedBaseGetterAccessor_xEv(ptr noundef nonnull align 4 dereferenceable(8) %this) #6 comdat align 2 {
                                                                                                                                                                                      ^
<stdin>:124:6: note: possible intended match here
 %add.ptr = getelementptr inbounds i8, ptr %this1, i32 4
     ^

@natecook1000, do these tests also fail on 32-bit watchOS, presuming that's still being tested by some CI?

@hyp
Copy link
Contributor Author

hyp commented Oct 19, 2023

Fixing it.

hyp added a commit to hyp/swift that referenced this pull request Oct 19, 2023
@hyp
Copy link
Contributor Author

hyp commented Oct 19, 2023

Patch up: #69283

meg-gupta pushed a commit to meg-gupta/swift that referenced this pull request Oct 23, 2023
hyp added a commit that referenced this pull request Oct 23, 2023
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.

[cxx-interop] calls to __swift_interopStaticCast in synthesized base class member accessors should not copy C++ type by value
3 participants