-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
asm_goto_with_outputs miscompilation #137867
Labels
A-inline-assembly
Area: Inline assembly (`asm!(…)`)
C-bug
Category: This is a bug.
F-asm
`#![feature(asm)]` (not `llvm_asm`)
I-miscompile
Issue: Correct Rust code lowers to incorrect machine code
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Comments
Cc @nbdd0121 |
Looks like rust/compiler/rustc_codegen_llvm/src/asm.rs Lines 347 to 374 in fd17dea
CriticalCallEdges MIR pass should perform the same critical edge splitting as for Call terminators?
|
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this issue
Mar 7, 2025
… r=bjorn3 Break critical edges in inline asm before code generation An inline asm terminator defines outputs along its target edges -- a fallthrough target and labeled targets. Code generation implements this by inserting code directly into the target blocks. This approach works only if the target blocks don't have other predecessors. Establish required invariant by extending existing code that breaks critical edges before code generation. Fixes rust-lang#137867. r? `@bjorn3`
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this issue
Mar 7, 2025
Rollup merge of rust-lang#138073 - tmiasko:inline-asm-critical-edges, r=bjorn3 Break critical edges in inline asm before code generation An inline asm terminator defines outputs along its target edges -- a fallthrough target and labeled targets. Code generation implements this by inserting code directly into the target blocks. This approach works only if the target blocks don't have other predecessors. Establish required invariant by extending existing code that breaks critical edges before code generation. Fixes rust-lang#137867. r? ``@bjorn3``
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-inline-assembly
Area: Inline assembly (`asm!(…)`)
C-bug
Category: This is a bug.
F-asm
`#![feature(asm)]` (not `llvm_asm`)
I-miscompile
Issue: Correct Rust code lowers to incorrect machine code
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
This should return
7
, but returnsa
, with or without optimizations.https://godbolt.org/z/Efze66G84
As far as I can tell, the MIR looks correct:
In particular, the value assigned to
_1
inbb2
is returned inbb1
.The LLVM-IR is incorrect, as
bb2
stores the value toptr %a
, butbb1
then overwrites that with the previous value in%2
.rustc --version --verbose
:asm_goto tracking issue: #119364
@rustbot label +F-asm +A-inline-assembly +T-compiler
The text was updated successfully, but these errors were encountered: