SourceManager: Fix an SLocEntry memory regression introduced with FileEntryRef
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Fri, 16 Oct 2020 18:39:28 +0000 (14:39 -0400)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Mon, 26 Oct 2020 19:38:13 +0000 (15:38 -0400)
commit22e6b1863e74136908842d71b4f942313d89b273
treecb13bf2306bae0716e6046e313b41c1979ba412c
parent139785dc98ae94717eebaed083eeaad5d775b495
SourceManager: Fix an SLocEntry memory regression introduced with FileEntryRef

4dc5573acc0d2e7c59d8bac2543eb25cb4b32984 added `FileEntryRef` in order to
help enable sharing of a `FileManager` between `CompilerInstance`s.

It also added a `StringRef` with the filename on `FileInfo`. This
doubled `sizeof(FileInfo)`, bloating `sizeof(SLocEntry)`, of which we
have one for each (loaded and unloaded) file and macro expansion. This
causes a memory regression in modules builds.

Move the filename down into the `ContentCache`, which is a side data
structure for `FileInfo` that does not impact `sizeof(SLocEntry)`. Once
`FileEntryRef` is used for `ContentCache::OrigEntry` this can go away.

Differential Revision: https://reviews.llvm.org/D89580
Radar-Id: rdar://59908826
clang/include/clang/Basic/SourceManager.h
clang/lib/Basic/SourceManager.cpp