This is an archive of the discontinued LLVM Phabricator instance.

[LiveDebugValues] Encode a location in VarLoc IDs, NFC [2/3]
ClosedPublic

Authored by vsk on Feb 21 2020, 12:16 PM.

Details

Summary

This is part 2 of a 3-part series to address a compile-time explosion
issue in LiveDebugValues.


Each VarLoc has a unique ID: this ID is used to look up a VarLoc in the
VarLocMap, and to virtually insert a VarLoc into a VarLocSet. Instead of
inserting the VarLoc /itself/ into the VarLocSet, we insert just the ID,
because this can be represented efficiently with a SparseBitVector.

This change introduces LocIndex, a layer of abstraction on top of VarLoc
IDs. Prior to this change, an ID was just an index into a vector. With
this change, an ID encodes both an index /and/ a register location. The
type-checker ensures that conversions to and from LocIndex are correct.

For the moment the register location is always 0 (undef). We have plenty
of bits left over to encode physregs, stack slots, and other locations
in the future.

Loosely depends on: https://reviews.llvm.org/D74984

Diff Detail

Event Timeline

vsk created this revision.Feb 21 2020, 12:16 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 21 2020, 12:16 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
vsk updated this revision to Diff 245966.Feb 21 2020, 12:40 PM

Back out changes accidentally introduced in a rebase.

aprantl added inline comments.Feb 24 2020, 8:54 AM
llvm/lib/CodeGen/LiveDebugValues.cpp
118

Should we write this as an adaptor/wrapper of SparseBitVector instead?
I'm fine with "no" as an answer.

133

Out of curiosity: This data structure looks like a hand-written implementation of union { uint64_t ; struct {int32_t; int32_t}} are there some UB-related problems with doing just that?

436

If it's has methods, it gets a doxygen comment :-)

452

Nit: ///< or the comments must come before the decl.

probinson added inline comments.
llvm/lib/CodeGen/LiveDebugValues.cpp
133

(Drive-by comment) There are definitely endian-ness problems with a simple union.

vsk marked 2 inline comments as done.Feb 24 2020, 2:09 PM
vsk added inline comments.
llvm/lib/CodeGen/LiveDebugValues.cpp
118

I'm not sure I follow, sorry. Do you mean, should we be writing for (LocIndex LI : someVarLocSet), where someVarLocSet is a wrapper around a bitvector that allows iteration over LocIndex? I'm inclined to say 'no', as working with the wrapper to set operations and the like might be messier than converting to/from LocIndex.

133

My intention in writing out the left shift explicitly is to make it clear to readers that "Location" lives in the high bits. This isn't clear to me when this is written as a union. There could be weird effects with endianness as Paul points out.

436

Ouch, I accidentally squashed the change to add doxygen comments to VarLocMap into D74986. Is it all right if I land the change there? Splitting the commit apart is a pain.

aprantl accepted this revision.Feb 24 2020, 4:36 PM
aprantl added inline comments.
llvm/lib/CodeGen/LiveDebugValues.cpp
436

Sure. Just FYI, you can use a mixture of git reset HEAD~1 (un-commit changes) and git add -p (selectively add changes to commit) to move lines from one commit to another.

This revision is now accepted and ready to land.Feb 24 2020, 4:36 PM
This revision was automatically updated to reflect the committed changes.