forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#126803 - tgross35:verbose-asm, r=Amanieu Change `asm-comments` to `verbose-asm`, always emit user comments Implements what is described in rust-lang/compiler-team#762 Tracking issue: rust-lang#126802
- Loading branch information
Showing
8 changed files
with
94 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# `verbose-asm` | ||
|
||
The tracking issue for this feature is: [#126802](https://github.com/rust-lang/rust/issues/126802). | ||
|
||
------------------------ | ||
|
||
This enables passing `-Zverbose-asm` to get contextual comments added by LLVM. | ||
|
||
Sample code: | ||
|
||
```rust | ||
#[no_mangle] | ||
pub fn foo(a: i32, b: i32) -> i32 { | ||
a + b | ||
} | ||
``` | ||
|
||
Default output: | ||
|
||
```asm | ||
foo: | ||
push rax | ||
add edi, esi | ||
mov dword ptr [rsp + 4], edi | ||
seto al | ||
jo .LBB0_2 | ||
mov eax, dword ptr [rsp + 4] | ||
pop rcx | ||
ret | ||
.LBB0_2: | ||
lea rdi, [rip + .L__unnamed_1] | ||
mov rax, qword ptr [rip + core::panicking::panic_const::panic_const_add_overflow::h9c85248fe0d735b2@GOTPCREL] | ||
call rax | ||
.L__unnamed_2: | ||
.ascii "/app/example.rs" | ||
.L__unnamed_1: | ||
.quad .L__unnamed_2 | ||
.asciz "\017\000\000\000\000\000\000\000\004\000\000\000\005\000\000" | ||
``` | ||
|
||
With `-Zverbose-asm`: | ||
|
||
```asm | ||
foo: # @foo | ||
# %bb.0: | ||
push rax | ||
add edi, esi | ||
mov dword ptr [rsp + 4], edi # 4-byte Spill | ||
seto al | ||
jo .LBB0_2 | ||
# %bb.1: | ||
mov eax, dword ptr [rsp + 4] # 4-byte Reload | ||
pop rcx | ||
ret | ||
.LBB0_2: | ||
lea rdi, [rip + .L__unnamed_1] | ||
mov rax, qword ptr [rip + core::panicking::panic_const::panic_const_add_overflow::h9c85248fe0d735b2@GOTPCREL] | ||
call rax | ||
# -- End function | ||
.L__unnamed_2: | ||
.ascii "/app/example.rs" | ||
.L__unnamed_1: | ||
.quad .L__unnamed_2 | ||
.asciz "\017\000\000\000\000\000\000\000\004\000\000\000\005\000\000" | ||
# DW_AT_external | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
//@ assembly-output: emit-asm | ||
//@ only-x86_64 | ||
// Check that comments in assembly get passed | ||
|
||
#![crate_type = "lib"] | ||
|
||
// CHECK-LABEL: test_comments: | ||
#[no_mangle] | ||
pub fn test_comments() { | ||
// CHECK: example comment | ||
unsafe { core::arch::asm!("nop // example comment") }; | ||
} |