<div dir="ltr">Nice!</div><br><div class="gmail_quote"><div dir="ltr">On Tue, Apr 25, 2017 at 10:35 AM Adrian Prantl via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: adrian<br>
Date: Tue Apr 25 12:22:09 2017<br>
New Revision: 301333<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=301333&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=301333&view=rev</a><br>
Log:<br>
Print complete DIExpressions in the assembler output DEBUG_VALUE comments.<br>
<br>
The previous code was complex, incorrect, and couldn't print everything.<br>
<br>
Modified:<br>
llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp<br>
llvm/trunk/test/DebugInfo/COFF/pieces.ll<br>
llvm/trunk/test/DebugInfo/X86/debug-loc-asan.ll<br>
llvm/trunk/test/DebugInfo/X86/op_deref.ll<br>
llvm/trunk/test/DebugInfo/X86/pieces-4.ll<br>
llvm/trunk/test/DebugInfo/X86/this-stack_value.ll<br>
llvm/trunk/test/DebugInfo/X86/vla.ll<br>
<br>
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=301333&r1=301332&r2=301333&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=301333&r1=301332&r2=301333&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Tue Apr 25 12:22:09 2017<br>
@@ -825,43 +825,25 @@ static bool emitDebugValueComment(const<br>
OS << Name << ":";<br>
}<br>
OS << V->getName();<br>
-<br>
- const DIExpression *Expr = MI->getDebugExpression();<br>
- auto Fragment = Expr->getFragmentInfo();<br>
- if (Fragment)<br>
- OS << " [fragment offset=" << Fragment->OffsetInBits<br>
- << " size=" << Fragment->SizeInBits << "]";<br>
OS << " <- ";<br>
<br>
// The second operand is only an offset if it's an immediate.<br>
- bool Deref = false;<br>
bool MemLoc = MI->getOperand(0).isReg() && MI->getOperand(1).isImm();<br>
int64_t Offset = MemLoc ? MI->getOperand(1).getImm() : 0;<br>
- for (unsigned i = 0; i < Expr->getNumElements(); ++i) {<br>
- uint64_t Op = Expr->getElement(i);<br>
- if (Op == dwarf::DW_OP_LLVM_fragment) {<br>
- // There can't be any operands after this in a valid expression<br>
- break;<br>
- } else if (Deref) {<br>
- // We currently don't support extra Offsets or derefs after the first<br>
- // one. Bail out early instead of emitting an incorrect comment.<br>
- OS << " [complex expression]";<br>
- AP.OutStreamer->emitRawComment(OS.str());<br>
- return true;<br>
- } else if (Op == dwarf::DW_OP_deref) {<br>
- Deref = true;<br>
- continue;<br>
- }<br>
-<br>
- uint64_t ExtraOffset = Expr->getElement(i++);<br>
- if (Op == dwarf::DW_OP_plus)<br>
- Offset += ExtraOffset;<br>
- else if (Op == dwarf::DW_OP_stack_value)<br>
- OS << " [stack value]";<br>
- else {<br>
- assert(Op == dwarf::DW_OP_minus);<br>
- Offset -= ExtraOffset;<br>
+ const DIExpression *Expr = MI->getDebugExpression();<br>
+ if (Expr->getNumElements()) {<br>
+ OS << '[';<br>
+ bool NeedSep = false;<br>
+ for (auto Op : Expr->expr_ops()) {<br>
+ if (NeedSep)<br>
+ OS << ", ";<br>
+ else<br>
+ NeedSep = true;<br>
+ OS << dwarf::OperationEncodingString(Op.getOp());<br>
+ for (unsigned I = 0; I < Op.getNumArgs(); ++I)<br>
+ OS << ' ' << Op.getArg(I);<br>
}<br>
+ OS << "] ";<br>
}<br>
<br>
// Register or immediate value. Register 0 means undef.<br>
@@ -892,7 +874,7 @@ static bool emitDebugValueComment(const<br>
const TargetFrameLowering *TFI = AP.MF->getSubtarget().getFrameLowering();<br>
Offset += TFI->getFrameIndexReference(*AP.MF,<br>
MI->getOperand(0).getIndex(), Reg);<br>
- Deref = true;<br>
+ MemLoc = true;<br>
}<br>
if (Reg == 0) {<br>
// Suppress offset, it is not meaningful here.<br>
@@ -901,12 +883,12 @@ static bool emitDebugValueComment(const<br>
AP.OutStreamer->emitRawComment(OS.str());<br>
return true;<br>
}<br>
- if (MemLoc || Deref)<br>
+ if (MemLoc)<br>
OS << '[';<br>
OS << PrintReg(Reg, AP.MF->getSubtarget().getRegisterInfo());<br>
}<br>
<br>
- if (MemLoc || Deref)<br>
+ if (MemLoc)<br>
OS << '+' << Offset << ']';<br>
<br>
// NOTE: Want this comment at start of line, don't emit with AddComment.<br>
<br>
Modified: llvm/trunk/test/DebugInfo/COFF/pieces.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/pieces.ll?rev=301333&r1=301332&r2=301333&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/pieces.ll?rev=301333&r1=301332&r2=301333&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/DebugInfo/COFF/pieces.ll (original)<br>
+++ llvm/trunk/test/DebugInfo/COFF/pieces.ll Tue Apr 25 12:22:09 2017<br>
@@ -35,27 +35,27 @@<br>
; }<br>
<br>
; ASM-LABEL: loop_csr: # @loop_csr<br>
-; ASM: #DEBUG_VALUE: loop_csr:o [fragment offset=0 size=32] <- 0<br>
-; ASM: #DEBUG_VALUE: loop_csr:o [fragment offset=32 size=32] <- 0<br>
+; ASM: #DEBUG_VALUE: loop_csr:o <- [DW_OP_LLVM_fragment 0 32] 0<br>
+; ASM: #DEBUG_VALUE: loop_csr:o <- [DW_OP_LLVM_fragment 32 32] 0<br>
; ASM: # BB#2: # %for.body.preheader<br>
; ASM: xorl %edi, %edi<br>
; ASM: xorl %esi, %esi<br>
; ASM: .p2align 4, 0x90<br>
; ASM: .LBB0_3: # %for.body<br>
; ASM: [[ox_start:\.Ltmp[0-9]+]]:<br>
-; ASM: #DEBUG_VALUE: loop_csr:o [fragment offset=0 size=32] <- %EDI<br>
+; ASM: #DEBUG_VALUE: loop_csr:o <- [DW_OP_LLVM_fragment 0 32] %EDI<br>
; ASM: .cv_loc 0 1 13 11 # t.c:13:11<br>
; ASM: movl %edi, %ecx<br>
; ASM: callq g<br>
; ASM: movl %eax, %edi<br>
; ASM: [[oy_start:\.Ltmp[0-9]+]]:<br>
-; ASM: #DEBUG_VALUE: loop_csr:o [fragment offset=0 size=32] <- %EDI<br>
-; ASM: #DEBUG_VALUE: loop_csr:o [fragment offset=32 size=32] <- %ESI<br>
+; ASM: #DEBUG_VALUE: loop_csr:o <- [DW_OP_LLVM_fragment 0 32] %EDI<br>
+; ASM: #DEBUG_VALUE: loop_csr:o <- [DW_OP_LLVM_fragment 32 32] %ESI<br>
; ASM: .cv_loc 0 1 14 11 # t.c:14:11<br>
; ASM: movl %esi, %ecx<br>
; ASM: callq g<br>
; ASM: movl %eax, %esi<br>
-; ASM: #DEBUG_VALUE: loop_csr:o [fragment offset=32 size=32] <- %ESI<br>
+; ASM: #DEBUG_VALUE: loop_csr:o <- [DW_OP_LLVM_fragment 32 32] %ESI<br>
; ASM: cmpl n(%rip), %eax<br>
; ASM: jl .LBB0_3<br>
; ASM: [[oy_end:\.Ltmp[0-9]+]]:<br>
@@ -64,32 +64,32 @@<br>
<br>
<br>
; ASM-LABEL: pad_right: # @pad_right<br>
-; ASM: #DEBUG_VALUE: pad_right:o [fragment offset=32 size=32] <- %ECX<br>
+; ASM: #DEBUG_VALUE: pad_right:o <- [DW_OP_LLVM_fragment 32 32] %ECX<br>
; ASM: movl %ecx, %eax<br>
; ASM: retq<br>
<br>
<br>
; ASM-LABEL: pad_left: # @pad_left<br>
-; ASM: #DEBUG_VALUE: pad_left:o [fragment offset=0 size=32] <- %ECX<br>
+; ASM: #DEBUG_VALUE: pad_left:o <- [DW_OP_LLVM_fragment 0 32] %ECX<br>
; ASM: .cv_loc 2 1 24 3 # t.c:24:3<br>
; ASM: movl %ecx, %eax<br>
; ASM: retq<br>
<br>
<br>
; ASM-LABEL: nested: # @nested<br>
-; ASM: #DEBUG_VALUE: nested:o <- [%RCX+0]<br>
+; ASM: #DEBUG_VALUE: nested:o <- [DW_OP_deref] [%RCX+0]<br>
; ASM: movl 12(%rcx), %eax<br>
; ASM: [[p_start:\.Ltmp[0-9]+]]:<br>
-; ASM: #DEBUG_VALUE: nested:p [fragment offset=32 size=32] <- %EAX<br>
+; ASM: #DEBUG_VALUE: nested:p <- [DW_OP_LLVM_fragment 32 32] %EAX<br>
; ASM: retq<br>
<br>
; ASM-LABEL: bitpiece_spill: # @bitpiece_spill<br>
-; ASM: #DEBUG_VALUE: bitpiece_spill:o [fragment offset=0 size=32] <- 0<br>
+; ASM: #DEBUG_VALUE: bitpiece_spill:o <- [DW_OP_LLVM_fragment 0 32] 0<br>
; ASM: xorl %ecx, %ecx<br>
; ASM: callq g<br>
; ASM: movl %eax, [[offset_o_x:[0-9]+]](%rsp) # 4-byte Spill<br>
; ASM: [[spill_o_x_start:\.Ltmp[0-9]+]]:<br>
-; ASM: #DEBUG_VALUE: bitpiece_spill:o [fragment offset=32 size=32] <- [%RSP+[[offset_o_x]]]<br>
+; ASM: #DEBUG_VALUE: bitpiece_spill:o <- [DW_OP_LLVM_fragment 32 32] [%RSP+[[offset_o_x]]]<br>
; ASM: #APP<br>
; ASM: #NO_APP<br>
; ASM: movl [[offset_o_x]](%rsp), %eax # 4-byte Reload<br>
<br>
Modified: llvm/trunk/test/DebugInfo/X86/debug-loc-asan.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/debug-loc-asan.ll?rev=301333&r1=301332&r2=301333&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/debug-loc-asan.ll?rev=301333&r1=301332&r2=301333&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/DebugInfo/X86/debug-loc-asan.ll (original)<br>
+++ llvm/trunk/test/DebugInfo/X86/debug-loc-asan.ll Tue Apr 25 12:22:09 2017<br>
@@ -12,10 +12,10 @@<br>
; The address of the (potentially now malloc'ed) alloca ends up<br>
; in RDI, after which it is spilled to the stack. We record the<br>
; spill OFFSET on the stack for checking the debug info below.<br>
-; CHECK: #DEBUG_VALUE: bar:y <- [%RDI+0]<br>
+; CHECK: #DEBUG_VALUE: bar:y <- [DW_OP_deref] [%RDI+0]<br>
; CHECK: movq %rdi, [[OFFSET:[0-9]+]](%rsp)<br>
; CHECK-NEXT: [[START_LABEL:.Ltmp[0-9]+]]<br>
-; CHECK-NEXT: #DEBUG_VALUE: bar:y <- [complex expression]<br>
+; CHECK-NEXT: #DEBUG_VALUE: bar:y <- [DW_OP_deref, DW_OP_deref]<br>
; This location should be valid until the end of the function.<br>
<br>
; CHECK: movq %rbp, %rsp<br>
<br>
Modified: llvm/trunk/test/DebugInfo/X86/op_deref.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/op_deref.ll?rev=301333&r1=301332&r2=301333&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/op_deref.ll?rev=301333&r1=301332&r2=301333&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/DebugInfo/X86/op_deref.ll (original)<br>
+++ llvm/trunk/test/DebugInfo/X86/op_deref.ll Tue Apr 25 12:22:09 2017<br>
@@ -20,7 +20,7 @@<br>
; right now, so we check the asm output:<br>
; RUN: llc -O0 -mtriple=x86_64-apple-darwin %s -o - -filetype=asm | FileCheck %s -check-prefix=ASM-CHECK<br>
; vla should have a register-indirect address at one point.<br>
-; ASM-CHECK: DEBUG_VALUE: vla <- [%RCX+0]<br>
+; ASM-CHECK: DEBUG_VALUE: vla <- [DW_OP_deref] [%RCX+0]<br>
; ASM-CHECK: DW_OP_breg2<br>
<br>
; RUN: llvm-as %s -o - | llvm-dis - | FileCheck %s --check-prefix=PRETTY-PRINT<br>
<br>
Modified: llvm/trunk/test/DebugInfo/X86/pieces-4.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/pieces-4.ll?rev=301333&r1=301332&r2=301333&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/pieces-4.ll?rev=301333&r1=301332&r2=301333&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/DebugInfo/X86/pieces-4.ll (original)<br>
+++ llvm/trunk/test/DebugInfo/X86/pieces-4.ll Tue Apr 25 12:22:09 2017<br>
@@ -15,8 +15,8 @@<br>
; CHECK-LABEL: bitpiece_spill: # @bitpiece_spill<br>
; CHECK: callq g<br>
; CHECK: movl %eax, [[offs:[0-9]+]](%rsp) # 4-byte Spill<br>
-; CHECK: #DEBUG_VALUE: bitpiece_spill:o [fragment offset=32 size=32] <- 0<br>
-; CHECK: #DEBUG_VALUE: bitpiece_spill:o [fragment offset=0 size=32] <- [%RSP+[[offs]]]<br>
+; CHECK: #DEBUG_VALUE: bitpiece_spill:o <- [DW_OP_LLVM_fragment 32 32] 0<br>
+; CHECK: #DEBUG_VALUE: bitpiece_spill:o <- [DW_OP_LLVM_fragment 0 32] [%RSP+[[offs]]]<br>
; CHECK: #APP<br>
; CHECK: #NO_APP<br>
; CHECK: movl [[offs]](%rsp), %eax # 4-byte Reload<br>
<br>
Modified: llvm/trunk/test/DebugInfo/X86/this-stack_value.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/this-stack_value.ll?rev=301333&r1=301332&r2=301333&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/this-stack_value.ll?rev=301333&r1=301332&r2=301333&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/DebugInfo/X86/this-stack_value.ll (original)<br>
+++ llvm/trunk/test/DebugInfo/X86/this-stack_value.ll Tue Apr 25 12:22:09 2017<br>
@@ -17,7 +17,7 @@<br>
; The inlined A::this pointer has the same location as B::this, but it may not be<br>
; modified by the debugger.<br>
;<br>
-; ASM: [stack value]<br>
+; ASM: [DW_OP_stack_value]<br>
; CHECK: Location description: 70 00 9f<br>
; rax+0, stack-value<br>
source_filename = "ab.cpp"<br>
<br>
Modified: llvm/trunk/test/DebugInfo/X86/vla.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/vla.ll?rev=301333&r1=301332&r2=301333&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/vla.ll?rev=301333&r1=301332&r2=301333&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/DebugInfo/X86/vla.ll (original)<br>
+++ llvm/trunk/test/DebugInfo/X86/vla.ll Tue Apr 25 12:22:09 2017<br>
@@ -1,6 +1,6 @@<br>
; RUN: llc -O0 -mtriple=x86_64-apple-darwin -filetype=asm %s -o - | FileCheck %s<br>
; Ensure that we generate an indirect location for the variable length array a.<br>
-; CHECK: ##DEBUG_VALUE: vla:a <- [%RCX+0]<br>
+; CHECK: ##DEBUG_VALUE: vla:a <- [DW_OP_deref] [%RCX+0]<br>
; CHECK: DW_OP_breg2<br>
; rdar://problem/13658587<br>
;<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>