-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Prevent type sufix to appear in ROOT normalized name #18373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
@makortel @Dr15Jones Any opinions on the interface to see the auto-parsed classes and to disable auto-parsing in TClass::GetClass. |
Test Results 18 files 18 suites 4d 9h 40m 26s ⏱️ Results for commit d3f4129. ♻️ This comment has been updated with latest results. |
Can we find which commit broke that in llvm? |
interpreter/llvm-project/clang/include/clang/AST/PrettyPrinter.h
Outdated
Show resolved
Hide resolved
'Technically' it is Details
However, the improvement in itself is not bad and is actually necessary in other cases when producing code, it just need to be made optional (which is what the commit in this PR does). |
Are you sure this is the right commit? 8dff24d is a downstream commit by Axel.
The code you were touching in your revert is in fact optional, for Edit: Ah, now I see this is where |
Why this cannot go upstream? |
I personally do not see any reason why not (It is an opt-in behavior change) |
Yes, it is the one I meant as it 'originally' (or at least that more or what I thought ... I could wrong) started to introduce the suffixes.
There is indeed 100% correct ;) and the patch I proposing forces
:) |
Probably the part that we will need to explain is why we need a separate switch and should not be the default behavior. |
Our downstream version yes, but not the code that is causing problems / that you were modifying in your "revert": If you look at https://github.com/root-project/root/blame/b41de52bae91bc44a24f132f80a0e973f05b0c35/interpreter/llvm-project/clang/lib/AST/TemplateBase.cpp#L107-L135, that code comes from upstream LLVM 13. Our downstream lines are in https://github.com/root-project/root/blame/b41de52bae91bc44a24f132f80a0e973f05b0c35/interpreter/llvm-project/clang/lib/AST/TemplateBase.cpp#L137-L142 and there you can also see that it went through many revisions and doesn't look anymore like the first version in 8dff24d (but only adds it if required). If you then look at the upstream blame https://github.com/llvm/llvm-project/blame/028429ac452acde227ae0bfafbfe8579c127e1ea/clang/lib/AST/TemplateBase.cpp#L104-L132 you see that it was introduced by llvm/llvm-project@99d63cc (committed by @vgvassilev). That commit also adds (And why am I spending so much time explaining to you how |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please split off the new TClass
feature into a separate PR? It should be independent of the template argument printing in Clang.
I have not look at the upstream LLVM and the end result is unchanged:
If you want you can explore the details with the standalone reproducer root-project/roottest#1302
Sure but if it is the 'correct' behavior, we still can not adapt ROOT in a short time. We need the name without the suffix (for now). Hence the opt-in proposed behavior which allows to create a consistent no-suffix name. |
Okay, I think I start understanding where we are going. So in some places we lost the spelling as written in the code and that resulted the suffix to be printed only sometimes. The current approach of dropping the suffix will likely not work for literals that are larger than in and really need the suffix to make it work. We currently have such cases in the dictionaries iirc (mersenne_twister). Can we find out why the suffix was not printed when the user typed it in the code instead? |
A change that fixes one use case still doesn't make a correct solution. I maintain that more care and deeper investigation is required.
I disagree: Axel's downstream patch adds the type for 64-bit unsigned integers unconditionally if required to represent the literal. llvm/llvm-project@99d63cc adds a suffix for all widths and regardless of the value if |
I guess this is one of the tricky situations where we have discussed in the past as a theoretical setup. An experiment needs a fix which ought to be quick. We have a quick fix, which I am pretty sure it is not acceptable upstream. We can't really dedicate a lot of time to turn things upside down in clang due to @pcanal time commitments I suspect. We have several suboptimal options:
In the past we did not dare with 1); we mostly did 2) and that's why we are where we are now. We rarely tried 3) which arguably suboptimal but a reasonable way forward due to the constrain various people have... |
This is not an option. The problem would affect any code where the class with a dictionary has a template parameter which is a
I am not sure what you have in mind but the code paths here are the one for 'name normalization' where we don't want the type sugar (except in some cases like For the record here are 3 stack traces where we need to disallow the priting of the suffix: Details
|
This is necessary to allow ROOT normalized names to never have the type suffix added to integral template arguments.
This solves problems caused by some code paths producing normalized name with unexpectedly added type suffix after on integral non-type template parameters. This fixes root-project#18363
Note: the PR has been trimmed to only the 2 commits related to the name normalization, including 0a0e7a9 which would need to make its way to the mono repo (i.e. 'fix' https://github.com/root-project/root/actions/runs/14448578670/job/40515239847?pr=18373) The new PR is #18402 |
I agree.
I do not think we understand what this fixes in practice. I want to reproduce the error with clang and normal c++ code first. That would mean taking a look at the patch that @hahnjo sent with his git blame and see how the tests triggered the codepaths in question. Another easy way to see the impact of your patch is to apply it on clang, make it on by default and run its test suite. I think the current patch would break quite a few things. |
That's "impossible". The patch is completely opt-in. The code would need to somehow (I assume using UB) set the new data member |
I wrote "Another easy way to see the impact of your patch is to apply it on clang, make it on by default and run its test suite." |
EDIT: The impossible part is technically right for the current patch and the tests. I can tweak my statement to "I think the current patch would silently break quite a few things" :) |
Sorry, I missed that :) |
I am not intending to be annoying here and it may not be obvious from outside but we have spent a lot of blood, sweat and tears in trying to reduce patches that were born in the same way as this PR is going... Let's try to do something else here -- once you get the setup and the commit -- I expect that invested effort won't be significantly larger to fix the issue upstream. |
That is fair and would be an investigation into whether or not the change @hahnjo mentioned are functioning as intended or not. Can someone volunteer to do this investigation while we merge this maybe temporary patch so that CMSSW can move forward? (Note: As long as |
What is the issue you are suspecting? See the example Is the question whether Clang is correct in tagging the argument's type as 'deduced' for the specific example? So the most genuine question for this patch is "is there any cases of class template instances where Clang would like to default to add the suffix to any integral number?". If the answer is yes there is at least one case where the suffix will be added, then we need this patch. The current answer in
I am still not sure why the patch could not be upstreamed .... Anyways, @devajithvs @aaronj0 Do you have time to look into whether Clang is doing the 'right'/'intended' thing in printing the type in that case. And/or as Vassil suggested, apply this patch to regular clang, turn on the 'Never' flag by default and report the failures? |
If we merge this pull request we essentially move the responsibility from the author of the PR to somebody else to fix it and that somebody has no incentive to do anything. That's how we got here in a first place. To be constructive, if you feed me a reproducer with standalone clang I can take a look. |
It fixes that when |
I had a quick look at one of the Clang tests and In this case, the suffix is absolutely required because all of |
What would be required to change the name normalization? (I’m trying to understand) I assume you mean setting |
The problem is not to change it (albeit due to the many code paths, it might also be not straightforward), it is the consequences of changing it. The change in name normalization will change the checksum of those classes and all the classes that contain them. We would need to upgrade all the algorithm that are use to match CheckSum values to Class layout schema to handle the transition from the old to the new scheme (to be able to still properly read 'old' file). We may have to adjust older releases (patches) to do the converse to allow forward compatibility. In addition some experiments (CMS for example) have code to make sure that their code is not changed without update class version and so they record the checksum of the current version ... those would need to be updated. PS. And it is guaranteed that I forgot one or more additional things to have to handle :( |
This fixes #18363 and thus cms-sw/cmssw#47697.
The companion PR is root-project/roottest#1302
This PR actually 2 related parts
a - an update to LLVM type printer and its use within ROOT
b - an improvement in the detection of unwanted auto-parsing
a. LLVM update
The update to LLVM allows to completely prevent the addition of type suffixes when printing names rather than the current default (there for some types - and in addition, at least how we use it in ROOT, even for those types not consistently there).
In practice, in the failing case, we were getting this normalized name:
instead of
Note that in the failing case only one of the two integers is suffixed by "UL". I did not tracked down the cause of this discrepancy.
In addition, we also produce alternate spelling of names to ease lookup (by preventing auto-parsing in some trivial case of alternative spelling).
As a side note, another source of confusion is the following.
In the successful run of the example with get:
where the alternate have the suffix ... but in lower case. The alternates here are produced by
abi::__cxa_demangle
. (the exact same spelling appears for the alternate in the failing case).