[all-commits] [llvm/llvm-project] 44af53: [clang][modules] Avoid calling expensive `SourceMa...
Jan Svoboda via All-commits
all-commits at lists.llvm.org
Thu Mar 28 13:03:10 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 44af53b22aaa1fe382b22329bbc7e4610ecbacc8
https://github.com/llvm/llvm-project/commit/44af53b22aaa1fe382b22329bbc7e4610ecbacc8
Author: Jan Svoboda <jan_svoboda at apple.com>
Date: 2024-03-28 (Thu, 28 Mar 2024)
Changed paths:
M clang/include/clang/Lex/ModuleMap.h
M clang/lib/Frontend/CompilerInstance.cpp
M clang/lib/Frontend/FrontendAction.cpp
M clang/lib/Lex/ModuleMap.cpp
M clang/lib/Serialization/ASTWriter.cpp
M clang/test/ClangScanDeps/modules-extern-unrelated.m
Log Message:
-----------
[clang][modules] Avoid calling expensive `SourceManager::translateFile()` (#86216)
The `ASTWriter` algorithm for computing affecting module maps uses
`SourceManager::translateFile()` to get a `FileID` from a `FileEntry`.
This is slow (O(n)) since the function performs a linear walk over
`SLocEntries` until it finds one with a matching `FileEntry`.
This patch removes this use of `SourceManager::translateFile()` by
tracking `FileID` instead of `FileEntry` in couple of places in
`ModuleMap`, giving `ASTWriter` the desired `FileID` directly. There are
no changes required for clients that still want a `FileEntry` from
`ModuleMap`: the existing APIs internally use `SourceManager` to perform
the reverse `FileID` to `FileEntry` conversion in O(1).
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