[PATCH] D135440: [SourceManager] Speedup getFileIDLocal with a separate Offset Table.

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 11 01:43:51 PDT 2022


hokein added a comment.

In D135440#3847720 <https://reviews.llvm.org/D135440#3847720>, @nickdesaulniers wrote:

> Is it worth it and possible to fully decompose `LocalSLocEntryTable` into arrays of its constituent parts, and only construct a `SLocEntry` when necessary?

Fully decomposing `LocalSLocEntryTable` into arrays seems a good idea (which will get us more memory back, since we don't need to pay the 4 padding bytes for `SLocEntry`).
But I think constructing a `SLocEntry` every time we call `getSLocEntry` would be expensive since this is a hot function. Instead, we should probably deprecate the `SLocEntry` structure at all -- adding `getOffset(FileID)`, `getFileInfo(FileID)`, `getExpansionInfo(FileID)` to the `SourceManager`, this would take some more work (update all `SLocEntry` usage, tackle loadedSLocEntry` etc).

> I'm ok with the cost increase;  please also adding asserts to keep the size of the vectors equivalent.

added. I'd wait for a few days before landing it for @aaron.ballman's opinion.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D135440/new/

https://reviews.llvm.org/D135440



More information about the cfe-commits mailing list