Open
Description
Quick example (run on playground):
#![feature(asm, global_asm)]
global_asm!("GlobalThisIsNotAnInstruction");
fn main() {
unsafe {
asm!("MainThisIsNotAnInstruction");
}
}
Current error output is:
error: invalid instruction mnemonic 'globalthisisnotaninstruction'
|
note: instantiated into assembly here
--> <inline asm>:1:1
|
1 | GlobalThisIsNotAnInstruction
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: invalid instruction mnemonic 'mainthisisnotaninstruction'
--> src/main.rs:7:15
|
7 | asm!("MainThisIsNotAnInstruction");
| ^
|
note: instantiated into assembly here
--> <inline asm>:2:2
|
2 | MainThisIsNotAnInstruction
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
The reason asm!
has location information is because it attaches !srcloc
metadata on the call asm
instruction, whereas global_asm!
does nothing of the sort.
It's not clear from the LLVM documentation whether !srcloc
(or something equivalent) is supported for module asm
, so this might be blocked on LLVM implementing it in the first place.
This came up as @Jasper-Bekkers tried iimplementing AsmMethods::codegen_global_asm
for rustc_codegen_spirv
and noticed there was no Span
being passed, and (presumably the more worrying aspect) that hir::GlobalAsm
contains no Span
either - it probably should (given that hir::InlineAsm
has line_spans: &[Span]
).
Metadata
Metadata
Assignees
Labels
Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Messages for errors, warnings, and lintsArea: Inline assembly (`asm!(…)`)Category: An issue proposing an enhancement or a PR with one.Relevant to the compiler team, which will review and decide on the PR/issue.This issue requires a nightly compiler in some way.