This is an archive of the discontinued LLVM Phabricator instance.

Change DW_LLE_baseaddr to DW_LLE_baseaddrx in .debug_loclist section
ClosedPublic

Authored by rastogishubham on Jul 19 2023, 9:39 AM.

Details

Summary

With https://reviews.llvm.org/D154638, the ability to emit a .debug_addr section has been added to dsymutil. With this, instead of emitting a DW_LLE_baseaddr in the .debug_loclist section, a DW_LLE_baseaddrx can be emitted instead, which will allow for more indirection.

I opted for DW_LLE_baseaddrx + DW_LLE_offset_pair because using a DW_LLE_startx_length, because the latter would cause more entries to appear in the .debug_addr section which may lead to the size of the .debug_addr section blowing up considerably

Diff Detail

Event Timeline

rastogishubham created this revision.Jul 19 2023, 9:39 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 19 2023, 9:39 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
rastogishubham requested review of this revision.Jul 19 2023, 9:39 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 19 2023, 9:39 AM
aprantl added inline comments.Jul 19 2023, 9:50 AM
llvm/include/llvm/DWARFLinker/DWARFLinker.h
654

This hasn't been introduced by this patch, but I'm curious why we need to store the addresses twice? Would AddrIndexMap.insert(std::make_pair(Addr, AddrIndexMap.size())) work just as well?

llvm/lib/DWARFLinker/DWARFLinker.cpp
2002

should we assert(BaseAddress) here to make sure Index was initialized?

llvm/lib/DWARFLinker/DWARFStreamer.cpp
547

Should this be called BaseAddressIndex?

665

ditto

llvm/include/llvm/DWARFLinker/DWARFLinker.h
654

It is a matter of space vs size, if we get rid of SmallVector<uint64_t> Addrs; we will have to sort the AddrIndexMap by index and then output the .debug_addr section.

aprantl added inline comments.Jul 19 2023, 12:38 PM
llvm/include/llvm/DWARFLinker/DWARFLinker.h
654

Right. I forgot we need to write out the stuff, too ;-)

llvm/include/llvm/DWARFLinker/DWARFLinker.h
654

Space vs time*

Sorry about that

avl added inline comments.Jul 20 2023, 3:55 AM
llvm/include/llvm/DWARFLinker/DWARFLinker.h
829–830

probably we can make generateUnitLocations to be method of DIECloner as it looks compile unit local?

llvm/lib/DWARFLinker/DWARFLinker.cpp
1997

it looks like duplication of what is going on inside emitDwarfDebugLocListsTableFragment(). probably instead of passing Index into emitDwarfDebugLocListsTableFragment we would pass DebugAddrPool ?

LocListsSectionSize += MS->emitULEB128IntValue(AddrPool.getAddrIndex(*BaseAddress));

It makes unnecessary this additional index calculation and duplicating BaseAddress variable.

rastogishubham marked 6 inline comments as done.

Moved generateUnitLocations into DIECloner

Pass AddrPool to DWARFStreamer::emitDwarfDebugLocListFragment` to calculate baseaddrx index there instead of passing index in

rastogishubham marked an inline comment as done.Jul 20 2023, 6:35 PM

Fix test failures in dwarf5-loclists.test

avl accepted this revision.Jul 21 2023, 4:33 AM

LGTM, Thanks! Please, pay attention that patch application failed.

This revision is now accepted and ready to land.Jul 21 2023, 4:33 AM

Rebased on top of main

@avl I imagine the patch application failed because this patch depends on https://reviews.llvm.org/D154638 going in?

avl added a comment.Jul 21 2023, 2:30 PM

@avl I imagine the patch application failed because this patch depends on https://reviews.llvm.org/D154638 going in?

yes, application failed because this patch depends on https://reviews.llvm.org/D154638 and one or both of these two patches probably need rebasing.