Closed
Description
Minimal testcase:
#![feature(asm)]
fn main() {
let byte = 0;
let port = 0x80;
unsafe { asm!("out %al, %dx" :: "a" (byte), "d" (port) :: "volatile"); }
}
rustc --version
:
rustc 1.0.0-nightly (4db0b3246 2015-02-25) (built 2015-02-26)
rustc
output:
$ rustc mintest.rs
$
(i.e., nothing)
Resulting objdump on x86_64-unknown-linux-gnu:
0000000000005070 <_ZN4main20h953519ae653eac04eaaE>:
5070: 64 48 3b 24 25 70 00 cmp %fs:0x70,%rsp
5077: 00 00
5079: 77 1a ja 5095 <_ZN4main20h953519ae653eac04eaaE+0x25>
507b: 49 ba 10 00 00 00 00 movabs $0x10,%r10
5082: 00 00 00
5085: 49 bb 00 00 00 00 00 movabs $0x0,%r11
508c: 00 00 00
508f: e8 80 00 00 00 callq 5114 <__morestack>
5094: c3 retq
5095: 48 83 ec 10 sub $0x10,%rsp
5099: c7 44 24 0c 00 00 00 movl $0x0,0xc(%rsp)
50a0: 00
50a1: c7 44 24 08 80 00 00 movl $0x80,0x8(%rsp)
50a8: 00
50a9: 8b 44 24 0c mov 0xc(%rsp),%eax
50ad: 8b 4c 24 08 mov 0x8(%rsp),%ecx
50b1: 89 44 24 04 mov %eax,0x4(%rsp)
50b5: 89 0c 24 mov %ecx,(%rsp)
50b8: 48 83 c4 10 add $0x10,%rsp
50bc: c3 retq
50bd: 0f 1f 00 nopl (%rax)
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.
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
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
, fieldCodes
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 forrustc
to 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.o
andrust_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.
19 remaining items