Add documentation for -Zverbose-asm · rust-lang/rust@b079ac7 (original) (raw)
File tree
1 file changed
lines changed
- src/doc/unstable-book/src/compiler-flags
1 file changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
1 | +# `verbose-asm` | |
2 | + | |
3 | +The tracking issue for this feature is: [#126802](https://github.com/rust-lang/rust/issues/126802). | |
4 | + | |
5 | +------------------------ | |
6 | + | |
7 | +This enables passing `-Zverbose-asm` to get contextual comments added by LLVM. | |
8 | + | |
9 | +Sample code: | |
10 | + | |
11 | +```rust | |
12 | +#[no_mangle] | |
13 | +pub fn foo(a: i32, b: i32) -> i32 { | |
14 | +a + b | |
15 | +} | |
16 | +``` | |
17 | + | |
18 | +Default output: | |
19 | + | |
20 | +```asm | |
21 | +foo: | |
22 | + push rax | |
23 | + add edi, esi | |
24 | + mov dword ptr [rsp + 4], edi | |
25 | + seto al | |
26 | + jo .LBB0_2 | |
27 | + mov eax, dword ptr [rsp + 4] | |
28 | + pop rcx | |
29 | + ret | |
30 | +.LBB0_2: | |
31 | + lea rdi, [rip + .L__unnamed_1] | |
32 | + mov rax, qword ptr [rip + core::panicking::panic_const::panic_const_add_overflow::h9c85248fe0d735b2@GOTPCREL] | |
33 | + call rax | |
34 | + | |
35 | +.L__unnamed_2: | |
36 | + .ascii "/app/example.rs" | |
37 | + | |
38 | +.L__unnamed_1: | |
39 | + .quad .L__unnamed_2 | |
40 | + .asciz "\017\000\000\000\000\000\000\000\004\000\000\000\005\000\000" | |
41 | +``` | |
42 | + | |
43 | +With `-Zverbose-asm`: | |
44 | + | |
45 | +```asm | |
46 | +foo: # @foo | |
47 | +# %bb.0: | |
48 | + push rax | |
49 | + add edi, esi | |
50 | + mov dword ptr [rsp + 4], edi # 4-byte Spill | |
51 | + seto al | |
52 | + jo .LBB0_2 | |
53 | +# %bb.1: | |
54 | + mov eax, dword ptr [rsp + 4] # 4-byte Reload | |
55 | + pop rcx | |
56 | + ret | |
57 | +.LBB0_2: | |
58 | + lea rdi, [rip + .L__unnamed_1] | |
59 | + mov rax, qword ptr [rip + core::panicking::panic_const::panic_const_add_overflow::h9c85248fe0d735b2@GOTPCREL] | |
60 | + call rax | |
61 | + # -- End function | |
62 | +.L__unnamed_2: | |
63 | + .ascii "/app/example.rs" | |
64 | + | |
65 | +.L__unnamed_1: | |
66 | + .quad .L__unnamed_2 | |
67 | + .asciz "\017\000\000\000\000\000\000\000\004\000\000\000\005\000\000" | |
68 | + | |
69 | + # DW_AT_external | |
70 | +``` |