Skip to content

Make LLVM emit assembly comments with -Z asm-comments - #53290

Merged
bors merged 1 commit into
rust-lang:masterfrom
whitequark:fix-35741
Aug 14, 2018
Merged

Make LLVM emit assembly comments with -Z asm-comments#53290
bors merged 1 commit into
rust-lang:masterfrom
whitequark:fix-35741

Conversation

@whitequark

Copy link
Copy Markdown
Contributor

Fixes#35741, and makes -Z asm-comments actually do something useful.

Before:

	.section	.text.main,"ax",@progbits
.globl	main
.p2align	4, 0x90
.type	main,@function
main:
.cfi_startproc
pushq	%rax
.cfi_def_cfa_offset 16
movslq	%edi, %rax
leaq	_ZN1t4main17he95a7d4f1843730eE(%rip), %rdi
movq	%rsi, (%rsp)
movq	%rax, %rsi
movq	(%rsp), %rdx
callq	_ZN3std2rt10lang_start17h3121da83b2bc3697E
movl	%eax, %ecx
movl	%ecx, %eax
popq	%rcx
.cfi_def_cfa_offset 8
retq
.Lfunc_end8:
.size	main, .Lfunc_end8-main
.cfi_endproc

After:

	.section	.text.main,"ax",@progbits
.globl	main # -- Begin function main
.p2align	4, 0x90
.type	main,@function
main: # @main
.cfi_startproc
# %bb.0:
pushq	%rax
.cfi_def_cfa_offset 16
movslq	%edi, %rax
leaq	_ZN1t4main17he95a7d4f1843730eE(%rip), %rdi
movq	%rsi, (%rsp) # 8-byte Spill
movq	%rax, %rsi
movq	(%rsp), %rdx # 8-byte Reload
callq	_ZN3std2rt10lang_start17h3121da83b2bc3697E
movl	%eax, %ecx
movl	%ecx, %eax
popq	%rcx
.cfi_def_cfa_offset 8
retq
.Lfunc_end8:
.size	main, .Lfunc_end8-main
.cfi_endproc
# -- End function

@rust-highfive

Copy link
Copy Markdown
Contributor

r? @cramertj

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 12, 2018
@nagisa

Copy link
Copy Markdown
Member

@bors r+

Thanks!

@bors

bors commented Aug 12, 2018

Copy link
Copy Markdown
Collaborator

📌 Commit 66fd1eb has been approved by nagisa

@bors

bors commented Aug 12, 2018

Copy link
Copy Markdown
Collaborator

🌲 The tree is currently closed for pull requests below priority 10, this pull request will be tested once the tree is reopened

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 12, 2018
kennytm added a commit to kennytm/rust that referenced this pull request Aug 12, 2018
Make LLVM emit assembly comments with -Z asm-comments
Fixesrust-lang#35741, and makes `-Z asm-comments` actually do something useful.
Before:
```
.section	.text.main,"ax",@progbits
.globl	main
.p2align	4, 0x90
.type	main,@function
main:
.cfi_startproc
pushq	%rax
.cfi_def_cfa_offset 16
movslq	%edi, %rax
leaq	_ZN1t4main17he95a7d4f1843730eE(%rip), %rdi
movq	%rsi, (%rsp)
movq	%rax, %rsi
movq	(%rsp), %rdx
callq	_ZN3std2rt10lang_start17h3121da83b2bc3697E
movl	%eax, %ecx
movl	%ecx, %eax
popq	%rcx
.cfi_def_cfa_offset 8
retq
.Lfunc_end8:
.size	main, .Lfunc_end8-main
.cfi_endproc
```
After:
```
.section	.text.main,"ax",@progbits
.globl	main # -- Begin function main
.p2align	4, 0x90
.type	main,@function
main: # @main
.cfi_startproc
pushq	%rax
.cfi_def_cfa_offset 16
movslq	%edi, %rax
leaq	_ZN1t4main17he95a7d4f1843730eE(%rip), %rdi
movq	%rsi, (%rsp) # 8-byte Spill
movq	%rax, %rsi
movq	(%rsp), %rdx # 8-byte Reload
callq	_ZN3std2rt10lang_start17h3121da83b2bc3697E
movl	%eax, %ecx
movl	%ecx, %eax
popq	%rcx
.cfi_def_cfa_offset 8
retq
.Lfunc_end8:
.size	main, .Lfunc_end8-main
.cfi_endproc
# -- End function
```
@kennytmkennytm mentioned this pull request Aug 12, 2018
@kennytm

Copy link
Copy Markdown
Member

@bors rollup

kennytm added a commit to kennytm/rust that referenced this pull request Aug 13, 2018
Make LLVM emit assembly comments with -Z asm-comments
Fixesrust-lang#35741, and makes `-Z asm-comments` actually do something useful.
Before:
```
.section	.text.main,"ax",@progbits
.globl	main
.p2align	4, 0x90
.type	main,@function
main:
.cfi_startproc
pushq	%rax
.cfi_def_cfa_offset 16
movslq	%edi, %rax
leaq	_ZN1t4main17he95a7d4f1843730eE(%rip), %rdi
movq	%rsi, (%rsp)
movq	%rax, %rsi
movq	(%rsp), %rdx
callq	_ZN3std2rt10lang_start17h3121da83b2bc3697E
movl	%eax, %ecx
movl	%ecx, %eax
popq	%rcx
.cfi_def_cfa_offset 8
retq
.Lfunc_end8:
.size	main, .Lfunc_end8-main
.cfi_endproc
```
After:
```
.section	.text.main,"ax",@progbits
.globl	main # -- Begin function main
.p2align	4, 0x90
.type	main,@function
main: # @main
.cfi_startproc
# %bb.0:
pushq	%rax
.cfi_def_cfa_offset 16
movslq	%edi, %rax
leaq	_ZN1t4main17he95a7d4f1843730eE(%rip), %rdi
movq	%rsi, (%rsp) # 8-byte Spill
movq	%rax, %rsi
movq	(%rsp), %rdx # 8-byte Reload
callq	_ZN3std2rt10lang_start17h3121da83b2bc3697E
movl	%eax, %ecx
movl	%ecx, %eax
popq	%rcx
.cfi_def_cfa_offset 8
retq
.Lfunc_end8:
.size	main, .Lfunc_end8-main
.cfi_endproc
# -- End function
```
@kennytmkennytm mentioned this pull request Aug 13, 2018
kennytm added a commit to kennytm/rust that referenced this pull request Aug 14, 2018
Make LLVM emit assembly comments with -Z asm-comments
Fixesrust-lang#35741, and makes `-Z asm-comments` actually do something useful.
Before:
```
.section	.text.main,"ax",@progbits
.globl	main
.p2align	4, 0x90
.type	main,@function
main:
.cfi_startproc
pushq	%rax
.cfi_def_cfa_offset 16
movslq	%edi, %rax
leaq	_ZN1t4main17he95a7d4f1843730eE(%rip), %rdi
movq	%rsi, (%rsp)
movq	%rax, %rsi
movq	(%rsp), %rdx
callq	_ZN3std2rt10lang_start17h3121da83b2bc3697E
movl	%eax, %ecx
movl	%ecx, %eax
popq	%rcx
.cfi_def_cfa_offset 8
retq
.Lfunc_end8:
.size	main, .Lfunc_end8-main
.cfi_endproc
```
After:
```
.section	.text.main,"ax",@progbits
.globl	main # -- Begin function main
.p2align	4, 0x90
.type	main,@function
main: # @main
.cfi_startproc
# %bb.0:
pushq	%rax
.cfi_def_cfa_offset 16
movslq	%edi, %rax
leaq	_ZN1t4main17he95a7d4f1843730eE(%rip), %rdi
movq	%rsi, (%rsp) # 8-byte Spill
movq	%rax, %rsi
movq	(%rsp), %rdx # 8-byte Reload
callq	_ZN3std2rt10lang_start17h3121da83b2bc3697E
movl	%eax, %ecx
movl	%ecx, %eax
popq	%rcx
.cfi_def_cfa_offset 8
retq
.Lfunc_end8:
.size	main, .Lfunc_end8-main
.cfi_endproc
# -- End function
```
@kennytmkennytm mentioned this pull request Aug 14, 2018
bors added a commit that referenced this pull request Aug 14, 2018
Rollup of 11 pull requests
Successful merges:
- #53112 (pretty print BTreeSet)
- #53208 (Don't panic on std::env::vars() when env is null.)
- #53226 (driver: set the syntax edition in phase 1)
- #53229 (Make sure rlimit is only ever increased)
- #53233 (targets: aarch64: Add bare-metal aarch64 target)
- #53239 (rustc_codegen_llvm: Restore the closure env alloca hack for LLVM 5.)
- #53246 (A few cleanups)
- #53257 (Idiomatic improvements to IP method)
- #53274 (Remove statics field from CodegenCx)
- #53290 (Make LLVM emit assembly comments with -Z asm-comments)
- #53317 (Mark prior failure to avoid ICE)
@bors
bors merged commit 66fd1eb into rust-lang:masterAug 14, 2018
@whitequark
whitequark deleted the fix-35741 branch August 15, 2018 02:47
@whitequark

Copy link
Copy Markdown
ContributorAuthor

whoa, this is even more awesome than I thought if you turn on debug info:
screenshot_20180815_042637

@gnzlbg

Copy link
Copy Markdown
Contributor

Is it possible to use this in stable rust?

@whitequark

Copy link
Copy Markdown
ContributorAuthor

No, since it's a -Z flag.

@gnzlbg

Copy link
Copy Markdown
Contributor

Is there an issue tracking the stabilization of this flag ?

@whitequark

Copy link
Copy Markdown
ContributorAuthor

Nope, I just added the flag.

@cameron-martin

Copy link
Copy Markdown

This looks really useful. Any idea on when it will get into stable rust?

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generate commented assembly with --emit=asm

8 participants

@whitequark@rust-highfive@nagisa@bors@kennytm@gnzlbg@cameron-martin@cramertj