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

Rust's i128 return ABI does not agree with Clang and GCC on Windows targets #134288

Open
tgross35 opened this issue Dec 13, 2024 · 0 comments
Open
Labels
A-ABI Area: Concerning the application binary interface (ABI) A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. O-windows Operating system: Windows T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@tgross35
Copy link
Contributor

Originally reported at rust-lang/lang-team#255 (comment), Clang and GCC-MinGW return __int128 in xmm0. Rust currently returns it on the stack.

@wesleywiser has a proposed patch to make Clang return on the stack for -msvc targets, while keeping the behavior for MinGW wesleywiser/llvm-project@b2f8b83.

Rustc could probably just change the Windows ABI to always return in xmm0 for now, and then if the Clang patch lands we can change this to apply only to MinGW.

Demo: https://godbolt.org/z/o9h8We69o

@tgross35 tgross35 added A-ABI Area: Concerning the application binary interface (ABI) A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. O-windows Operating system: Windows T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 13, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 13, 2024
@tgross35 tgross35 removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 13, 2024
tgross35 added a commit to tgross35/rust that referenced this issue Dec 14, 2024
Clang and GCC both return `i128` in xmm0 on Windows, both for MSVC and
MinGW targets. Currently, Rust returns `i128` indirectly. Add a fixup
for return ABI so we also return scalar `i128`s, which should make our
`i128` compatible with C.

In the future, Clang may change to return `i128` on the stack for its
`-msvc` targets (more at [1]). If this happens, the change here will
need to be adjusted to only affect MinGW.

Link: rust-lang#134288 (does not fix)
tgross35 added a commit to tgross35/rust that referenced this issue Dec 14, 2024
Clang and GCC both return `i128` in xmm0 on Windows, both for MSVC and
MinGW targets. Currently, Rust returns `i128` indirectly. Add a fixup
for return ABI so we also return scalar `i128`s, which should make our
`i128` compatible with C.

In the future, Clang may change to return `i128` on the stack for its
`-msvc` targets (more at [1]). If this happens, the change here will
need to be adjusted to only affect MinGW.

Link: rust-lang#134288 (does not fix)
tgross35 added a commit to tgross35/rust that referenced this issue Dec 14, 2024
Clang and GCC both return `i128` in xmm0 on windows-msvc and
windows-gnu. Currently, Rust returns the type on the stack. Add a
calling convention adjustment so we also return scalar `i128`s using the
vector ABI, which makes our `i128` compatible with C.

In the future, Clang may change to return `i128` on the stack for its
`-msvc` targets (more at [1]). If this happens, the change here will
need to be adjusted to only affect MinGW.

Link: rust-lang#134288 (does not fix)
tgross35 added a commit to tgross35/rust that referenced this issue Dec 14, 2024
Clang and GCC both return `i128` in xmm0 on windows-msvc and
windows-gnu. Currently, Rust returns the type on the stack. Add a
calling convention adjustment so we also return scalar `i128`s using the
vector ABI, which makes our `i128` compatible with C.

In the future, Clang may change to return `i128` on the stack for its
`-msvc` targets (more at [1]). If this happens, the change here will
need to be adjusted to only affect MinGW.

Link: rust-lang#134288 (does not fix)
bors added a commit to rust-lang-ci/rust that referenced this issue Dec 14, 2024
Windows x86: Change i128 to return via the vector ABI

Clang and GCC both return `i128` in xmm0 on windows-msvc and windows-gnu. Currently, Rust returns the type on the stack. Add a calling convention adjustment so we also return scalar `i128`s using the vector ABI, which makes our `i128` compatible with C.

In the future, Clang may change to return `i128` on the stack for its `-msvc` targets (more at [1]). If this happens, the change here will need to be adjusted to only affect MinGW.

Link: rust-lang#134288 (does not fix)

try-job: x86_64-msvc
try-job: x86_64-msvc-ext1
try-job: x86_64-mingw-1
try-job: x86_64-mingw-2
tgross35 added a commit to tgross35/rust that referenced this issue Dec 15, 2024
Clang and GCC both return `i128` in xmm0 on windows-msvc and
windows-gnu. Currently, Rust returns the type on the stack. Add a
calling convention adjustment so we also return scalar `i128`s using the
vector ABI, which makes our `i128` compatible with C.

In the future, Clang may change to return `i128` on the stack for its
`-msvc` targets (more at [1]). If this happens, the change here will
need to be adjusted to only affect MinGW.

Link: rust-lang#134288
tgross35 added a commit to tgross35/rust that referenced this issue Dec 15, 2024
Clang and GCC both return `i128` in xmm0 on windows-msvc and windows-gnu
but Rust returns the type on the stack. The LLVM backend was changed to
use the same convention as the C compilers; change Cranelift to do the
same.

Link: rust-lang#134288
bors added a commit to rust-lang-ci/rust that referenced this issue Dec 15, 2024
Windows x86: Change i128 to return via the vector ABI

Clang and GCC both return `i128` in xmm0 on windows-msvc and windows-gnu. Currently, Rust returns the type on the stack. Add a calling convention adjustment so we also return scalar `i128`s using the vector ABI, which makes our `i128` compatible with C.

In the future, Clang may change to return `i128` on the stack for its `-msvc` targets (more at [1]). If this happens, the change here will need to be adjusted to only affect MinGW.

Link: rust-lang#134288 (does not fix)

try-job: x86_64-msvc
try-job: x86_64-msvc-ext1
try-job: x86_64-mingw-1
try-job: x86_64-mingw-2
tgross35 added a commit to tgross35/rust that referenced this issue Dec 17, 2024
Clang and GCC both return `i128` in xmm0 on windows-msvc and
windows-gnu. Currently, Rust returns the type on the stack. Add a
calling convention adjustment so we also return scalar `i128`s using the
vector ABI, which makes our `i128` compatible with C.

In the future, Clang may change to return `i128` on the stack for its
`-msvc` targets (more at [1]). If this happens, the change here will
need to be adjusted to only affect MinGW.

Link: rust-lang#134288
tgross35 added a commit to tgross35/rust that referenced this issue Dec 17, 2024
Clang and GCC both return `i128` in xmm0 on windows-msvc and windows-gnu
but Rust returns the type on the stack. The LLVM backend was changed to
use the same convention as the C compilers; change Cranelift libcalls to
do the same.

Link: rust-lang#134288
tgross35 added a commit to tgross35/rust that referenced this issue Dec 17, 2024
Clang and GCC both return `i128` in xmm0 on windows-msvc and
windows-gnu. Currently, Rust returns the type on the stack. Add a
calling convention adjustment so we also return scalar `i128`s using the
vector ABI, which makes our `i128` compatible with C.

In the future, Clang may change to return `i128` on the stack for its
`-msvc` targets (more at [1]). If this happens, the change here will
need to be adjusted to only affect MinGW.

Link: rust-lang#134288
tgross35 added a commit to tgross35/rust that referenced this issue Dec 17, 2024
Clang and GCC both return `i128` in xmm0 on windows-msvc and windows-gnu
but Rust returns the type on the stack. The LLVM backend was changed to
use the same convention as the C compilers; change Cranelift libcalls to
do the same.

Link: rust-lang#134288
bors added a commit to rust-lang-ci/rust that referenced this issue Dec 17, 2024
Windows x86: Change i128 to return via the vector ABI

Clang and GCC both return `i128` in xmm0 on windows-msvc and windows-gnu. Currently, Rust returns the type on the stack. Add a calling convention adjustment so we also return scalar `i128`s using the vector ABI, which makes our `i128` compatible with C.

In the future, Clang may change to return `i128` on the stack for its `-msvc` targets (more at [1]). If this happens, the change here will need to be adjusted to only affect MinGW.

Link: rust-lang#134288 (does not fix)

try-job: x86_64-msvc
try-job: x86_64-msvc-ext1
try-job: x86_64-mingw-1
try-job: x86_64-mingw-2
tgross35 added a commit to tgross35/rust that referenced this issue Dec 22, 2024
Clang and GCC both return `i128` in xmm0 on windows-msvc and
windows-gnu. Currently, Rust returns the type on the stack. Add a
calling convention adjustment so we also return scalar `i128`s using the
vector ABI, which makes our `i128` compatible with C.

In the future, Clang may change to return `i128` on the stack for its
`-msvc` targets (more at [1]). If this happens, the change here will
need to be adjusted to only affect MinGW.

Link: rust-lang#134288
tgross35 added a commit to tgross35/rust that referenced this issue Dec 22, 2024
Clang and GCC both return `i128` in xmm0 on windows-msvc and windows-gnu
but Rust returns the type on the stack. The LLVM backend was changed to
use the same convention as the C compilers; change Cranelift libcalls to
do the same.

Link: rust-lang#134288
bors added a commit to rust-lang-ci/rust that referenced this issue Dec 22, 2024
Windows x86: Change i128 to return via the vector ABI

Clang and GCC both return `i128` in xmm0 on windows-msvc and windows-gnu. Currently, Rust returns the type on the stack. Add a calling convention adjustment so we also return scalar `i128`s using the vector ABI, which makes our `i128` compatible with C.

In the future, Clang may change to return `i128` on the stack for its `-msvc` targets (more at [1]). If this happens, the change here will need to be adjusted to only affect MinGW.

Link: rust-lang#134288 (does not fix) [1]

try-job: x86_64-msvc
try-job: x86_64-msvc-ext1
try-job: x86_64-mingw-1
try-job: x86_64-mingw-2
tgross35 added a commit to tgross35/rust that referenced this issue Jan 15, 2025
Clang and GCC both return `i128` in xmm0 on windows-msvc and
windows-gnu. Currently, Rust returns the type on the stack. Add a
calling convention adjustment so we also return scalar `i128`s using the
vector ABI, which makes our `i128` compatible with C.

In the future, Clang may change to return `i128` on the stack for its
`-msvc` targets (more at [1]). If this happens, the change here will
need to be adjusted to only affect MinGW.

Link: rust-lang#134288
bors added a commit to rust-lang-ci/rust that referenced this issue Jan 15, 2025
Windows x86: Change i128 to return via the vector ABI

Clang and GCC both return `i128` in xmm0 on windows-msvc and windows-gnu. Currently, Rust returns the type on the stack. Add a calling convention adjustment so we also return scalar `i128`s using the vector ABI, which makes our `i128` compatible with C.

In the future, Clang may change to return `i128` on the stack for its `-msvc` targets (more at [1]). If this happens, the change here will need to be adjusted to only affect MinGW.

Link: rust-lang#134288 (does not fix) [1]

try-job: x86_64-msvc
try-job: x86_64-msvc-ext1
try-job: x86_64-mingw-1
try-job: x86_64-mingw-2
tgross35 added a commit to tgross35/rust that referenced this issue Jan 16, 2025
Clang and GCC both return `i128` in xmm0 on windows-msvc and
windows-gnu. Currently, Rust returns the type on the stack. Add a
calling convention adjustment so we also return scalar `i128`s using the
vector ABI, which makes our `i128` compatible with C.

In the future, Clang may change to return `i128` on the stack for its
`-msvc` targets (more at [1]). If this happens, the change here will
need to be adjusted to only affect MinGW.

Link: rust-lang#134288
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jan 17, 2025
…bjorn3,wesleywiser

Windows x86: Change i128 to return via the vector ABI

Clang and GCC both return `i128` in xmm0 on windows-msvc and windows-gnu. Currently, Rust returns the type on the stack. Add a calling convention adjustment so we also return scalar `i128`s using the vector ABI, which makes our `i128` compatible with C.

In the future, Clang may change to return `i128` on the stack for its `-msvc` targets (more at [1]). If this happens, the change here will need to be adjusted to only affect MinGW.

Link: rust-lang#134288 (does not fix) [1]

try-job: x86_64-msvc
try-job: x86_64-msvc-ext1
try-job: x86_64-mingw-1
try-job: x86_64-mingw-2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ABI Area: Concerning the application binary interface (ABI) A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. O-windows Operating system: Windows T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants