[all-commits] [llvm/llvm-project] 92f021: [clang][Serialization] Deduplicate loaded header-u...

Yuxuan Chen via All-commits all-commits at lists.llvm.org
Wed Jul 8 08:50:18 PDT 2026


  Branch: refs/heads/users/yuxuanchen1997/modules-sloc-dedup
  Home:   https://github.com/llvm/llvm-project
  Commit: 92f02148816fe09f1dd648e0d46059160f2a435e
      https://github.com/llvm/llvm-project/commit/92f02148816fe09f1dd648e0d46059160f2a435e
  Author: Yuxuan Chen <i at yuxuan.ch>
  Date:   2026-07-08 (Wed, 08 Jul 2026)

  Changed paths:
    M clang/include/clang/Serialization/ASTReader.h
    M clang/include/clang/Serialization/ModuleFile.h
    M clang/lib/Serialization/ASTReader.cpp

  Log Message:
  -----------
  [clang][Serialization] Deduplicate loaded header-unit SLoc ranges

Header units that textually include the same large header used to consume loaded SourceLocation address space independently, even when the serialized file contents were identical. Importing many such header units could therefore run out of the loaded SLoc region long before the translation unit was large in any meaningful source sense.

Use the eager SLoc dedup metadata to share already-loaded file ranges when a later header-unit PCM contains a matching dedupable file entry. The reader now builds a per-module remapping from serialized local offsets to the global SourceManager offsets actually used for the import. Fresh entries are packed into the module's allocation, while duplicate file entries map back to the canonical FileID and offset range from the first loaded PCM.

This changes the module-loading model from a single base-offset translation for every loaded location to a segmented translation for PCMs that participate in deduplication. Modules without dedup metadata keep the existing single-add fast path. The SourceManager loaded-entry table only receives slots for entries that are actually allocated, and serialized local FileIDs are remapped to their canonical loaded FileIDs when a file range is shared.

The result is that repeated textual headers in header units no longer multiply loaded SLoc address-space usage when the flag is enabled, while the default path and PCMs without the new metadata continue to load as before.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list