This is an archive of the discontinued LLVM Phabricator instance.

[DebugInfo] Align comments in debug_loc section
ClosedPublic

Authored by bjope on Jan 5 2018, 4:50 AM.

Details

Summary

This commit updates the BufferByteStreamer, used by DebugLocStream
to buffer bytes/comments to put in the debug_loc section, to
make sure that the Buffer and Comments vectors are synced.
Previously, when an SLEB128 or ULEB128 was emitted together with
a comment, the vectors could be out-of-sync if the LEB encoding
added several entries to the Buffer vectors, while we only added
a single entry to the Comments vector.

The goal with this is to get the comments in the debug_loc
section in the .s file correctly aligned.

Example (using ARM as target):
Instead of

.byte 144                     @ sub-register DW_OP_regx
.byte 128                     @ 256
.byte 2                       @ DW_OP_piece
.byte 147                     @ 8
.byte 8                       @ sub-register DW_OP_regx
.byte 144                     @ 257
.byte 129                     @ DW_OP_piece
.byte 2                       @ 8
.byte 147                     @
.byte 8                       @

we now get

.byte 144                     @ sub-register DW_OP_regx
.byte 128                     @ 256
.byte 2                       @
.byte 147                     @ DW_OP_piece
.byte 8                       @ 8
.byte 144                     @ sub-register DW_OP_regx
.byte 129                     @ 257
.byte 2                       @
.byte 147                     @ DW_OP_piece
.byte 8                       @ 8

Event Timeline

bjope created this revision.Jan 5 2018, 4:50 AM
bjope added a subscriber: uabelho.Jan 5 2018, 4:59 AM
Ka-Ka added a subscriber: Ka-Ka.Jan 5 2018, 7:32 AM
davide added a subscriber: davide.Jan 5 2018, 7:35 AM
aprantl accepted this revision.Jan 5 2018, 8:41 AM

Looks good, thanks!

This revision is now accepted and ready to land.Jan 5 2018, 8:41 AM
This revision was automatically updated to reflect the committed changes.