This is an archive of the discontinued LLVM Phabricator instance.

[DebugInfo] Allow <Symbol, Offset> pairs in AddressPool [NFC]
AbandonedPublic

Authored by dstenb on Oct 4 2019, 7:47 AM.

Details

Summary

This is a preparatory commit for D68465. That commit introduces location
list range trimming for values that are call-clobbered, in order to
improve compatibility with GDB. If a variable is described by a mix of
values that are call-clobbered and those that are not, then we need to
be able to start a location list entry inside the call instruction for
all values that are not call-clobbered. This commit adds support for
inserting such expressions in the address pool.

My initial thought was to allow MCExprs in the address pool, but I gave
up on that idea when I did not find a good way to unique them, and went
with simple <Symbol, Offset> pairs instead, as I did not foresee the
need for more advanced expressions.

D68465 only adds tests for cases where the offset is negative. I'm not
sure how to test cases where the offset is positive. Should that be
covered by an assert instead?

Diff Detail

Event Timeline

dstenb created this revision.Oct 4 2019, 7:47 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 4 2019, 7:48 AM
aprantl added inline comments.Oct 7 2019, 5:26 PM
llvm/lib/CodeGen/AsmPrinter/AddressPool.cpp
30

std::make_pair(a, b) -> {a, b}

85

This looks up the entry twice. Does this work?

auto &Entry = Entries[I.second.Number];
SymbolExpr OldSymbolExpr = Entry;
Entry = MCBinaryExpr::create(Op, OldSymbolExpr, OffsetExpr, Asm.OutContext);
llvm/lib/CodeGen/AsmPrinter/AddressPool.h
21

I usually recommend defining a struct instead, so the members can have descriptive names for better readability. Since you still want the DenseMap to work, a trick I used elsewhere is to inherit from std::pair and provide accessors. Maybe that's excessive here.

dstenb updated this revision to Diff 224381.Oct 10 2019, 9:07 AM
dstenb marked 5 inline comments as done.

Address review comments.

llvm/lib/CodeGen/AsmPrinter/AddressPool.cpp
85

Yes. Thanks.

llvm/lib/CodeGen/AsmPrinter/AddressPool.h
21

Thanks for the suggestion! I have probably overlooked something, but when I inherited from std::pair I still had to implement DenseMapInfo for the inherited class, so all-in-all the code was about as large as implementing a normal struct, so I went with the latter (using the std::pair's DenseMapInfo::getHashValue() implementation though).

aprantl added inline comments.Oct 10 2019, 9:53 AM
llvm/lib/CodeGen/AsmPrinter/AddressPool.h
21

The idea is to use a DenseMap<std::pair<>> for the automatic DenseMapInfo and cast to the struct as needed.

dstenb abandoned this revision.Oct 29 2019, 3:37 AM

Abandoning this helper patch as D68465 was abandoned.