-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
Fix the IR gen for C++ method calls and refactor around CGFunctionInfo #76324
Conversation
@swift-ci please test |
@swift-ci please test macOS platform |
4 similar comments
@swift-ci please test macOS platform |
@swift-ci please test macOS platform |
@swift-ci please test macOS platform |
@swift-ci please test macOS platform |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this going through this path instead of using the proper call-lowering path?
@egorzhdan Can you help out here? Why does the |
I'm afraid I don't know the reason for the missing attribute. Perhaps this sret/noreg logic should be moved to @ahatanaka WDYT? |
@rjmccall WDYT? I think I will see what I can figure out. If there are some hints or places to look at, it'd be great if you can point me to them. |
53072ce
to
a31e89d
Compare
Rebased. @swift-ci please test |
@ahatanaka ping |
@swift-ci please test |
It looks like it's possible to add For example, this is the SIL for the call to
|
@ahatanaka So it sounds like that was the reason to add @rjmccall What do you think? |
f1d5c59
to
50ea617
Compare
As suggested, dropping the return type from the The test failures (with restricting to this pointer)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@swift-ci please test |
50ea617
to
0a4889b
Compare
@swift-ci please test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I thought it looked a little short. LGTM.
Thanks, John! I will look into the test failures. |
In GenCall, fix the IR gen for C++ method calls as under MSVC as the calling conventions for free functions and C++ methods can be different. This also fixes the missing inreg (on sret arguments) issues on Windows ARM64. Also refactor to use CGFunctionInfo returnInfo isSretAfterThis to detect when to reorder the sret and the this arguments under MSVC. In ClagImporter, don't drop the return type for the compound assignment operators such as operator+= when the return value is a reference so that the CGFunctionInfo will be correctly indicate an indirect return for the compound assignment operators.
0a4889b
to
fcc1f6b
Compare
@swift-ci please test |
@swift-ci please test Windows Platform |
3 similar comments
@swift-ci please test Windows Platform |
@swift-ci please test Windows Platform |
@swift-ci please test Windows Platform |
@rjmccall Can you take a quick look after the test fix? (for the return type change, additional attributes like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test changes look fine, although I'm confused about why we ever used 16-byte alignment for this type. I verified that MSVC only guarantees ordinary ABI alignment for sret results, as you'd normally expect.
Thanks, John! I am not sure why the 16-byte alignment there, either 🤔 but I agree with you. If I have a chance, I'll think about this. I'll merge this, and move onto cherrypicking this along with the other commits to 6 and 5.10 to make progress in resurrecting the windows arm64 compiler. |
In GenCall, fix the IR gen for C++ method calls as under MSVC as the calling conventions for free functions and C++ methods can be different. This also fixes the missing inreg (on sret arguments) issues on Windows ARM64. Also refactor to use CGFunctionInfo returnInfo isSretAfterThis to detect when to reorder the sret and the this arguments under MSVC. In ClagImporter, don't drop the return type for the compound assignment operators such as operator+= when the return value is a reference so that the CGFunctionInfo will be correctly indicate an indirect return for the compound assignment operators. Cherrypick swiftlang#76324
On Windows ARM64, how a struct value type is returned is sensitive to conditions including whether a user-defined constructor exists, etc. See https://learn.microsoft.com/en-us/cpp/build/arm64-windows-abi-conventions?view=msvc-170#return-values That caused a calling convention mismatch between the non-USED_IN_CPP_SOURCE (Swift) side and the USE_IN_CPP_SOURCE (C++) side and a crash. Add this constructor so that the calling convention matches. This is a fix for the OnoneSimplification crash in and is a partial fix for Cherrypick swiftlang#76324
In GenCall, fix the IR gen for C++ method calls as under MSVC as the calling conventions for free functions and C++ methods can be different. This also fixes the missing inreg (on sret arguments) issues on Windows ARM64. Also refactor to use CGFunctionInfo returnInfo isSretAfterThis to detect when to reorder the sret and the this arguments under MSVC. In ClagImporter, don't drop the return type for the compound assignment operators such as operator+= when the return value is a reference so that the CGFunctionInfo will be correctly indicate an indirect return for the compound assignment operators. Cherrypick swiftlang#76324
In GenCall, fix the IR gen for C++ method calls as under MSVC as the calling conventions for free functions and C++ methods can be different. This also fixes the missing inreg (on sret arguments) issues on Windows ARM64. Also refactor to use CGFunctionInfo returnInfo isSretAfterThis to detect when to reorder the sret and the this arguments under MSVC. In ClagImporter, don't drop the return type for the compound assignment operators such as operator+= when the return value is a reference so that the CGFunctionInfo will be correctly indicate an indirect return for the compound assignment operators. Cherrypick swiftlang#76324
In GenCall, fix the IR gen for C++ method calls as under MSVC as the calling conventions for free functions and C++ methods can be different. This also fixes the missing inreg (on sret arguments) issues on Windows ARM64. Also refactor to use CGFunctionInfo returnInfo isSretAfterThis to detect when to reorder the sret and the this arguments under MSVC. In ClagImporter, don't drop the return type for the compound assignment operators such as operator+= when the return value is a reference so that the CGFunctionInfo will be correctly indicate an indirect return for the compound assignment operators. Cherrypick swiftlang#76324
This case was missed by #76159.
This is a partial fix for #74866