This is an archive of the discontinued LLVM Phabricator instance.

Fix -u option in dsymutil, to not emit an extra DW_LNE_set_address if the original line table was empty
ClosedPublic

Authored by rastogishubham on May 26 2023, 12:11 PM.

Details

Summary

With dsymutil's -u option, only the accelerator tables should be updated, but with https://reviews.llvm.org/D150554 the -u option will still re-generate the line table. If the line table was empty, that is, it was a dummy line table, with no entries in it, dsymutil will always generate a line table with a DW_LNE_end_sequence, a funky side effect of this is that when the line table is re-generated, it will always emit a DW_LNE_set_address first, which will change the line table total size. This patch addresses this by making sure that if all the line table has in it is a DW_LNE_end_sequence, it is the same as a dummy entry.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptMay 26 2023, 12:11 PM
rastogishubham requested review of this revision.May 26 2023, 12:11 PM
Herald added a project: Restricted Project. · View Herald Transcript
aprantl accepted this revision.May 26 2023, 12:53 PM
This revision is now accepted and ready to land.May 26 2023, 12:53 PM

Removed the

REQUIRES: darwin

line in the test

JDevlieghere added inline comments.May 26 2023, 2:18 PM
llvm/lib/DWARFLinker/DWARFStreamer.cpp
854–855 ↗(On Diff #526170)

Would it make sense to hoist that into the LineTable class and have a method LineTable::empty() that returns exactly this?

avl added inline comments.May 29 2023, 2:07 PM
llvm/lib/DWARFLinker/DWARFStreamer.cpp
854–855 ↗(On Diff #526170)

In that case LineTable::empty() would in fact not match with real number of LineTable.Rows(). It looks a bit sloppy.

Another alternative might be implementing what described in DWARFLinker.cpp:

// FIXME: this only removes the unneeded end_sequence if the
// sequences have been inserted in order. Using a global sort like
// described in generateLineTableForUnit() and delaying the end_sequene
// elimination to emitLineTableForUnit() we can get rid of all of them.

Running such cleanup code for no-update and update modes will probably make output equal for both modes.

avl added inline comments.May 29 2023, 2:20 PM
llvm/lib/DWARFLinker/DWARFStreamer.cpp
854–855 ↗(On Diff #526170)

Or, if it is not a good moment to implementing such cleanup code then do simple version of it in DWARFLinker.cpp:

// Set Line Table Rows.
if (Linker.Options.Update) {
  LineTable.Rows = LT->Rows; 
  if (LineTable.Rows.size() == 1 && LineTable.Rows[0].EndSequence))
     LineTable.Rows.clear()
rastogishubham marked an inline comment as done.

clear the line table rows, if the update flag is set, and the line table just has a DW_LNE_end_sequence in DWARFLinker.cpp

avl accepted this revision.May 30 2023, 12:34 PM

LGTM. Thank you!

This revision was landed with ongoing or failed builds.May 30 2023, 9:37 PM
This revision was automatically updated to reflect the committed changes.