[PATCH] D87233: [POC][DebugInfo] Use entry values within IR

Djordje Todorovic via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 7 06:45:17 PDT 2020


djtodoro created this revision.
djtodoro added reviewers: dblaikie, aprantl, vsk, dstenb.
djtodoro added projects: debug-info, LLVM.
Herald added subscribers: llvm-commits, ormris, hiraditya, MatzeB.
djtodoro requested review of this revision.

Using entry values on IR will give us better debugging user experience when debugging "optimized" code (swift uses llvm.dbg.values even in non-optimized code, so this refers to that code as well). This patch implements a utility (within Transforms/Utils/Local.cpp) that finds an entry Value for a given Variable.

Consider this (simple) test case:

  void f1(int);
  void f2(int i) {
    f1(1);
    i = i + 5;
    f1(3);
  }

IR (//$ clang -g -O2 -S//) for the func looks:

  define dso_local void @f2(i32 %i) local_unnamed_addr !dbg !7 {
  entry:
    call void @llvm.dbg.value(metadata i32 %i, metadata !12, metadata !DIExpression()), !dbg !13
    tail call void @f1(i32 1), !dbg !14
    call void @llvm.dbg.value(metadata i32 %i, metadata !12, metadata !DIExpression(DW_OP_plus_uconst, 5, DW_OP_stack_value)), !dbg !13
    tail call void @f1(i32 3), !dbg !15
    ret void, !dbg !16
  }

SelectionDAG for the second dbg.value generates:

  DBG_VALUE $noreg, $noreg, !"i", !DIExpression(DW_OP_plus_uconst, 5, DW_OP_stack_value), debug-location !13; test.c:0 line no:2

After this patch, we will salvage the value by using the entry values, so the `DBG_VALUE` looks as following:

  DBG_VALUE $edi, $noreg, !12, !DIExpression(DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 5, DW_OP_stack_value), debug-location !13

The patch isn't for commit yet, since there are some test failing, but I haven't had time (yet) to take a look into these.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87233

Files:
  llvm/include/llvm/Transforms/Utils/Local.h
  llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp
  llvm/lib/CodeGen/SelectionDAG/InstrEmitter.cpp
  llvm/lib/CodeGen/SelectionDAG/InstrEmitter.h
  llvm/lib/CodeGen/SelectionDAG/ScheduleDAGFast.cpp
  llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
  llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.h
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
  llvm/lib/IR/DebugInfoMetadata.cpp
  llvm/lib/Transforms/Utils/Local.cpp
  llvm/test/DebugInfo/X86/entry-values-for-isel-invalidated-nodes.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87233.290277.patch
Type: text/x-patch
Size: 14457 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200907/6de3e0c2/attachment.bin>


More information about the llvm-commits mailing list