-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Invalid bitcast with repr(simd), array type, and wasm #80108
Comments
This remains an issue on Rust nightly with LLVM 12. PS> rustc --version --verbose
rustc 1.53.0-nightly (7af1f55ae 2021-04-15)
binary: rustc
commit-hash: 7af1f55ae359e731c2c303f5d98e42a1a8163af0
commit-date: 2021-04-15
host: x86_64-pc-windows-msvc
release: 1.53.0-nightly
LLVM version: 12.0.0 |
Playing around with this some more in godbolt. x86_64-unknown-linux-gnu without optimization generates:
wasm32-unknown-unknown without optimization generates:
Is it expected that |
I think I see the problem, more or less. Here the SIMD field is extracted: rust/compiler/rustc_codegen_ssa/src/mir/operand.rs Lines 214 to 217 in 673d0db
and then here it is bitcast: rust/compiler/rustc_codegen_ssa/src/mir/operand.rs Lines 223 to 228 in 673d0db
I'm not sure, but I think the correct thing to do is check if the extracted element is an array (and not a pointer to an array?). If it's an array, we must return not the array on line 216 but a pointer to it. |
Yes, rust/compiler/rustc_middle/src/ty/layout.rs Lines 2905 to 2930 in 6eb956f
|
I took another shot at this with no success. It appears that with an arch without indirect SIMD types it completely skips the operand code and hits this branch in this rust/compiler/rustc_codegen_ssa/src/mir/place.rs Lines 97 to 101 in 533002d
I tried using |
Godbolt currently is back on May 31st, rustc 1.54.0-nightly (657bc01 2021-05-31)``` binary: rustc commit-hash: 657bc01 commit-date: 2021-05-31 host: x86_64-unknown-linux-gnu release: 1.54.0-nightly LLVM version: 12.0.1 Compiler returned: 0 ```#85966 got merged on June 4th. My nightly is dated since then, rustc 1.54.0-nightly (6c2dd25 2021-06-05)
Godbolt still fails, but my local rustc now succeeds in emitting wasm for this using rustc 1.55.0-nightly (6a758ea 2021-06-22)
|
@workingjubilee passing vectors via indirection definitely fixes the issue. I think the issue still stands if/when another architecture passes them directly. |
I agree that we seem to have an issue where we emit unsound bitcasts, but it seems like that should be documented more fully in another issue. |
…8, r=Mark-Simulacrum Add regression test for issue 80108 Closes rust-lang#80108
For some reason this only occurs with wasm. If you compile this on the playground, it works just fine until you compile for wasm, which produces this error.
Code
https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=685f1384988924fc87ac7760fccab58a
Meta
rustc --version --verbose
:Error output
The text was updated successfully, but these errors were encountered: