[PATCH] D99048: [RFC][DebugInfo] Do not use the DBG_VALUE to calculate debug info of spill location

Yifeng Dong via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 21 20:27:52 PDT 2021


dongAxis1944 created this revision.
Herald added subscribers: hiraditya, qcolombet.
dongAxis1944 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Considering the following c++ code:

  enum class TestEnum ...
  #define CHECK_GDB_TEST(s) ...
  
  __attribute__((noinline)) uint64_t
  TestBasicTypeNormal(uint8_t a, int8_t b, uint16_t c, int16_t d, uint32_t e,
                      int32_t f, uint64_t g, int64_t h, char i, const char *j,
                      const char k[], float l, double m, TestEnum n) {
    CHECK_GDB_TEST("coro_variable_test");
    uint64_t sum = a + b + c + d + e + f + g + h;
    double sum_f = l + m;
    CHECK_GDB_TEST("coro_variable_test");
    printf("%lu %lf %f %lf %c %s %s %s\n", sum, sum_f, l, m, i, j, k, n == TestEnum::TYPE_A ? "TYPE_A" : "TYPE_B");
    return sum;
  }

When we use gdb or lldb to debug this elf, we get the following ouput:

  Breakpoint 1, TestBasicTypeNormal (a=<optimized out>, a at entry=1 '\001', b=b at entry=10 '\n',
      c=c at entry=100, d=d at entry=1000, e=e at entry=10000, f=-854629579, f at entry=100000, g=100000000000,
      h=1000000000000, i=99 'c', j=0x4009b2 "hello", k=0x4009b8 "world", l=<optimized out>,
      m=0.87654321000000002, n=TestEnum::TYPE_B)
  22        printf("%lu %lf %f %lf %c %s %s %s\n", sum, sum_f, l, m, i, j, k, n == TestEnum::TYPE_A ? "TYPE_A" : "TYPE_B");
  (gdb)

We can find the variable l become -854629579. It is wried, because we did not change the value of l.
And after downloading the dwarf info:

  0x00001e3a:     DW_TAG_formal_parameter
                    DW_AT_location        (0x0000015e:
                       [0x0000000000400740, 0x000000000040077c): DW_OP_reg9 R9
                       [0x000000000040077c, 0x000000000040082e): DW_OP_breg7 RSP+8)
                    DW_AT_name    ("f")
                    DW_AT_decl_line       (16)
                    DW_AT_type    (0x00001254 "int32_t")

It shows f should be in [rsp + 8] between 0x000000000040077c and 0x000000000040082e.
But it is not right after checking the assembly code:

  40075a:       44 89 4c 24 08          mov    %r9d,0x8(%rsp)    ----> r9d is l, and it save to the rsp+8
  ....
  4007bc:       f2 0f 11 44 24 08       movsd  %xmm0,0x8(%rsp)   ---->  save xmm0 to the rsp+8 without notify the dwarf

So the problem is clear, llvm failed to calculate dwarf interval for spill location.
I use this patch to fix the problems, but I do not know whether it is right.


https://reviews.llvm.org/D99048

Files:
  llvm/lib/CodeGen/InlineSpiller.cpp
  llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99048.332191.patch
Type: text/x-patch
Size: 4289 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210322/4039edef/attachment.bin>


More information about the llvm-commits mailing list