[PATCH] D117441: [DwarfDebug] Restore code that make comments stay aligned in DwarfDebug::emitDebugLocEntry

Bjorn Pettersson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 16 14:14:41 PST 2022


bjope created this revision.
bjope added reviewers: dblaikie, markus.
Herald added a subscriber: hiraditya.
bjope requested review of this revision.
Herald added a project: LLVM.

Commit 2bddab25dba8d4b0 <https://reviews.llvm.org/rG2bddab25dba8d4b0932dc2b6cacef13fcf8a0694> removed a piece of code from
DwarfDebug::emitDebugLocEntry that according to code comments
"Make sure comments stay aligned".

This patch restores that piece of code, together with the addition
of some extra checks in an existing lit test to work as a regression
test. Without this patch we incorrectly get

  .byte   159                             # 0

instead of

  .byte   159                             # DW_OP_stack_value


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D117441

Files:
  llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
  llvm/test/DebugInfo/X86/convert-loclist.ll


Index: llvm/test/DebugInfo/X86/convert-loclist.ll
===================================================================
--- llvm/test/DebugInfo/X86/convert-loclist.ll
+++ llvm/test/DebugInfo/X86/convert-loclist.ll
@@ -19,6 +19,16 @@
 ; extra bytes would be emitted into the output assembly in no
 ; particular/intentional section - so let's check they don't show up at all:
 ; ASM-NOT: .asciz  "\200\200\200"
+; ASM:      .byte   10                              # Loc expr size
+; ASM-NEXT: .byte   17                              # DW_OP_consts
+; ASM-NEXT: .byte   7                               # 7
+; ASM-NEXT: .byte   48                              # DW_OP_lit0
+; ASM-NEXT: .byte   34                              # DW_OP_plus
+; ASM-NEXT: .byte   168                             # DW_OP_convert
+; ASM-NEXT: .asciz  "\232\200\200"                  #
+; ASM-NEXT: .byte   159                             # DW_OP_stack_value
+; ASM-NEXT: .byte   0                               # DW_LLE_end_of_list
+; ASM-NOT: .asciz  "\200\200\200"
 
 ; CHECK: 0x{{0*}}[[TYPE:.*]]: DW_TAG_base_type
 ; CHECK-NEXT:                   DW_AT_name ("DW_ATE_unsigned_32")
Index: llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -2540,6 +2540,10 @@
         continue;
       if (Op.getDescription().Op[I] == Encoding::BaseTypeRef) {
         Streamer.emitDIERef(*CU->ExprRefedBaseTypes[Op.getRawOperand(I)].Die);
+        // Make sure comments stay aligned.
+        for (unsigned J = 0; J < ULEB128PadSize; ++J)
+          if (Comment != End)
+            Comment++;
       } else {
         for (uint64_t J = Offset; J < Op.getOperandEndOffset(I); ++J)
           Streamer.emitInt8(Data.getData()[J], Comment != End ? *(Comment++) : "");


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117441.400404.patch
Type: text/x-patch
Size: 1882 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220116/90f286ad/attachment.bin>


More information about the llvm-commits mailing list