[PATCH] D56587: Fix sign/zero extension in Dwarf expressions.

Markus Lavin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 1 06:37:44 PST 2019


markus updated this revision to Diff 184736.
markus added a comment.

Time to switch the approach. This time try adding support for typed Dwarf5 stack ops such as DW_OP_convert.

As an example in IR a `sext` would be represented as (where the `DW_OP_convert` arguments are indices into `dbg.dwarf5.type.tbl`):

  call void @llvm.dbg.value(metadata i8 %x, metadata !15, metadata !DIExpression(DW_OP_convert, 0, DW_OP_convert, 1, DW_OP_stack_value)), !dbg !17
  !dbg.dwarf5.type.tbl = !{!7, !8}
  !7 = !DIBasicType(name: "s8", size: 8, encoding: DW_ATE_signed)
  !8 = !DIBasicType(name: "s32", size: 32, encoding: DW_ATE_signed)

In assembly (x86) we get a labeled `base_type` entries in `.debug_info`

  .Ltype_tbl0:                                                                                                                                                                                                       
          .byte   2                       # Abbrev [2] 0x2a:0x7 DW_TAG_base_type                                                                                                                                     
          .long   .Linfo_string3          # DW_AT_name                                                                                                                                                               
          .byte   5                       # DW_AT_encoding                                                                                                                                                           
          .byte   1                       # DW_AT_byte_size                                                                                                                                                          
  .Ltype_tbl1:                                                                                                                                                                                                       
          .byte   2                       # Abbrev [2] 0x31:0x7 DW_TAG_base_type                                                                                                                                     
          .long   .Linfo_string4          # DW_AT_name                                                                                                                                                               
          .byte   5                       # DW_AT_encoding                                                                                                                                                           
          .byte   4                       # DW_AT_byte_size                                                                                                                                                          
          .byte   3                       # Abbrev [3] 0x38:0x38 DW_TAG_subprogram

that are referenced from the debug expression as in

  .byte   168                     # DW_OP_convert
  .uleb128 .Ltype_tbl0-.Lcu_begin0

As I see it the most significant benefit of this approach is that it would open up for using other typed DW5 ops as well.

Feedback please :)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56587/new/

https://reviews.llvm.org/D56587

Files:
  include/llvm/CodeGen/DIE.h
  lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp
  lib/CodeGen/AsmPrinter/DIEHash.cpp
  lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
  lib/CodeGen/AsmPrinter/DwarfDebug.cpp
  lib/CodeGen/AsmPrinter/DwarfDebug.h
  lib/CodeGen/AsmPrinter/DwarfExpression.cpp
  lib/IR/DebugInfoMetadata.cpp
  lib/Transforms/Utils/Local.cpp
  test/DebugInfo/X86/dwarf-pubnames-split.ll
  test/Transforms/InstCombine/cast-set-preserve-signed-dbg-val.ll
  unittests/Transforms/Utils/LocalTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56587.184736.patch
Type: text/x-patch
Size: 17271 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190201/50da9f73/attachment.bin>


More information about the llvm-commits mailing list