about summary refs log tree commit diff
path: root/src/rustllvm
diff options
context:
space:
mode:
authorkennytm <kennytm@gmail.com>2018-08-14 23:59:16 +0800
committerGitHub <noreply@github.com>2018-08-14 23:59:16 +0800
commit47f66e7372e5e020d8c4852b24c01ed6321a2ba5 (patch)
tree3853834a6e426e597000023272855da3ee5526a1 /src/rustllvm
parente862efa65d24673be1471c2a41f45ed81f52cea1 (diff)
parent66fd1ebfae2fff815f27bf2be19469f40dd99c88 (diff)
downloadrust-47f66e7372e5e020d8c4852b24c01ed6321a2ba5.tar.gz
rust-47f66e7372e5e020d8c4852b24c01ed6321a2ba5.zip
Rollup merge of #53290 - whitequark:fix-35741, r=nagisa
Make LLVM emit assembly comments with -Z asm-comments

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
```
Diffstat (limited to 'src/rustllvm')
-rw-r--r--src/rustllvm/PassWrapper.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/rustllvm/PassWrapper.cpp b/src/rustllvm/PassWrapper.cpp
index 7305dc71cbf..d9fbd494ab3 100644
--- a/src/rustllvm/PassWrapper.cpp
+++ b/src/rustllvm/PassWrapper.cpp
@@ -366,7 +366,8 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine(
     bool PositionIndependentExecutable, bool FunctionSections,
     bool DataSections,
     bool TrapUnreachable,
-    bool Singlethread) {
+    bool Singlethread,
+    bool AsmComments) {
 
   auto OptLevel = fromRust(RustOptLevel);
   auto RM = fromRust(RustReloc);
@@ -393,6 +394,8 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine(
   }
   Options.DataSections = DataSections;
   Options.FunctionSections = FunctionSections;
+  Options.MCOptions.AsmVerbose = AsmComments;
+  Options.MCOptions.PreserveAsmComments = AsmComments;
 
   if (TrapUnreachable) {
     // Tell LLVM to codegen `unreachable` into an explicit trap instruction.