-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Incorrect code generated from inline assembly with inout
register on riscv32im-unknown-none-elf
#128212
Comments
I haven't looked into this too much yet, but do you know if it reproduces using C's inline assembly fed through clang? This seems like it could be an LLVM problem. |
It appears that this bug starts to appear in 1.77. Using 1.76: https://godbolt.org/z/bKosKqvfW |
Could it be that this is the same underlying issue? |
Did you mean between 1.77 and 1.78? The two links look the same to me. It looks like this has to be a regression in LLVM, which was bumped to version 18 in 1.78, because we seem to generate the exact same IR. Could you file an issue with LLVM? https://godbolt.org/z/Te9efcnMz
It looks like it, I will close that one because this one has more detail. |
WG-prioritization assigning priority (Zulip discussion). Being an unsound issue, maybe let's see what we can do. Compile target is Tier 2. @rustbot label -I-prioritize +P-high |
See: rust-lang/rust#128212 --------- Co-authored-by: Erik Kaneda <erik@risczero.com>
Fix applied to LLVM 19.x llvm/llvm-project#100843 |
Update to LLVM 19 The LLVM 19.1.0 final release is planned for Sep 3rd. The rustc 1.82 stable release will be on Oct 17th. The unstable MC/DC coverage support is temporarily broken by this update. It will be restored by rust-lang#126733. The implementation changed substantially in LLVM 19, and there are no plans to support both the LLVM 18 and LLVM 19 implementation at the same time. Compatibility note for wasm: > WebAssembly target support for the `multivalue` target feature has changed when upgrading to LLVM 19. Support for generating functions with multiple returns no longer works and `-Ctarget-feature=+multivalue` has a different meaning than it did in LLVM 18 and prior. The WebAssembly target features `multivalue` and `reference-types` are now both enabled by default, but generated code is not affected by default. These features being enabled are encoded in the `target_features` custom section and may affect downstream tooling such as `wasm-opt` consuming the module, but the actual generated WebAssembly will continue to not use either `multivalue` or `reference-types` by default. There is no longer any supported means to generate a module that has a function with multiple returns. Related changes: * rust-lang#127605 * rust-lang#127613 * rust-lang#127654 * rust-lang#128141 * llvm/llvm-project#98933 Fixes rust-lang#121444. Fixes rust-lang#128212.
Update to LLVM 19 The LLVM 19.1.0 final release is planned for Sep 3rd. The rustc 1.82 stable release will be on Oct 17th. The unstable MC/DC coverage support is temporarily broken by this update. It will be restored by rust-lang#126733. The implementation changed substantially in LLVM 19, and there are no plans to support both the LLVM 18 and LLVM 19 implementation at the same time. Compatibility note for wasm: > WebAssembly target support for the `multivalue` target feature has changed when upgrading to LLVM 19. Support for generating functions with multiple returns no longer works and `-Ctarget-feature=+multivalue` has a different meaning than it did in LLVM 18 and prior. The WebAssembly target features `multivalue` and `reference-types` are now both enabled by default, but generated code is not affected by default. These features being enabled are encoded in the `target_features` custom section and may affect downstream tooling such as `wasm-opt` consuming the module, but the actual generated WebAssembly will continue to not use either `multivalue` or `reference-types` by default. There is no longer any supported means to generate a module that has a function with multiple returns. Related changes: * rust-lang#127605 * rust-lang#127613 * rust-lang#127654 * rust-lang#128141 * llvm/llvm-project#98933 Fixes rust-lang#121444. Fixes rust-lang#128212.
Update to LLVM 19 The LLVM 19.1.0 final release is planned for Sep 3rd. The rustc 1.82 stable release will be on Oct 17th. The unstable MC/DC coverage support is temporarily broken by this update. It will be restored by rust-lang/rust#126733. The implementation changed substantially in LLVM 19, and there are no plans to support both the LLVM 18 and LLVM 19 implementation at the same time. Compatibility note for wasm: > WebAssembly target support for the `multivalue` target feature has changed when upgrading to LLVM 19. Support for generating functions with multiple returns no longer works and `-Ctarget-feature=+multivalue` has a different meaning than it did in LLVM 18 and prior. The WebAssembly target features `multivalue` and `reference-types` are now both enabled by default, but generated code is not affected by default. These features being enabled are encoded in the `target_features` custom section and may affect downstream tooling such as `wasm-opt` consuming the module, but the actual generated WebAssembly will continue to not use either `multivalue` or `reference-types` by default. There is no longer any supported means to generate a module that has a function with multiple returns. Related changes: * rust-lang/rust#127605 * rust-lang/rust#127613 * rust-lang/rust#127654 * rust-lang/rust#128141 * llvm/llvm-project#98933 Fixes rust-lang/rust#121444. Fixes rust-lang/rust#128212.
Update to LLVM 19 The LLVM 19.1.0 final release is planned for Sep 3rd. The rustc 1.82 stable release will be on Oct 17th. The unstable MC/DC coverage support is temporarily broken by this update. It will be restored by rust-lang/rust#126733. The implementation changed substantially in LLVM 19, and there are no plans to support both the LLVM 18 and LLVM 19 implementation at the same time. Compatibility note for wasm: > WebAssembly target support for the `multivalue` target feature has changed when upgrading to LLVM 19. Support for generating functions with multiple returns no longer works and `-Ctarget-feature=+multivalue` has a different meaning than it did in LLVM 18 and prior. The WebAssembly target features `multivalue` and `reference-types` are now both enabled by default, but generated code is not affected by default. These features being enabled are encoded in the `target_features` custom section and may affect downstream tooling such as `wasm-opt` consuming the module, but the actual generated WebAssembly will continue to not use either `multivalue` or `reference-types` by default. There is no longer any supported means to generate a module that has a function with multiple returns. Related changes: * rust-lang/rust#127605 * rust-lang/rust#127613 * rust-lang/rust#127654 * rust-lang/rust#128141 * llvm/llvm-project#98933 Fixes rust-lang/rust#121444. Fixes rust-lang/rust#128212.
I tried compiling this code with a target of
riscv32im-unknown-none-elf
:The assembly generated is incorrect, since it doesn't add in the lower 16 bits of the address of
MY_BUFFER
before calling theecall
:As a workaround, changing the
inout
toinlateout
seems to fix the problem:Here is a compiler explorer link for rust nightly that demonstrates the problem:
https://godbolt.org/z/xMjoTo5oY
(For reference in case it gets fixed in nightly, it's also present in rust 1.80.0)
The text was updated successfully, but these errors were encountered: