[all-commits] [llvm/llvm-project] 537344: [clang][modules] Move `SLocEntry` search into `AST...
Jan Svoboda via All-commits
all-commits at lists.llvm.org
Fri Oct 6 14:52:33 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 537344fc502474545d332bf5592db257cc568250
https://github.com/llvm/llvm-project/commit/537344fc502474545d332bf5592db257cc568250
Author: Jan Svoboda <jan_svoboda at apple.com>
Date: 2023-10-06 (Fri, 06 Oct 2023)
Changed paths:
M clang/include/clang/Basic/SourceManager.h
M clang/include/clang/Serialization/ASTReader.h
M clang/lib/Basic/SourceManager.cpp
M clang/lib/Serialization/ASTReader.cpp
M clang/test/Modules/explicit-build-missing-files.cpp
M llvm/include/llvm/ADT/STLExtras.h
Log Message:
-----------
[clang][modules] Move `SLocEntry` search into `ASTReader` (#66966)
In `SourceManager::getFileID()`, Clang performs binary search over its
buffer of `SLocEntries`. For modules, this binary search fully
deserializes the entire `SLocEntry` block for each visited entry. For
some entries, that includes decompressing the associated buffer (e.g.
the predefines buffer, macro expansion buffers, contents of volatile
files), which shows up in profiles of the dependency scanner.
This patch moves the binary search over loaded entries into `ASTReader`,
which can perform cheaper partial deserialization during the binary
search, reducing the wall time of dependency scans by ~3%. This also
reduces the number of retired instructions by ~1.4% on regular
(implicit) modules compilation.
Note that this patch drops the optimizations based on the last lookup ID
(pruning the search space and performing linear search before resorting
to the full binary search). Instead, it reduces the search space by
asking `ASTReader::GlobalSLocOffsetMap` for the containing `ModuleFile`
and only does binary search over entries of single module file.
More information about the All-commits
mailing list