[PATCH] D89749: SourceManager: Don't allocate an SLocEntry until it's loaded

Duncan P. N. Exon Smith via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 19 16:17:28 PDT 2020


dexonsmith created this revision.
dexonsmith added reviewers: teemperor, Bigcheese.
Herald added a subscriber: ributzka.
dexonsmith requested review of this revision.

Convert `SLocEntryLoaded` into an index vector into
`LoadedSLocEntryTable`, where 0 indicates "not loaded", and change
`LoadedSLocEntryTable` to only include an `SLocEntry` if it has been
loaded. This makes the allocation for an unloaded `SLocEntry` 6x smaller
(24B => 4B), dramatically improving memory usage with large / many
modules.

This increases memory usage for a *loaded* `SLocEntry` slightly.


https://reviews.llvm.org/D89749

Files:
  clang/include/clang/Basic/SourceManager.h
  clang/lib/Basic/SourceManager.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D89749.299213.patch
Type: text/x-patch
Size: 7790 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201019/17aca11c/attachment.bin>


More information about the cfe-commits mailing list