[clang] [clang][modules] Move `SLocEntry` search into `ASTReader` (PR #66966)

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

[clang] [clang][modules] Move `SLocEntry` search into `ASTReader` (PR #66966)

2023-10-04 Thread Ben Langmuir via cfe-commits
https://github.com/benlangmuir approved this pull request. Latest change to shrink memory use LGTM. https://github.com/llvm/llvm-project/pull/66966 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/

[clang] [clang][modules] Move `SLocEntry` search into `ASTReader` (PR #66966)

2023-10-04 Thread Jan Svoboda via cfe-commits
@@ -1444,6 +1444,74 @@ llvm::Error ASTReader::ReadSourceManagerBlock(ModuleFile &F) { } } +llvm::Expected +ASTReader::readSLocOffset(ModuleFile *F, unsigned Index) { + BitstreamCursor &Cursor = F->SLocEntryCursor; + SavedStreamPosition SavedPosition(Cursor); + if (llvm::

[clang] [clang][modules] Move `SLocEntry` search into `ASTReader` (PR #66966)

2023-10-04 Thread Jan Svoboda via cfe-commits
https://github.com/jansvoboda11 updated https://github.com/llvm/llvm-project/pull/66966 >From 4edf9d8559339a12108d9c4d1e2f3bb062a5a768 Mon Sep 17 00:00:00 2001 From: Jan Svoboda Date: Wed, 20 Sep 2023 17:30:45 -0700 Subject: [PATCH 1/9] [clang][modules] Move `SLocEntry` search into `ASTReader`

[clang] [clang][modules] Move `SLocEntry` search into `ASTReader` (PR #66966)

2023-10-04 Thread Ben Langmuir via cfe-commits
@@ -288,10 +288,12 @@ class ModuleFile { /// for the entry is SLocEntryOffsetsBase + SLocEntryOffsets[i]. uint64_t SLocEntryOffsetsBase = 0; - /// Offsets for all of the source location entries in the - /// AST file. + /// Stream bit offsets for all of the source locati

[clang] [clang][modules] Move `SLocEntry` search into `ASTReader` (PR #66966)

2023-10-04 Thread Ben Langmuir via cfe-commits
https://github.com/benlangmuir approved this pull request. LGTM; you might need a `std::move` in `readSLocOffset` to appease an older compiler. https://github.com/llvm/llvm-project/pull/66966 ___ cfe-commits mailing list cfe-commits@lists.llvm.org htt

[clang] [clang][modules] Move `SLocEntry` search into `ASTReader` (PR #66966)

2023-10-04 Thread Ben Langmuir via cfe-commits
@@ -1444,6 +1444,74 @@ llvm::Error ASTReader::ReadSourceManagerBlock(ModuleFile &F) { } } +llvm::Expected +ASTReader::readSLocOffset(ModuleFile *F, unsigned Index) { + BitstreamCursor &Cursor = F->SLocEntryCursor; + SavedStreamPosition SavedPosition(Cursor); + if (llvm::

[clang] [clang][modules] Move `SLocEntry` search into `ASTReader` (PR #66966)

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

[clang] [clang][modules] Move `SLocEntry` search into `ASTReader` (PR #66966)

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

[clang] [clang][modules] Move `SLocEntry` search into `ASTReader` (PR #66966)

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" f

[clang] [clang][modules] Move `SLocEntry` search into `ASTReader` (PR #66966)

2023-10-02 Thread Jan Svoboda via cfe-commits
https://github.com/jansvoboda11 updated https://github.com/llvm/llvm-project/pull/66966 >From 4edf9d8559339a12108d9c4d1e2f3bb062a5a768 Mon Sep 17 00:00:00 2001 From: Jan Svoboda Date: Wed, 20 Sep 2023 17:30:45 -0700 Subject: [PATCH 1/7] [clang][modules] Move `SLocEntry` search into `ASTReader`

[clang] [clang][modules] Move `SLocEntry` search into `ASTReader` (PR #66966)

2023-10-02 Thread Jan Svoboda via cfe-commits
@@ -50,6 +50,7 @@ int y = a2; // CHECK: In module 'a': // CHECK-NEXT: a.h:1:45: error: +int z = b; // MISSING-B: could not find file '{{.*}}b.h' // MISSING-B-NOT: please delete the module cache jansvoboda11 wrote: I'm not sure. To me, this seems like an imp

[clang] [clang][modules] Move `SLocEntry` search into `ASTReader` (PR #66966)

2023-10-02 Thread Jan Svoboda via cfe-commits
@@ -288,10 +288,12 @@ class ModuleFile { /// for the entry is SLocEntryOffsetsBase + SLocEntryOffsets[i]. uint64_t SLocEntryOffsetsBase = 0; - /// Offsets for all of the source location entries in the - /// AST file. + /// Stream bit offsets for all of the source locati

[clang] [clang][modules] Move `SLocEntry` search into `ASTReader` (PR #66966)

2023-10-02 Thread Jan Svoboda via cfe-commits
@@ -864,74 +864,7 @@ FileID SourceManager::getFileIDLocal(SourceLocation::UIntTy SLocOffset) const { /// This function knows that the SourceLocation is in a loaded buffer, not a /// local one. FileID SourceManager::getFileIDLoaded(SourceLocation::UIntTy SLocOffset) const { -

[clang] [clang][modules] Move `SLocEntry` search into `ASTReader` (PR #66966)

2023-09-27 Thread Ben Langmuir via cfe-commits
@@ -1444,6 +1444,77 @@ llvm::Error ASTReader::ReadSourceManagerBlock(ModuleFile &F) { } } +std::optional +ASTReader::readSLocOffset(ModuleFile *F, unsigned Index) { benlangmuir wrote: Does every path that returns `std::nullopt` report an error? If so I wou

[clang] [clang][modules] Move `SLocEntry` search into `ASTReader` (PR #66966)

2023-09-27 Thread Ben Langmuir via cfe-commits
@@ -2261,43 +2261,68 @@ template struct enumerator_result { mutable range_reference_tuple Storage; }; -/// Infinite stream of increasing 0-based `size_t` indices. -struct index_stream { - struct iterator : iterator_facade_base { -iterator &operator++() { - assert

[clang] [clang][modules] Move `SLocEntry` search into `ASTReader` (PR #66966)

2023-09-27 Thread Ben Langmuir via cfe-commits
@@ -288,10 +288,12 @@ class ModuleFile { /// for the entry is SLocEntryOffsetsBase + SLocEntryOffsets[i]. uint64_t SLocEntryOffsetsBase = 0; - /// Offsets for all of the source location entries in the - /// AST file. + /// Stream bit offsets for all of the source locati

[clang] [clang][modules] Move `SLocEntry` search into `ASTReader` (PR #66966)

2023-09-27 Thread Ben Langmuir via cfe-commits
@@ -50,6 +50,7 @@ int y = a2; // CHECK: In module 'a': // CHECK-NEXT: a.h:1:45: error: +int z = b; // MISSING-B: could not find file '{{.*}}b.h' // MISSING-B-NOT: please delete the module cache benlangmuir wrote: Can we use this approach to test the current

[clang] [clang][modules] Move `SLocEntry` search into `ASTReader` (PR #66966)

2023-09-27 Thread Ben Langmuir via cfe-commits
@@ -864,74 +864,7 @@ FileID SourceManager::getFileIDLocal(SourceLocation::UIntTy SLocOffset) const { /// This function knows that the SourceLocation is in a loaded buffer, not a /// local one. FileID SourceManager::getFileIDLoaded(SourceLocation::UIntTy SLocOffset) const { -

[clang] [clang][modules] Move `SLocEntry` search into `ASTReader` (PR #66966)

2023-09-25 Thread Jan Svoboda via cfe-commits
@@ -50,6 +50,7 @@ int y = a2; // CHECK: In module 'a': // CHECK-NEXT: a.h:1:45: error: +int z = b; // MISSING-B: could not find file '{{.*}}b.h' // MISSING-B-NOT: please delete the module cache jansvoboda11 wrote: This test relied on the fact that when diag

[clang] [clang][modules] Move `SLocEntry` search into `ASTReader` (PR #66966)

2023-09-25 Thread Jan Svoboda via cfe-commits
https://github.com/jansvoboda11 updated https://github.com/llvm/llvm-project/pull/66966 >From 4edf9d8559339a12108d9c4d1e2f3bb062a5a768 Mon Sep 17 00:00:00 2001 From: Jan Svoboda Date: Wed, 20 Sep 2023 17:30:45 -0700 Subject: [PATCH 1/6] [clang][modules] Move `SLocEntry` search into `ASTReader`

[clang] [clang][modules] Move `SLocEntry` search into `ASTReader` (PR #66966)

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

[clang] [clang][modules] Move `SLocEntry` search into `ASTReader` (PR #66966)

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

[clang] [clang][modules] Move `SLocEntry` search into `ASTReader` (PR #66966)

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

[clang] [clang][modules] Move `SLocEntry` search into `ASTReader` (PR #66966)

2023-09-22 Thread Jan Svoboda via cfe-commits
https://github.com/jansvoboda11 updated https://github.com/llvm/llvm-project/pull/66966 >From 4edf9d8559339a12108d9c4d1e2f3bb062a5a768 Mon Sep 17 00:00:00 2001 From: Jan Svoboda Date: Wed, 20 Sep 2023 17:30:45 -0700 Subject: [PATCH 1/5] [clang][modules] Move `SLocEntry` search into `ASTReader`

[clang] [clang][modules] Move `SLocEntry` search into `ASTReader` (PR #66966)

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

[clang] [clang][modules] Move `SLocEntry` search into `ASTReader` (PR #66966)

2023-09-22 Thread Jan Svoboda via cfe-commits
https://github.com/jansvoboda11 updated https://github.com/llvm/llvm-project/pull/66966 >From 4edf9d8559339a12108d9c4d1e2f3bb062a5a768 Mon Sep 17 00:00:00 2001 From: Jan Svoboda Date: Wed, 20 Sep 2023 17:30:45 -0700 Subject: [PATCH 1/4] [clang][modules] Move `SLocEntry` search into `ASTReader`

[clang] [clang][modules] Move `SLocEntry` search into `ASTReader` (PR #66966)

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

[clang] [clang][modules] Move `SLocEntry` search into `ASTReader` (PR #66966)

2023-09-21 Thread Jan Svoboda via cfe-commits
https://github.com/jansvoboda11 updated https://github.com/llvm/llvm-project/pull/66966 >From d26f9487dedf53ac419cbd9dfb8c29214ba0e09f Mon Sep 17 00:00:00 2001 From: Jan Svoboda Date: Wed, 20 Sep 2023 17:30:45 -0700 Subject: [PATCH 1/2] [clang][modules] Move `SLocEntry` search into `ASTReader`

[clang] [clang][modules] Move `SLocEntry` search into `ASTReader` (PR #66966)

2023-09-20 Thread Jan Svoboda via cfe-commits
jansvoboda11 wrote: Marking as draft for now. We still need to cache the lightweight offset deserialization. While this patch speeds up the dependency scanner as it stands, implicit modules compile slows down by 50%. https://github.com/llvm/llvm-project/pull/66966 _

[clang] [clang][modules] Move `SLocEntry` search into `ASTReader` (PR #66966)

2023-09-20 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang-modules Changes In `getFileID()` the `SourceManager` ends up doing a binary search over its buffer of `SLocEntries`. For modules, this binary search fully deserializes the entire `SLocEntry` block for visited each entry. This shows up in profiles

[clang] [clang][modules] Move `SLocEntry` search into `ASTReader` (PR #66966)

2023-09-20 Thread Jan Svoboda via cfe-commits
https://github.com/jansvoboda11 created https://github.com/llvm/llvm-project/pull/66966 In `getFileID()` the `SourceManager` ends up doing a binary search over its buffer of `SLocEntries`. For modules, this binary search fully deserializes the entire `SLocEntry` block for visited each entry. T