[PATCH] D147506: [DebugLine] save one debug line entry for empty prologue

David Blaikie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 8 17:01:35 PDT 2023


dblaikie added a comment.

In D147506#4323541 <https://reviews.llvm.org/D147506#4323541>, @shchenz wrote:

> In D147506#4322262 <https://reviews.llvm.org/D147506#4322262>, @dblaikie wrote:
>
>> In D147506#4321690 <https://reviews.llvm.org/D147506#4321690>, @shchenz wrote:
>>
>>> The buildbot failure is caused by instructions are inserted into prologue after empty prologue is checked. So if instructions are inserted to a empty prologue, because we save the first loc for empty prologue, then the inserted instructions will not appear in the debug line section because they are all after the first loc. So with such dwarf debug line, llvm-symbolizer can not find the location for these prologue instructions.
>>
>> ah, good to know. Guess that favors the "lazy" approach I was suggesting, then? (since that'll work more dynamically/based on the instructions that are emitted, rather than trying to compute it ahead of time)
>
> Hi @dblaikie Thanks for comments. I actually had same thought about check the prologue at a later time, for example, moving line 1012 ~ 1022 <https://github.com/llvm/llvm-project/blob/8f0eee16d9b420c0b5339bf9c386dc6cbbf29b42/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp#L1012-L1022> after line 1024 ~ 1045 <https://github.com/llvm/llvm-project/blob/8f0eee16d9b420c0b5339bf9c386dc6cbbf29b42/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp#L1024-L1045> . So that when checking the prologue, the instructions should already be inserted. However this does not work, because the codes inserted at line 1024 ~ 1045 <https://github.com/llvm/llvm-project/blob/8f0eee16d9b420c0b5339bf9c386dc6cbbf29b42/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp#L1024-L1045> are directly emitted to the final assembly/object, they are not linked to the MachineFunction. Iterating all instructions inside a function by using:
>
>   for (const auto &MBB : *MF)
>     for (const auto &MI : MBB)
>
> can not iterate through these instructions. So even in a lazy time removal(also apply to your proposal about handling in `beginInstruction() + recordSourceLine()` which is also driven by above iterating), we still have to explicit check in which cases instructions may be inserted to the prologue. And seems the instruction insertion at  line 1024 ~ 1045 <https://github.com/llvm/llvm-project/blob/8f0eee16d9b420c0b5339bf9c386dc6cbbf29b42/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp#L1024-L1045> looks good, I don't see other places in AsmPrinter calls `BuildMI` or something like that to add instructions to `MachineFunction`.

Ah :/ this again, feels to me like wanting something lower-level down in MC/MI to handle this... (what's the codepath that leads from this AsmPrinter.cpp 1024-1045 to BuildMI calls?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147506



More information about the llvm-commits mailing list