You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Invalid inline assembly is silently discarded #22892
Unless I'm missing something, I should either get an error, or I should see "out %al, %dx" somewhere in there, but instead, absolutely nothing happens.
seems to work just fine. The relevant LLVM documentation is for struct llvm::InlineAsm::SubConstraintInfo, field Codes where it specifies that the register name may come in braces, but doesn't really say anything more specific than that.
If Rust isn't receiving an error from LLVM about the invalid constraint, that's an LLVM bug, right? Still, I would like Rust documentation to be a little more specific about what constraints are allowed in asm! and perhaps for rustc to verify them, if LLVM won't.
This issue appears to have returned with the recent LLVM update. If the data type passed to the inline assembly does not match the register size, the assembly is not emitted into assembly.
#![feature(asm)]fnmain(){unsafe{// - Errors, as expected//asm!("lttr %cx" : : "{ecx}" (7*8));// No error, no emitted instruction.asm!("lttr %cx"::"{rcx}"(7*8));}}
changed the title [-]Inline assembly fails to generate OUT instruction with the required constraints[/-][+]Invalid inline assembly is silently discarded[/+]on Jan 14, 2016
Minimal test case from top comment produces, so presumably this is fixed. However, output files (rust_out.0.o and rust_out.crate.metadata.o) are still produced despite the error, so I'm not sure if this should be closed quite yet. If yes, please do so.
error: couldn't allocate input reg for constraint 'a'
--> <anon>:7:14
|
7 | unsafe { asm!("out %al, %dx" :: "a" (byte), "d" (port) :: "volatile"); }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
Edit: This probably means #26648 is also fixed, but I'm not sure...
If anyone can reproduce, please reopen. I haven't been able to reproduce since the original source doesn't quite compile--we should open another issue about incomplete compiles leaving files behind.
Activity
devyn commentedon Mar 1, 2015
LLVM IR appears to include the inline asm, so I'm guessing this is an LLVM bug:
I'll check to see what clang does.
devyn commentedon Mar 1, 2015
C source:
clang LLVM IR (
clang -emit-llvm -S mintest.c):So it looks like it might be a Rust bug after all; Rust should be generating
{ax}and{dx}constraints in the IR?devyn commentedon Mar 2, 2015
Okay, so I looked at this again today:
seems to work just fine. The relevant LLVM documentation is for struct
llvm::InlineAsm::SubConstraintInfo, fieldCodeswhere it specifies that the register name may come in braces, but doesn't really say anything more specific than that.If Rust isn't receiving an error from LLVM about the invalid constraint, that's an LLVM bug, right? Still, I would like Rust documentation to be a little more specific about what constraints are allowed in
asm!and perhaps forrustcto verify them, if LLVM won't.thepowersgang commentedon Jul 2, 2015
This issue appears to have returned with the recent LLVM update. If the data type passed to the inline assembly does not match the register size, the assembly is not emitted into assembly.
jethrogb commentedon Jan 14, 2016
This is still a problem. Title of this bug should be: Invalid inline assembly is silently discarded.
[-]Inline assembly fails to generate OUT instruction with the required constraints[/-][+]Invalid inline assembly is silently discarded[/+]devyn commentedon Jan 14, 2016
Updated.
Mark-Simulacrum commentedon Apr 16, 2017
Minimal test case from top comment produces, so presumably this is fixed. However, output files (
rust_out.0.oandrust_out.crate.metadata.o) are still produced despite the error, so I'm not sure if this should be closed quite yet. If yes, please do so.Edit: This probably means #26648 is also fixed, but I'm not sure...
Mark-Simulacrum commentedon Apr 28, 2017
If anyone can reproduce, please reopen. I haven't been able to reproduce since the original source doesn't quite compile--we should open another issue about incomplete compiles leaving files behind.
jethrogb commentedon Apr 28, 2017
Might be good to add a regression test?
Mark-Simulacrum commentedon Apr 28, 2017
Hmm, yeah. I'll reopen and mark as E-needstest.
3 remaining items
Add a test for rust-lang#22892
Rollup merge of rust-lang#58743 - varkor:bulk-needstest-1, r=alexcric…
Add a test for rust-lang#22892
Rollup merge of rust-lang#58743 - varkor:bulk-needstest-1, r=alexcric…
Rollup merge of rust-lang#58743 - varkor:bulk-needstest-1, r=alexcric…
Rollup merge of rust-lang#58743 - varkor:bulk-needstest-1, r=alexcric…
varkor commentedon Mar 9, 2019
There seem to still be issues with this test case on
armhf-gnu: #59046 (comment).Add a test for rust-lang#22892
Add a test for rust-lang#22892
Amanieu commentedon May 22, 2020
This issue does not apply to the new
asm!(RFC 2850) which validates the operand register classes.The legacy
llvm_asm!is deprecated and is no longer maintained.Merge pull request rust-lang#22892 from Wilfred/fix/merge-imports-mal…