[clang] [Modules] No transitive source location change (PR #86912)

Chuanqi Xu via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 28 18:29:00 PDT 2024


ChuanqiXu9 wrote:

> By default, `SourceLocation` is 32 bits. One bit is used to distinguish macro expansions. Looking at libc++'s module map, it contains 999 top-level modules at this moment. That's 10 bits just to be able to import the (entire) standard library. That leaves 21 bits, restricting local `SourceLocation` space to 2 MB. This doesn't sound feasible. Did I misunderstand?

Yes, I explained this in `Some low level details` section. The size of source location won't be affected. Since the size of source location is unsigned (practically, it is 32 bits in most platforms). And we use uint64_t as a unit in the serializer. So there are 32 bit not used completely. The plan is to store the module file index in the higher 32 bits and it shouldn't be a safe problem.

The only trade-off I saw about this change is that it may increase the size of **on-disk** .pcm files due to we use VBR6 format to decrease the size of small numbers. But on the one side, we still need to pay for more spaces if we want to use `{local-module-index, offset-within-module} pair` (Thanks for the good name suggestion). On the other hand, from the experiment, it shows the overhead is acceptable.

https://github.com/llvm/llvm-project/pull/86912


More information about the cfe-commits mailing list