[PATCH] D108261: [DebugInfo] Fix end_sequence of debug_line in LTO Object

Kyungwoo Lee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 25 23:18:10 PDT 2021


kyulee added a comment.

In D108261#2966544 <https://reviews.llvm.org/D108261#2966544>, @dblaikie wrote:

> I'm a bit confused/unclear how this algorithm works/how this fixes things and whether it's the right direction. It'll be a while before I can find the time/brain bandwidth to really dig into this - so perhaps you can help me.
>
> What I'm confused by is why multiple line tables would be unterminated & then end up needing to terminate them all/figure out which one to terminate? Instead I'd expect whenever another line table got an entry, the previously current line table entry would need to end - so there shouldn't be a need for the extra maps & maybe we can just keep track of the current "open" line table (whichever was the last one to emit an entry)?

Here is my understanding. Basically a line table is emitted per compilation unit (CU). For simplicity, I consider two cases:

1. When multiple sections exist in a CU, we still want to emit them into a single line table (with multiple end_sequences per section).
2. In a LTO case, multiple CUs appear in a single (merged) object. In that case, we want to emit multiple line tables per CU.

So, this algorithm tries to track the end label of each function range per section in a CU. Likewise each line entries are already aggregated per section in a CU. This ensures emitting the end label per section per CU.
In case for asm parser path (instead of normal compilation path), those line entries/function range may not be emitted, so in that case (`EndLabel = null`), I fall back to the old logic that just uses the section end label conservatively.

This is two examples that this change tries to fix/improve.

1. Multiple sections in a CU case -- similar to Comdat (function per section).

  void f2()
  {
  }
  // The end of .text in CU line table
  
  __attribute__((section(".s1")))
  void f1()
  {
  }
  // The end of .s1 in CU line table
  __attribute__((nodebug,section(".s1")))
  void f1nodebug()
  {
  }
  // --> Before this change: The line table pointed to here because it's the end of the section .s1.
  
  #if 0
  // llvm-objdump -d t1.o
  Disassembly of section .text:
  
  0000000000000000 <f2>:
  ..
         5: c3                            retq
  
  Disassembly of section .s1:
  
  0000000000000000 <f1>:
  ..
         5: c3                            retq
  
  0000000000000010 <f1nodebug>:
  ..
        15: c3                            retq
  
  
  // llvm-dwarfdump --debugline t1.o
  Address            Line   Column File   ISA Discriminator Flags
  ------------------ ------ ------ ------ --- ------------- -------------
  0x0000000000000000      2      0      1   0             0  is_stmt
  0x0000000000000004      3      1      1   0             0  is_stmt prologue_end
  0x0000000000000006      3      1      1   0             0  is_stmt end_sequence
  0x0000000000000000      8      0      1   0             0  is_stmt
  0x0000000000000004      9      1      1   0             0  is_stmt prologue_end
  0x0000000000000006      9      1      1   0             0  is_stmt end_sequence ---> Before this change, it pointed to offset 16, the end of the section .s1.
  #endif



2. LTO case: Multiple CUs in a single section

  // LTO object effectively has the view of the merged CUs.
  // CU1 from t1.c
  void t1()
  {
  }
  // End of .text in CU1 line table
  
  // CU2 from t2.c
  void t2()
  {
  }
  // End of .text in CU2 line table
  
  #if 0
  $ llvm-objdump -d lto.o
  0000000000000000 <t1>:
  ...
         5: c3                            retq
  
  0000000000000010 <t2>:
  ..
        15: c3                            retq
  
  $ llvm-dwarfdump --debug-line lto.o
  Address            Line   Column File   ISA Discriminator Flags
  ------------------ ------ ------ ------ --- ------------- -------------
  0x0000000000000000      4      0      1   0             0  is_stmt
  0x0000000000000004      5      1      1   0             0  is_stmt prologue_end
  0x0000000000000006      5      1      1   0             0  is_stmt end_sequence --> Before this change, it pointed to offset 16 (the end of .text section).
  
  Address            Line   Column File   ISA Discriminator Flags
  ------------------ ------ ------ ------ --- ------------- -------------
  0x0000000000000010      4      0      1   0             0  is_stmt
  0x0000000000000014      5      1      1   0             0  is_stmt prologue_end
  0x0000000000000016      5      1      1   0             0  is_stmt end_sequence
  #endif


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108261



More information about the llvm-commits mailing list