[PATCH] D101421: [DebugInfo] Enable CodeView DebugInfo for basic block sections

TaoPan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 11 22:16:25 PDT 2021


TaoPan added inline comments.


================
Comment at: llvm/lib/MC/MCStreamer.cpp:331
-        Loc,
-        "all .cv_loc directives for a function must be in the same section");
-    return false;
----------------
rnk wrote:
> TaoPan wrote:
> > rnk wrote:
> > > This check prevents us from crashing later in CodeViewContext::emitLineTableForFunction when it calls:
> > >       OS.emitAbsoluteSymbolDiff(J->getLabel(), FuncBegin, 4);
> > > 
> > > If those two labels are in different sections, this just moves the crash later. Which makes me wonder if any BB section splitting happens in the test case you added. Does it exercise that yet, or does that come later?
> > > 
> > > The codeview line table format assumes functions are contiguous to avoid extra relocations. There is a relocation to the function start at the beginning, and the rest is a sequence of code offsets and line numbers. I wonder if it would be better to plan to produce a line table per section instead of trying to make one holistic line table. Then we could keep this check. So, if that is the long term plan, maybe we can leave this code here in this change.
> > Both removing and restoring this check, OS.emitAbsoluteSymbolDiff(J->getLabel(), FuncBegin, 4); of CodeViewContext::emitLineTableForFunction won't be called in my test.
> > I compared to llvm/test/DebugInfo/X86/basic-block-sections_1.ll (Linux ELF test), it's also not per section line table, it's per file line table, the format is as below, no function and section information.
> > Address            Line   Column File   ISA Discriminator Flags
> > 0x0000000000000000      1      0      1   0             0  is_stmt
> > Is there any reason that need per section line table?
> I'm pretty confident that we do reach emitAbsoluteSymbolDiff when emitting emitLineTableForFunction, but I discovered that it doesn't assert, it produces a relocation instead. I haven't reasoned through what the relocation does, but I see it in your test case. I confused emitAbsoluteSymbolDiff with the computeLabelDiff helper in the same file, see here:
> https://github.com/llvm/llvm-project/blob/main/llvm/lib/MC/MCCodeView.cpp#L454
> 
> So, I agree, removing this assertion doesn't cause a crash now, but it will if you introduce inlining into the test case and attempt to produce an inline line table. (.cv_inline_linetable).
> 
> Even though we don't crash in the non-inline line table case, it's not clear to me what a debugger would do with a an unsorted, non-ascending, possibly negative line table, which is what you would get after the linker applies relocations.
Thanks for your guidance!
I added inline function to test, I can produce an inline line table (.cv_inline_linetable) with llc to asm then llvm-mc to obj (line 2 and 4 in my test). I can reproduce your mentioned problem if llc directly to obj, I'm investigating the problem that Success is false in https://github.com/llvm/llvm-project/blob/main/llvm/lib/MC/MCCodeView.cpp#L454


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101421



More information about the llvm-commits mailing list