[clang] 3e47883 - Recover performance loss after PagedVector introduction (#67972)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 5 01:16:56 PDT 2024
Author: Giulio Eulisse
Date: 2024-09-05T10:16:51+02:00
New Revision: 3e4788377bb29ed389b46521fcba0d06aa985bcf
URL: https://github.com/llvm/llvm-project/commit/3e4788377bb29ed389b46521fcba0d06aa985bcf
DIFF: https://github.com/llvm/llvm-project/commit/3e4788377bb29ed389b46521fcba0d06aa985bcf.diff
LOG: Recover performance loss after PagedVector introduction (#67972)
Added:
Modified:
clang/include/clang/Basic/SourceManager.h
llvm/include/llvm/ADT/PagedVector.h
Removed:
################################################################################
diff --git a/clang/include/clang/Basic/SourceManager.h b/clang/include/clang/Basic/SourceManager.h
index d3ccc7ef81c079..e0f1ea435d54e4 100644
--- a/clang/include/clang/Basic/SourceManager.h
+++ b/clang/include/clang/Basic/SourceManager.h
@@ -724,7 +724,7 @@ class SourceManager : public RefCountedBase<SourceManager> {
///
/// Negative FileIDs are indexes into this table. To get from ID to an index,
/// use (-ID - 2).
- llvm::PagedVector<SrcMgr::SLocEntry> LoadedSLocEntryTable;
+ llvm::PagedVector<SrcMgr::SLocEntry, 32> LoadedSLocEntryTable;
/// For each allocation in LoadedSLocEntryTable, we keep the first FileID.
/// We assume exactly one allocation per AST file, and use that to determine
diff --git a/llvm/include/llvm/ADT/PagedVector.h b/llvm/include/llvm/ADT/PagedVector.h
index 3fcca6d82cb33a..52ecd0bb0ba118 100644
--- a/llvm/include/llvm/ADT/PagedVector.h
+++ b/llvm/include/llvm/ADT/PagedVector.h
@@ -84,7 +84,7 @@ template <typename T, size_t PageSize = 1024 / sizeof(T)> class PagedVector {
assert(Index / PageSize < PageToDataPtrs.size());
T *&PagePtr = PageToDataPtrs[Index / PageSize];
// If the page was not yet allocated, allocate it.
- if (!PagePtr) {
+ if (LLVM_UNLIKELY(!PagePtr)) {
PagePtr = Allocator.getPointer()->template Allocate<T>(PageSize);
// We need to invoke the default constructor on all the elements of the
// page.
More information about the cfe-commits
mailing list