[clang] [clang][modules] Remove preloaded SLocEntries from PCM files (PR #66962)

2023-10-06 Thread Jan Svoboda via cfe-commits
https://github.com/jansvoboda11 closed https://github.com/llvm/llvm-project/pull/66962 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][modules] Remove preloaded SLocEntries from PCM files (PR #66962)

2023-10-04 Thread Jan Svoboda via cfe-commits
jansvoboda11 wrote: @sam-mccall Do you have any additional feedback? You might want to check how this PR and #66966 impact performance for you. https://github.com/llvm/llvm-project/pull/66962 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[clang] [clang][modules] Remove preloaded SLocEntries from PCM files (PR #66962)

2023-10-04 Thread Jan Svoboda via cfe-commits
jansvoboda11 wrote: > Thanks for iterating! I find the current implementation much clearer. Thanks for your patience! > The only thing I might quibble about is the "child" vs. "parent" terminology > you changed: I think it's fairly ambiguous either way, because the node is > the "child" from

[clang] [clang][modules] Remove preloaded SLocEntries from PCM files (PR #66962)

2023-10-04 Thread Ben Langmuir via cfe-commits
https://github.com/benlangmuir approved this pull request. Thanks for iterating! I find the current implementation much clearer. The only thing I might quibble about is the "child" vs. "parent" terminology you changed: I think it's fairly ambiguous either way, because the node is the "child"

[clang] [clang][modules] Remove preloaded SLocEntries from PCM files (PR #66962)

2023-10-04 Thread Jan Svoboda via cfe-commits
https://github.com/jansvoboda11 updated https://github.com/llvm/llvm-project/pull/66962 >From 61e8961cde95e9e8ce8cea3efd6aa52273f430e9 Mon Sep 17 00:00:00 2001 From: Jan Svoboda Date: Wed, 20 Sep 2023 16:50:48 -0700 Subject: [PATCH 1/6] [clang][modules] Remove preloaded SLocEntries from PCM

[clang] [clang][modules] Remove preloaded SLocEntries from PCM files (PR #66962)

2023-10-04 Thread Jan Svoboda via cfe-commits
@@ -1986,13 +1984,15 @@ bool SourceManager::isInTheSameTranslationUnitImpl( if (isLoadedFileID(LOffs.first) != isLoadedFileID(ROffs.first)) return false; - // If both are loaded from different AST files. if (isLoadedFileID(LOffs.first) &&

[clang] [clang][modules] Remove preloaded SLocEntries from PCM files (PR #66962)

2023-10-04 Thread Jan Svoboda via cfe-commits
@@ -1986,13 +1984,15 @@ bool SourceManager::isInTheSameTranslationUnitImpl( if (isLoadedFileID(LOffs.first) != isLoadedFileID(ROffs.first)) return false; - // If both are loaded from different AST files. if (isLoadedFileID(LOffs.first) &&

[clang] [clang][modules] Remove preloaded SLocEntries from PCM files (PR #66962)

2023-10-04 Thread Jan Svoboda via cfe-commits
https://github.com/jansvoboda11 edited https://github.com/llvm/llvm-project/pull/66962 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][modules] Remove preloaded SLocEntries from PCM files (PR #66962)

2023-10-04 Thread Jan Svoboda via cfe-commits
@@ -458,14 +458,12 @@ SourceManager::AllocateLoadedSLocEntries(unsigned NumSLocEntries, CurrentLoadedOffset - TotalSize < NextLocalOffset) { return std::make_pair(0, 0); } - - unsigned NewTableSize = LoadedSLocEntryTable.size() + NumSLocEntries; -

[clang] [clang][modules] Remove preloaded SLocEntries from PCM files (PR #66962)

2023-10-04 Thread Ben Langmuir via cfe-commits
@@ -458,14 +458,12 @@ SourceManager::AllocateLoadedSLocEntries(unsigned NumSLocEntries, CurrentLoadedOffset - TotalSize < NextLocalOffset) { return std::make_pair(0, 0); } - - unsigned NewTableSize = LoadedSLocEntryTable.size() + NumSLocEntries; -

[clang] [clang][modules] Remove preloaded SLocEntries from PCM files (PR #66962)

2023-10-04 Thread Ben Langmuir via cfe-commits
https://github.com/benlangmuir edited https://github.com/llvm/llvm-project/pull/66962 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][modules] Remove preloaded SLocEntries from PCM files (PR #66962)

2023-10-04 Thread Jan Svoboda via cfe-commits
@@ -458,14 +458,12 @@ SourceManager::AllocateLoadedSLocEntries(unsigned NumSLocEntries, CurrentLoadedOffset - TotalSize < NextLocalOffset) { return std::make_pair(0, 0); } - - unsigned NewTableSize = LoadedSLocEntryTable.size() + NumSLocEntries; -

[clang] [clang][modules] Remove preloaded SLocEntries from PCM files (PR #66962)

2023-10-04 Thread Ben Langmuir via cfe-commits
@@ -458,14 +458,12 @@ SourceManager::AllocateLoadedSLocEntries(unsigned NumSLocEntries, CurrentLoadedOffset - TotalSize < NextLocalOffset) { return std::make_pair(0, 0); } - - unsigned NewTableSize = LoadedSLocEntryTable.size() + NumSLocEntries; -

[clang] [clang][modules] Remove preloaded SLocEntries from PCM files (PR #66962)

2023-10-04 Thread Ben Langmuir via cfe-commits
@@ -1986,13 +1984,15 @@ bool SourceManager::isInTheSameTranslationUnitImpl( if (isLoadedFileID(LOffs.first) != isLoadedFileID(ROffs.first)) return false; - // If both are loaded from different AST files. if (isLoadedFileID(LOffs.first) &&

[clang] [clang][modules] Remove preloaded SLocEntries from PCM files (PR #66962)

2023-10-04 Thread Jan Svoboda via cfe-commits
https://github.com/jansvoboda11 updated https://github.com/llvm/llvm-project/pull/66962 >From 61e8961cde95e9e8ce8cea3efd6aa52273f430e9 Mon Sep 17 00:00:00 2001 From: Jan Svoboda Date: Wed, 20 Sep 2023 16:50:48 -0700 Subject: [PATCH 1/5] [clang][modules] Remove preloaded SLocEntries from PCM

[clang] [clang][modules] Remove preloaded SLocEntries from PCM files (PR #66962)

2023-10-04 Thread Jan Svoboda via cfe-commits
https://github.com/jansvoboda11 updated https://github.com/llvm/llvm-project/pull/66962 >From 61e8961cde95e9e8ce8cea3efd6aa52273f430e9 Mon Sep 17 00:00:00 2001 From: Jan Svoboda Date: Wed, 20 Sep 2023 16:50:48 -0700 Subject: [PATCH 1/4] [clang][modules] Remove preloaded SLocEntries from PCM

[clang] [clang][modules] Remove preloaded SLocEntries from PCM files (PR #66962)

2023-10-04 Thread Ben Langmuir via cfe-commits
@@ -701,6 +701,10 @@ class SourceManager : public RefCountedBase { /// use (-ID - 2). SmallVector LoadedSLocEntryTable; + /// For each allocation in LoadedSLocEntryTable, we keep the new size. This + /// can be used to determine whether two FileIDs come from the same

[clang] [clang][modules] Remove preloaded SLocEntries from PCM files (PR #66962)

2023-10-03 Thread Jan Svoboda via cfe-commits
https://github.com/jansvoboda11 edited https://github.com/llvm/llvm-project/pull/66962 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][modules] Remove preloaded SLocEntries from PCM files (PR #66962)

2023-10-03 Thread Jan Svoboda via cfe-commits
https://github.com/jansvoboda11 edited https://github.com/llvm/llvm-project/pull/66962 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][modules] Remove preloaded SLocEntries from PCM files (PR #66962)

2023-10-03 Thread Jan Svoboda via cfe-commits
@@ -701,6 +701,10 @@ class SourceManager : public RefCountedBase { /// use (-ID - 2). SmallVector LoadedSLocEntryTable; + /// For each allocation in LoadedSLocEntryTable, we keep the new size. This + /// can be used to determine whether two FileIDs come from the same

[clang] [clang][modules] Remove preloaded SLocEntries from PCM files (PR #66962)

2023-10-03 Thread Jan Svoboda via cfe-commits
@@ -458,11 +458,14 @@ SourceManager::AllocateLoadedSLocEntries(unsigned NumSLocEntries, CurrentLoadedOffset - TotalSize < NextLocalOffset) { return std::make_pair(0, 0); } - LoadedSLocEntryTable.resize(LoadedSLocEntryTable.size() + NumSLocEntries); -

[clang] [clang][modules] Remove preloaded SLocEntries from PCM files (PR #66962)

2023-10-03 Thread Jan Svoboda via cfe-commits
@@ -701,6 +701,10 @@ class SourceManager : public RefCountedBase { /// use (-ID - 2). SmallVector LoadedSLocEntryTable; + /// For each allocation in LoadedSLocEntryTable, we keep the new size. This + /// can be used to determine whether two FileIDs come from the same

[clang] [clang][modules] Remove preloaded SLocEntries from PCM files (PR #66962)

2023-10-03 Thread Ben Langmuir via cfe-commits
@@ -2082,6 +2082,11 @@ std::pair SourceManager::isInTheSameTranslationUnit( if (LOffs.first == ROffs.first) return std::make_pair(true, LOffs.second < ROffs.second); + // Built-ins are not considered part of any TU. benlangmuir wrote: Yes, this

[clang] [clang][modules] Remove preloaded SLocEntries from PCM files (PR #66962)

2023-10-03 Thread Jan Svoboda via cfe-commits
@@ -2082,6 +2082,11 @@ std::pair SourceManager::isInTheSameTranslationUnit( if (LOffs.first == ROffs.first) return std::make_pair(true, LOffs.second < ROffs.second); + // Built-ins are not considered part of any TU. jansvoboda11 wrote: This comment

[clang] [clang][modules] Remove preloaded SLocEntries from PCM files (PR #66962)

2023-10-03 Thread Ben Langmuir via cfe-commits
@@ -458,11 +458,14 @@ SourceManager::AllocateLoadedSLocEntries(unsigned NumSLocEntries, CurrentLoadedOffset - TotalSize < NextLocalOffset) { return std::make_pair(0, 0); } - LoadedSLocEntryTable.resize(LoadedSLocEntryTable.size() + NumSLocEntries); -

[clang] [clang][modules] Remove preloaded SLocEntries from PCM files (PR #66962)

2023-10-03 Thread Ben Langmuir via cfe-commits
@@ -458,11 +458,14 @@ SourceManager::AllocateLoadedSLocEntries(unsigned NumSLocEntries, CurrentLoadedOffset - TotalSize < NextLocalOffset) { return std::make_pair(0, 0); } - LoadedSLocEntryTable.resize(LoadedSLocEntryTable.size() + NumSLocEntries); -

[clang] [clang][modules] Remove preloaded SLocEntries from PCM files (PR #66962)

2023-10-03 Thread Ben Langmuir via cfe-commits
@@ -701,6 +701,10 @@ class SourceManager : public RefCountedBase { /// use (-ID - 2). SmallVector LoadedSLocEntryTable; + /// For each allocation in LoadedSLocEntryTable, we keep the new size. This + /// can be used to determine whether two FileIDs come from the same

[clang] [clang][modules] Remove preloaded SLocEntries from PCM files (PR #66962)

2023-10-03 Thread Ben Langmuir via cfe-commits
@@ -2082,6 +2082,11 @@ std::pair SourceManager::isInTheSameTranslationUnit( if (LOffs.first == ROffs.first) return std::make_pair(true, LOffs.second < ROffs.second); + // Built-ins are not considered part of any TU. benlangmuir wrote: Does this have

[clang] [clang][modules] Remove preloaded SLocEntries from PCM files (PR #66962)

2023-10-03 Thread Jan Svoboda via cfe-commits
jansvoboda11 wrote: > > That said, isBeforeInTranslationUnit is slow already, and I don't think > > it's hot in clang, moreso in tools like clang-tidy whose performance is > > less-critical. So let's make it right, and then optimize it again if > > problems arise. > > It may not be a hot

[clang] [clang][modules] Remove preloaded SLocEntries from PCM files (PR #66962)

2023-10-03 Thread Tom Honermann via cfe-commits
tahonermann wrote: > That said, isBeforeInTranslationUnit is slow already, and I don't think it's > hot in clang, moreso in tools like clang-tidy whose performance is > less-critical. So let's make it right, and then optimize it again if problems > arise. It may not be a hot function in

[clang] [clang][modules] Remove preloaded SLocEntries from PCM files (PR #66962)

2023-10-02 Thread Jan Svoboda via cfe-commits
https://github.com/jansvoboda11 updated https://github.com/llvm/llvm-project/pull/66962 >From 61e8961cde95e9e8ce8cea3efd6aa52273f430e9 Mon Sep 17 00:00:00 2001 From: Jan Svoboda Date: Wed, 20 Sep 2023 16:50:48 -0700 Subject: [PATCH 1/3] [clang][modules] Remove preloaded SLocEntries from PCM

[clang] [clang][modules] Remove preloaded SLocEntries from PCM files (PR #66962)

2023-10-02 Thread Jan Svoboda via cfe-commits
jansvoboda11 wrote: I don't understand why the tie-breaking code calls the previously visited `FileID` a parent. We're walking **up** the include/expansion tree, so I think it should be called child instead. LMK if I'm misunderstanding. https://github.com/llvm/llvm-project/pull/66962

[clang] [clang][modules] Remove preloaded SLocEntries from PCM files (PR #66962)

2023-10-02 Thread Jan Svoboda via cfe-commits
jansvoboda11 wrote: Turns out some clients are calling `isBeforeInTranslationUnit()` before checking if both `SourceLocations` are indeed in the same TU. I left behind a FIXME to call `llvm_unreachable()`, but for now, I just compare the `FileIDs` to keep things working.

[clang] [clang][modules] Remove preloaded SLocEntries from PCM files (PR #66962)

2023-10-02 Thread Jan Svoboda via cfe-commits
jansvoboda11 wrote: Since I moved up the special-casing of built-ins buffer up in my last commit, it was happening before we got chance to walk up from `FileID(3)` to `FileID(2)`, meaning it wasn't kicking in. I think we need to sink the special-casing into `isInTheSameTranslationUnit()` and

[clang] [clang][modules] Remove preloaded SLocEntries from PCM files (PR #66962)

2023-10-02 Thread Jan Svoboda via cfe-commits
jansvoboda11 wrote: I got around investigating "SemaCXX/warn-unsafe-buffer-usage-fixits-parm-span.cpp" and found out it uses this pattern: ``` %clang_cc1 ... -include %s %s ``` This means `FileID(1)` is the main input file `%s` and `FileID(2)` is the built-ins buffer that includes `%s` as

[clang] [clang][modules] Remove preloaded SLocEntries from PCM files (PR #66962)

2023-09-29 Thread Sam McCall via cfe-commits
sam-mccall wrote: Ripping out this feature sounds great, as does fixing the non-translation of builtin buffer locations. My only concern is that this will make isBeforeInTranslationUnit more expensive. A loc being in one of these special "" is the rare case, and the code recognizing them

[clang] [clang][modules] Remove preloaded SLocEntries from PCM files (PR #66962)

2023-09-28 Thread Ben Langmuir via cfe-commits
benlangmuir wrote: Thanks for laying it out. I also find this easier to understand in your latest changes because the comments in `isBeforeInTranslationUnit` lay out the intended ordering without relying on `isInTheSameTranslationUnit` returning `false` for builtin buffers, which is the part

[clang] [clang][modules] Remove preloaded SLocEntries from PCM files (PR #66962)

2023-09-28 Thread Jan Svoboda via cfe-commits
https://github.com/jansvoboda11 updated https://github.com/llvm/llvm-project/pull/66962 >From 1e36c68229a98ffbdb61ea652077bc3356fc177f Mon Sep 17 00:00:00 2001 From: Jan Svoboda Date: Wed, 20 Sep 2023 16:50:48 -0700 Subject: [PATCH 1/4] [clang][modules] Remove preloaded SLocEntries from PCM

[clang] [clang][modules] Remove preloaded SLocEntries from PCM files (PR #66962)

2023-09-28 Thread Jan Svoboda via cfe-commits
jansvoboda11 wrote: > > I changed SourceManager::isInTheSameTranslationUnit() to check for that > > case explicitly instead of relying on the fact/bug that built-ins buffers > > happened to be assigned an untranslated include SourceLocation. > > What is the translated location you get here?

[clang] [clang][modules] Remove preloaded SLocEntries from PCM files (PR #66962)

2023-09-27 Thread Ben Langmuir via cfe-commits
benlangmuir wrote: > I changed SourceManager::isInTheSameTranslationUnit() to check for that case > explicitly instead of relying on the fact/bug that built-ins buffers happened > to be assigned an untranslated include SourceLocation. What is the translated location you get here? It's hard

[clang] [clang][modules] Remove preloaded SLocEntries from PCM files (PR #66962)

2023-09-25 Thread Jan Svoboda via cfe-commits
https://github.com/jansvoboda11 resolved https://github.com/llvm/llvm-project/pull/66962 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][modules] Remove preloaded SLocEntries from PCM files (PR #66962)

2023-09-25 Thread Jan Svoboda via cfe-commits
https://github.com/jansvoboda11 updated https://github.com/llvm/llvm-project/pull/66962 >From 1e36c68229a98ffbdb61ea652077bc3356fc177f Mon Sep 17 00:00:00 2001 From: Jan Svoboda Date: Wed, 20 Sep 2023 16:50:48 -0700 Subject: [PATCH 1/3] [clang][modules] Remove preloaded SLocEntries from PCM

[clang] [clang][modules] Remove preloaded SLocEntries from PCM files (PR #66962)

2023-09-25 Thread Jan Svoboda via cfe-commits
https://github.com/jansvoboda11 updated https://github.com/llvm/llvm-project/pull/66962 >From 1e36c68229a98ffbdb61ea652077bc3356fc177f Mon Sep 17 00:00:00 2001 From: Jan Svoboda Date: Wed, 20 Sep 2023 16:50:48 -0700 Subject: [PATCH 1/2] [clang][modules] Remove preloaded SLocEntries from PCM

[clang] [clang][modules] Remove preloaded SLocEntries from PCM files (PR #66962)

2023-09-25 Thread Jan Svoboda via cfe-commits
jansvoboda11 wrote: Ok, the comment below seems to suggests that the built-ins buffers are not considered to be part of any TU: ```c++ bool SourceManager::isBeforeInTranslationUnit(SourceLocation LHS, SourceLocation RHS) const { // ... if

[clang] [clang][modules] Remove preloaded SLocEntries from PCM files (PR #66962)

2023-09-25 Thread Jan Svoboda via cfe-commits
jansvoboda11 wrote: The "Index/annotate-module.m" test fails with this patch. For run line 29, the previous input is: ``` Punctuation: "#" [1:1 - 1:2] inclusion directive=Module/Sub2.h (/Users/Jan/Code/upstream-llvm/clang/test/Index/../Modules/Inputs/Module.framework/Headers/Sub2.h)

[clang] [clang][modules] Remove preloaded SLocEntries from PCM files (PR #66962)

2023-09-21 Thread Ben Langmuir via cfe-commits
https://github.com/benlangmuir approved this pull request. LGTM other than my nit about the comment https://github.com/llvm/llvm-project/pull/66962 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[clang] [clang][modules] Remove preloaded SLocEntries from PCM files (PR #66962)

2023-09-21 Thread Jan Svoboda via cfe-commits
jansvoboda11 wrote: > > in my experience, it's not actually referenced in most modules > > Can you clarify what you looked at here? I assume you checked non-scanner > modules as well? I took a typical Xcode project and chose one TU that happens to transitively depend on 37 modules. I built

[clang] [clang][modules] Remove preloaded SLocEntries from PCM files (PR #66962)

2023-09-21 Thread Ben Langmuir via cfe-commits
https://github.com/benlangmuir edited https://github.com/llvm/llvm-project/pull/66962 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][modules] Remove preloaded SLocEntries from PCM files (PR #66962)

2023-09-21 Thread Ben Langmuir via cfe-commits
https://github.com/benlangmuir commented: > in my experience, it's not actually referenced in most modules Can you clarify what you looked at here? I assume you checked non-scanner modules as well? https://github.com/llvm/llvm-project/pull/66962 ___

[clang] [clang][modules] Remove preloaded SLocEntries from PCM files (PR #66962)

2023-09-21 Thread Ben Langmuir via cfe-commits
@@ -524,13 +524,7 @@ enum ASTRecordTypes { /// of source-location information. SOURCE_LOCATION_OFFSETS = 14, - /// Record code for the set of source location entries - /// that need to be preloaded by the AST reader. - /// - /// This set contains the source location

[clang] [clang][modules] Remove preloaded SLocEntries from PCM files (PR #66962)

2023-09-20 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang-modules Changes This commit removes the list of SLocEntry offsets to preload eagerly from PCM files. Commit introducing this functionality (258ae54a) doesn't clarify why this would be more performant than the lazy approach used regularly.

[clang] [clang][modules] Remove preloaded SLocEntries from PCM files (PR #66962)

2023-09-20 Thread Jan Svoboda via cfe-commits
https://github.com/jansvoboda11 created https://github.com/llvm/llvm-project/pull/66962 This commit removes the list of SLocEntry offsets to preload eagerly from PCM files. Commit introducing this functionality (258ae54a) doesn't clarify why this would be more performant than the lazy