[clang] [Serialization] Fix lazy template loading (PR #133057)

2025-07-04 Thread Jonas Hahnfeld via cfe-commits
hahnjo wrote: > @hahnjo, if we have a working reproducer could we see if @zygoloid's comment > helps us: > > > If this issue is indeed specific to conversion function templates, perhaps > > a path forward would be to disable some part of the lazy loading for only > > those templates to unbloc

[clang] [Serialization] Fix lazy template loading (PR #133057)

2025-07-04 Thread Vassil Vassilev via cfe-commits
vgvassilev wrote: > I don't think we should merge a partial state of this PR for two reasons: 1. > The three patches alone don't actually bring much benefit. When I measured in > ROOT, we definitely needed the (currently) problematic one for lazy template > loading to become really effective.

[clang] [Serialization] Fix lazy template loading (PR #133057)

2025-07-03 Thread Jonas Hahnfeld via cfe-commits
hahnjo wrote: I don't think we should merge a partial state of this PR for two reasons: 1. The three patches alone don't actually bring much benefit. When I measured in ROOT, we definitely needed the (currently) problematic one for lazy template loading to become really effective. 2. As commen

[clang] [Serialization] Fix lazy template loading (PR #133057)

2025-07-03 Thread Jonas Hahnfeld via cfe-commits
https://github.com/hahnjo converted_to_draft https://github.com/llvm/llvm-project/pull/133057 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Serialization] Fix lazy template loading (PR #133057)

2025-07-03 Thread Chuanqi Xu via cfe-commits
https://github.com/ChuanqiXu9 approved this pull request. BTW, I've landed the 3 patches (excluding the problematic reported by Google) internally and we've used it for months. It looks good. https://github.com/llvm/llvm-project/pull/133057 ___ cfe-co

[clang] [Serialization] Fix lazy template loading (PR #133057)

2025-07-03 Thread Vassil Vassilev via cfe-commits
vgvassilev wrote: > > I'm not so sure it's about conversion function templates in particular: if > > it's really commit > > [658d55b](https://github.com/llvm/llvm-project/commit/658d55ba1117a029f37f51a3072585a1fd9fc59f) > > causing the problem (@emaxx-google if you happen to have some time, it

[clang] [Serialization] Fix lazy template loading (PR #133057)

2025-05-20 Thread Chuanqi Xu via cfe-commits
ChuanqiXu9 wrote: BTW, I don't mind landing the rest 3 patches since they are "verified". https://github.com/llvm/llvm-project/pull/133057 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commi

[clang] [Serialization] Fix lazy template loading (PR #133057)

2025-05-20 Thread Chuanqi Xu via cfe-commits
ChuanqiXu9 wrote: > ### Performance measurements with LLVM > I tested these patches for building LLVM itself with modules > (`LLVM_ENABLE_MODULES=ON`). To work around #130795, I apply #131354 before > building Clang. In terms of overall performance for the entire build, I'm not > able to measu

[clang] [Serialization] Fix lazy template loading (PR #133057)

2025-05-19 Thread Maksim Ivanov via cfe-commits
emaxx-google wrote: > I'm not so sure it's about conversion function templates in particular: if > it's really commit > [658d55b](https://github.com/llvm/llvm-project/commit/658d55ba1117a029f37f51a3072585a1fd9fc59f) > causing the problem (@emaxx-google if you happen to have some time, it would

[clang] [Serialization] Fix lazy template loading (PR #133057)

2025-05-19 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: I can confirm that we routinely rely on the same header being part of multiple modules and results of that being combined in all kinds of ways imaginable. Moreover, the same header can be a modular header in some modules, textual in others and the resulting PCMs may also b

[clang] [Serialization] Fix lazy template loading (PR #133057)

2025-05-19 Thread Maksim Ivanov via cfe-commits
emaxx-google wrote: > Two observations: > > 1. There is a diamond module structure: Both `4BK.pcm` and `LUM.pcm` depend > on `WI9.pcm` and contain `2OT.h` with different module names (I removed > transitive empty includes). I'm not sure if this is valid... @emaxx-google is > it possible to sh

[clang] [Serialization] Fix lazy template loading (PR #133057)

2025-05-18 Thread Jonas Hahnfeld via cfe-commits
hahnjo wrote: I'm not so sure it's about conversion function templates in particular: if it's really commit 658d55ba1117a029f37f51a3072585a1fd9fc59f causing the problem (@emaxx-google if you happen to have some time, it would be great to confirm reverting that change also avoids the issues in

[clang] [Serialization] Fix lazy template loading (PR #133057)

2025-05-16 Thread Richard Smith via cfe-commits
zygoloid wrote: Conversion function templates might be a special case here because of how conversion function template specializations are found by deduction as part of class member name lookup. Maybe we're doing something different in that deduction in particular that means we're not properly

[clang] [Serialization] Fix lazy template loading (PR #133057)

2025-05-16 Thread Jonas Hahnfeld via cfe-commits
hahnjo wrote: Thanks, the reproducer is indeed useful. The first "bad" commit is the second `Complete only needed partial specializations`. I was manually able to further reduce the example (throwing out empty files & modules, inline through typedefs, etc) Smaller reproducer ``` //--- 2OT.h

[clang] [Serialization] Fix lazy template loading (PR #133057)

2025-05-15 Thread Maksim Ivanov via cfe-commits
emaxx-google wrote: Hello, here's the new reproducer (which compiles "before" and also in non-module mode, but not "after"): https://pastebin.com/zawQv7Q6 . Hopefully this time it's more useful than the previous attempts. https://github.com/llvm/llvm-project/pull/133057 ___

[clang] [Serialization] Fix lazy template loading (PR #133057)

2025-05-14 Thread Chuanqi Xu via cfe-commits
ChuanqiXu9 wrote: > @emaxx-google, @ilya-biryukov, do you think we can move forward even though > don't have a reproducer yet? It feels we are stuck on that one case on a > downstream client -- worst case maybe the devs can work it around by changing > source code for that one case? Yes, I'm

[clang] [Serialization] Fix lazy template loading (PR #133057)

2025-05-13 Thread Jonas Hahnfeld via cfe-commits
@@ -367,12 +367,6 @@ bool RedeclarableTemplateDecl::loadLazySpecializationsImpl( if (!ExternalSource) return false; - // If TPL is not null, it implies that we're loading specializations for - // partial templates. We need to load all specializations in such cases. -

[clang] [Serialization] Fix lazy template loading (PR #133057)

2025-05-05 Thread Maksim Ivanov via cfe-commits
emaxx-google wrote: An update: The miminization of the reproducer is sadly still ongoing. A longer version of this TLDR: --- As the reduction was making slow progress, I've tried the proposal from @vgvassilev to add the "successfully compiles in the non-modular mode" criterion to the interes

[clang] [Serialization] Fix lazy template loading (PR #133057)

2025-05-05 Thread Maksim Ivanov via cfe-commits
@@ -367,12 +367,6 @@ bool RedeclarableTemplateDecl::loadLazySpecializationsImpl( if (!ExternalSource) return false; - // If TPL is not null, it implies that we're loading specializations for - // partial templates. We need to load all specializations in such cases. -

[clang] [Serialization] Fix lazy template loading (PR #133057)

2025-04-28 Thread Chuanqi Xu via cfe-commits
ChuanqiXu9 wrote: LGTM. Let's land this in individual commits after the large test in google finish. https://github.com/llvm/llvm-project/pull/133057 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listin

[clang] [Serialization] Fix lazy template loading (PR #133057)

2025-04-27 Thread Chuanqi Xu via cfe-commits
@@ -21,17 +21,6 @@ using namespace clang; namespace { class TemplateArgumentHasher { - // If we bail out during the process of calculating hash values for - // template arguments for any reason. We're allowed to do it since - // TemplateArgumentHasher are only required to g

[clang] [Serialization] Fix lazy template loading (PR #133057)

2025-04-25 Thread Jonas Hahnfeld via cfe-commits
@@ -367,12 +367,6 @@ bool RedeclarableTemplateDecl::loadLazySpecializationsImpl( if (!ExternalSource) return false; - // If TPL is not null, it implies that we're loading specializations for - // partial templates. We need to load all specializations in such cases. -

[clang] [Serialization] Fix lazy template loading (PR #133057)

2025-04-25 Thread Jonas Hahnfeld via cfe-commits
@@ -21,17 +21,6 @@ using namespace clang; namespace { class TemplateArgumentHasher { - // If we bail out during the process of calculating hash values for - // template arguments for any reason. We're allowed to do it since - // TemplateArgumentHasher are only required to g

[clang] [Serialization] Fix lazy template loading (PR #133057)

2025-04-25 Thread Jonas Hahnfeld via cfe-commits
@@ -367,12 +367,6 @@ bool RedeclarableTemplateDecl::loadLazySpecializationsImpl( if (!ExternalSource) return false; - // If TPL is not null, it implies that we're loading specializations for - // partial templates. We need to load all specializations in such cases. -

[clang] [Serialization] Fix lazy template loading (PR #133057)

2025-04-15 Thread Maksim Ivanov via cfe-commits
emaxx-google wrote: Understood. JFYI I've been running another minimization task, this time without the `-fallow-pcm-with-compiler-errors` parameter, so that all modules compile correctly and the result is easier to comprehend, but it obviously takes a lot longer to reduce - so far it's still

[clang] [Serialization] Fix lazy template loading (PR #133057)

2025-04-12 Thread Jonas Hahnfeld via cfe-commits
hahnjo wrote: > When I have time, I will need to see that I turn the reduced example into > actual valid code to understand what is going on... I spent some time turning it into valid code, but then noticed that the `error: use of overloaded operator '=' is ambiguous` is gone. Going back, the

[clang] [Serialization] Fix lazy template loading (PR #133057)

2025-04-11 Thread Vassil Vassilev via cfe-commits
vgvassilev wrote: > > > Here's a new reproducer, this time verifying that a semi-fresh > > > tip-of-the-tree doesn't trigger the same error: > > > https://pastebin.com/7tYfjazz. Apologies for the delay. > > > > > > Thanks. I gave it a try, but I don't see any `use of overloaded operator > >

[clang] [Serialization] Fix lazy template loading (PR #133057)

2025-04-11 Thread Jonas Hahnfeld via cfe-commits
hahnjo wrote: > The simplified script: https://pastebin.com/udVTaPYV Aaaah, the important line is `EXTRA_CFLAGS='-Xclang -fallow-pcm-with-compiler-errors -ferror-limit=0'`. With that I indeed get the following diff between logs from `main` and a rebased version of this branch: ```diff --- main

[clang] [Serialization] Fix lazy template loading (PR #133057)

2025-04-11 Thread Maksim Ivanov via cfe-commits
emaxx-google wrote: > > Here's a new reproducer, this time verifying that a semi-fresh > > tip-of-the-tree doesn't trigger the same error: > > https://pastebin.com/7tYfjazz. Apologies for the delay. > > Thanks. I gave it a try, but I don't see any `use of overloaded operator '=' > is ambiguou

[clang] [Serialization] Fix lazy template loading (PR #133057)

2025-04-11 Thread Vassil Vassilev via cfe-commits
vgvassilev wrote: > > Here's a new reproducer, this time verifying that a semi-fresh > > tip-of-the-tree doesn't trigger the same error: > > https://pastebin.com/7tYfjazz. Apologies for the delay. > > Thanks. I gave it a try, but I don't see any `use of overloaded operator '=' > is ambiguous`

[clang] [Serialization] Fix lazy template loading (PR #133057)

2025-04-11 Thread Jonas Hahnfeld via cfe-commits
hahnjo wrote: > Here's a new reproducer, this time verifying that a semi-fresh > tip-of-the-tree doesn't trigger the same error: > https://pastebin.com/7tYfjazz. Apologies for the delay. Thanks. I gave it a try, but I don't see any `use of overloaded operator '=' is ambiguous` error. In fact,

[clang] [Serialization] Fix lazy template loading (PR #133057)

2025-04-10 Thread Maksim Ivanov via cfe-commits
emaxx-google wrote: Here's a new reproducer, this time verifying that a semi-fresh tip-of-the-tree doesn't trigger the same error: https://pastebin.com/7tYfjazz. Apologies for the delay. https://github.com/llvm/llvm-project/pull/133057 ___ cfe-commit

[clang] [Serialization] Fix lazy template loading (PR #133057)

2025-04-10 Thread Jonas Hahnfeld via cfe-commits
hahnjo wrote: Hi @emaxx-google, any updates on the second minimization run? https://github.com/llvm/llvm-project/pull/133057 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Serialization] Fix lazy template loading (PR #133057)

2025-04-05 Thread Maksim Ivanov via cfe-commits
emaxx-google wrote: > I had a closer look, but I get plenty of compile errors already on `main` - > including > > ``` > ./head15.h:20:7: error: use of overloaded operator '=' is ambiguous (with > operand types 'std::vector' and > 'strings_internal::Splitter strings_internal::SelectDelimiter::

[clang] [Serialization] Fix lazy template loading (PR #133057)

2025-03-28 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: The small-scale benchmarks we had show 10% improvement in CPU and 23% improvement in memory usage for some compilations! We did hit one compiler error that does not reproduce without modules, however: ```error: use of overloaded operator '=' is ambiguous``` We're in the pr

[clang] [Serialization] Fix lazy template loading (PR #133057)

2025-03-28 Thread Vassil Vassilev via cfe-commits
vgvassilev wrote: > The small-scale benchmarks we had show 10% improvement in CPU and 23% > improvement in memory usage for some compilations! That's very good news. I think we can further reduce these times. IIRC, we still deserialize declarations that we do not need. One of the places to loo

[clang] [Serialization] Fix lazy template loading (PR #133057)

2025-03-28 Thread Vassil Vassilev via cfe-commits
vgvassilev wrote: > > > While I may not able to look into them in detail recently, it may be > > > helpful to split this into seperate patches to review and to land. > > > > > > I initially considered this, but @vgvassilev said in > > [root-project/root#17722 > > (comment)](https://github.co

[clang] [Serialization] Fix lazy template loading (PR #133057)

2025-03-28 Thread Chuanqi Xu via cfe-commits
ChuanqiXu9 wrote: > > > > > > While I may not able to look into them in detail recently, it may > > > > > > be helpful to split this into seperate patches to review and to > > > > > > land. > > > > > > > > > > > > > > > I initially considered this, but @vgvassilev said in > > > > > [root-pro

[clang] [Serialization] Fix lazy template loading (PR #133057)

2025-03-28 Thread Vassil Vassilev via cfe-commits
vgvassilev wrote: > > > > > While I may not able to look into them in detail recently, it may be > > > > > helpful to split this into seperate patches to review and to land. > > > > > > > > > > > > I initially considered this, but @vgvassilev said in > > > > [root-project/root#17722 > > > >

[clang] [Serialization] Fix lazy template loading (PR #133057)

2025-03-28 Thread Chuanqi Xu via cfe-commits
ChuanqiXu9 wrote: > > > > While I may not able to look into them in detail recently, it may be > > > > helpful to split this into seperate patches to review and to land. > > > > > > > > > I initially considered this, but @vgvassilev said in > > > [root-project/root#17722 > > > (comment)](htt

[clang] [Serialization] Fix lazy template loading (PR #133057)

2025-03-28 Thread Chuanqi Xu via cfe-commits
ChuanqiXu9 wrote: > > Maybe you can test it with this and land it with different patches. So that > > we can revert one of them if either of them are problematic but other parts > > are fine. > > I'm ok with pushing the commits one-by-one after the PR is reviewed, just let > me know. > > > >

[clang] [Serialization] Fix lazy template loading (PR #133057)

2025-03-28 Thread Jonas Hahnfeld via cfe-commits
hahnjo wrote: > Maybe you can test it with this and land it with different patches. So that > we can revert one of them if either of them are problematic but other parts > are fine. I'm ok with pushing the commits one-by-one after the PR is reviewed, just let me know. > > Complete only neede

[clang] [Serialization] Fix lazy template loading (PR #133057)

2025-03-26 Thread Chuanqi Xu via cfe-commits
ChuanqiXu9 wrote: > Complete only needed partial specializations: It is unclear (to me) why this > needs to be done "for safety", but this change significantly improves the > effectiveness of lazy loading. This comes from the logic: if we have a partial template specialization `A` and we need

[clang] [Serialization] Fix lazy template loading (PR #133057)

2025-03-26 Thread Chuanqi Xu via cfe-commits
ChuanqiXu9 wrote: > > While I may not able to look into them in detail recently, it may be > > helpful to split this into seperate patches to review and to land. > > I initially considered this, but @vgvassilev said in [root-project/root#17722 > (comment)](https://github.com/root-project/root/

[clang] [Serialization] Fix lazy template loading (PR #133057)

2025-03-26 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: > @ilya-biryukov, would you mind giving this PR a test on your infrastructure > and if it works maybe share some performance results? Sure, let me try kicking it off. Note that our infrastructure is much better at detecting the compilations timing out than providing proper

[clang] [Serialization] Fix lazy template loading (PR #133057)

2025-03-26 Thread Jonas Hahnfeld via cfe-commits
hahnjo wrote: ### Performance measurements with LLVM I tested these patches for building LLVM itself with modules (`LLVM_ENABLE_MODULES=ON`). To work around https://github.com/llvm/llvm-project/issues/130795, I apply https://github.com/llvm/llvm-project/pull/131354 before building Clang. In

[clang] [Serialization] Fix lazy template loading (PR #133057)

2025-03-26 Thread Vassil Vassilev via cfe-commits
vgvassilev wrote: @ilya-biryukov, would you mind giving this PR a test on your infrastructure and if it works maybe share some performance results? https://github.com/llvm/llvm-project/pull/133057 ___ cfe-commits mailing list cfe-commits@lists.llvm.or

[clang] [Serialization] Fix lazy template loading (PR #133057)

2025-03-26 Thread Jonas Hahnfeld via cfe-commits
hahnjo wrote: > While I may not able to look into them in detail recently, it may be helpful > to split this into seperate patches to review and to land. I initially considered this, but @vgvassilev said in https://github.com/root-project/root/pull/17722#issuecomment-2706555950 he prefers a s

[clang] [Serialization] Fix lazy template loading (PR #133057)

2025-03-26 Thread Jonas Hahnfeld via cfe-commits
https://github.com/hahnjo created https://github.com/llvm/llvm-project/pull/133057 * Hash inner template arguments: The code is applied from `ODRHash::AddDecl` with the reasoning given in the comment, to reduce collisions. This was particularly visible with STL types templated on `std::pair`

[clang] [Serialization] Fix lazy template loading (PR #133057)

2025-03-26 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang Author: Jonas Hahnfeld (hahnjo) Changes * Hash inner template arguments: The code is applied from `ODRHash::AddDecl` with the reasoning given in the comment, to reduce collisions. This was particularly visible with STL types templated on `std::p