This is an archive of the discontinued LLVM Phabricator instance.

[DwarfDebug] Restore code that make comments stay aligned in DwarfDebug::emitDebugLocEntry
ClosedPublic

Authored by bjope on Jan 16 2022, 2:14 PM.

Details

Summary

Commit 2bddab25dba8d4b0 removed a piece of code from
DwarfDebug::emitDebugLocEntry that according to code comments
"Make sure comments stay aligned".

This patch restores that piece of code, together with the addition
of some extra checks in an existing lit test to work as a regression
test. Without this patch we incorrectly get

.byte   159                             # 0

instead of

.byte   159                             # DW_OP_stack_value

Diff Detail

Event Timeline

bjope created this revision.Jan 16 2022, 2:14 PM
bjope requested review of this revision.Jan 16 2022, 2:14 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 16 2022, 2:14 PM
dstenb added a subscriber: dstenb.Jan 16 2022, 11:46 PM

This seems like a fairly subtle/long distance dependence now, that "emitDIERef" will use the same ULEB128PadSize as this code uses? Which isn't necessarily true/could become divergent relatively easily.

This seems like a fairly subtle/long distance dependence now, that "emitDIERef" will use the same ULEB128PadSize as this code uses? Which isn't necessarily true/could become divergent relatively easily.

Yes, that could be true.

Honestly, I do not really know how it works with these comments. For example:

  • How comes that we should skip (up-to) ULEB128PadSize comments for Encoding::BaseTypeRef? Why is it like that?
  • Why are we just skipping comments and not printing them?

I was thinking that I could add a Twine argument to emitDIERef similarly to those found for emitInt8. But that felt weird since we just skip comments, not printing them. And I would need to pass the Iterator in order to step it multiple times.

Well, this patch simply restores the code needed to make our downstream test cases working again (we had some lit tests that used FileCheck lines to verify the debug section, including the comments, and those tests have been failing after commit 2bddab25dba8d4b0 due to the comments being totally messed up).

Perhaps a reasonable intermediate solution would be to return the pad size from emitDIERef? (or have an exposed constant in ByteStreamer that's used in emitDIERef and can be used from the DwarfDebug code) and use that value in the DwarfDebug code so the values can't diverge, at least...

bjope updated this revision to Diff 400644.Jan 17 2022, 2:21 PM

Utilize a return value from APByteStreamer::emitDIERef to determine how many comments to skip.

dblaikie accepted this revision.Jan 17 2022, 2:32 PM

Looks OK, thanks!

This revision is now accepted and ready to land.Jan 17 2022, 2:32 PM
This revision was landed with ongoing or failed builds.Jan 18 2022, 12:57 AM
This revision was automatically updated to reflect the committed changes.