[PATCH] D45045: [DebugInfo] Generate debug information for labels.

Edd Barrett via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 7 05:45:26 PDT 2018


vext01 added a comment.

Got one!

Here's a dumb program which simply adds 3 to 1 using a function. There is one label in the `add_3` function, named `XXXYYYZZZ`:

  ; ModuleID = 'mymod'
  source_filename = "mymod"
  
  define i32 @add_3(i32 %x) !dbg !3 {
  entry:
    %res = add i32 %x, 3, !dbg !9
    call void @llvm.dbg.label(metadata !8), !dbg !9
    ret i32 %res, !dbg !9
  }
  
  ; Function Attrs: nounwind readnone speculatable
  declare void @llvm.dbg.label(metadata) #0
  
  define i32 @main() {
  entry:
    %0 = call i32 @add_3(i32 1)
    ret i32 %0
  }
  
  attributes #0 = { nounwind readnone speculatable }
  
  !llvm.module.flags = !{!0}
  !llvm.dbg.cu = !{!1}
  
  !0 = !{i32 2, !"Debug Info Version", i32 3}
  !1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "API Example", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
  !2 = !DIFile(filename: "main.xxx", directory: ".")
  !3 = distinct !DISubprogram(name: "add_3", scope: null, file: !2, type: !4, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, isOptimized: false, unit: !1, retainedNodes: !7)
  !4 = !DISubroutineType(types: !5)
  !5 = !{!6, !6}
  !6 = !DIBasicType(name: "u32", size: 32, encoding: DW_ATE_unsigned)
  !7 = !{!8}
  !8 = !DILabel(scope: !3, name: "XXXYYYZZZ", file: !2, line: 1)
  !9 = !DILocation(line: 0, column: 1, scope: !3)

If we compile this (using LLVM just before your change was backed out), and inspect the debuginfo:

  $ clang -g -c -O0 -o example.o example.ll
  warning: overriding the module target triple with x86_64-unknown-linux-gnu [-Woverride-module]
  1 warning generated.
  $ dwarfdump example.o
  ...
  < 2><0x00000041>      DW_TAG_label
                          DW_AT_name                  XXXYYYZZZ
                          DW_AT_decl_file             0x00000001 ./main.xxx
                          DW_AT_decl_line             0x00000001
                          DW_AT_low_pc                0x00000000
  ...

Here we can see that `DW_AT_low_pc` is 0. What does this mean? Perhaps a bug? The code is clearly not dead, although I would understand if `add_3` were inlined. Either way, I'd expect a non-zero `low_pc`, right?


Repository:
  rL LLVM

https://reviews.llvm.org/D45045





More information about the cfe-commits mailing list