This is an archive of the discontinued LLVM Phabricator instance.

[DebugInfo] Unify Cursor usage for all debug line opcodes
ClosedPublic

Authored by jhenderson on Jun 10 2020, 6:07 AM.

Details

Summary

This is a natural extension of the previous changes to use the Cursor class independently in the standard and extended opcode paths, and in turn allows delaying error handling until the entire line has been printed in verbose mode, removing interleaved output in some cases.

Depends on D81470.

Diff Detail

Event Timeline

jhenderson created this revision.Jun 10 2020, 6:07 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 10 2020, 6:07 AM
JDevlieghere accepted this revision.Jun 10 2020, 9:19 AM
This revision is now accepted and ready to land.Jun 10 2020, 9:19 AM
MaskRay added inline comments.Jun 11 2020, 2:10 PM
llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
767

What about hoisting Cursor and refactoring more *OffsetPtr to use Cursor?

jhenderson marked an inline comment as done.Jun 15 2020, 3:48 AM
jhenderson added inline comments.
llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
767

I considered that, but there are a few reasons not to:

  1. We handle errors differently depending on context. For extended opcodes, we continue parsing, which means we want to reset the Cursor to a good state after handling them. Recreating it at the start of the loop is easier.
  2. We'd have to do a no-op error check of the Cursor, to avoid an unchecked error situation in the event of an empty body.
  3. The only parsing outside the loop is the Prologue parsing, which has its own Cursor and is self-contained (not all clients that parse the prologue parse the body), meaning it doesn't make much sense to pass in the Cursor from outside. There is therefore no need to share said Cursor with anything else. The only benefit in hoisting it is therefore to avoid needing to reinitialise the Cursor on each iteration (but see above why this isn't that helpful).

@MaskRay, are you happy for me to land this as-is?

MaskRay accepted this revision.Jun 16 2020, 8:39 AM

Looks great!

This revision was automatically updated to reflect the committed changes.