Do not normalize empty FoldExprs?#55
Merged
cor3ntin merged 15 commits intocor3ntin:corentin/use_normalization_for_satisfactionfrom Aug 23, 2025
Merged
Do not normalize empty FoldExprs?#55cor3ntin merged 15 commits intocor3ntin:corentin/use_normalization_for_satisfactionfrom
cor3ntin merged 15 commits intocor3ntin:corentin/use_normalization_for_satisfactionfrom
Conversation
cor3ntin
reviewed
Aug 22, 2025
Comment on lines
+528
to
+540
| unsigned Size = Satisfaction.Details.size(); | ||
| llvm::SmallVector<TemplateArgument, 4> FlattenedArgs; | ||
| for (auto List : *SubstitutedArgs) | ||
| for (const TemplateArgument &Arg : List.Args) | ||
| FlattenedArgs.emplace_back(S.Context.getCanonicalTemplateArgument(Arg)); | ||
|
|
||
| llvm::FoldingSetNodeID ID; | ||
| ID.AddPointer(Constraint.getConstraintExpr()); | ||
| ID.AddInteger(FlattenedArgs.size()); | ||
| for (auto &Arg : FlattenedArgs) | ||
| Arg.Profile(ID, S.Context); | ||
| ID.AddInteger(PackSubstitutionIndex.toInternalRepresentation()); | ||
| unsigned CacheKeyHash = ID.ComputeHash(); |
Owner
There was a problem hiding this comment.
You could compute the hash without having a FlattenedArgs vector (and I don't think you need to hash the size)
Comment on lines
+565
to
+575
|
|
||
| if (auto Iter = S.ConceptIdSatisfactionCache.find(CacheKeyHash); | ||
| Iter != S.ConceptIdSatisfactionCache.end()) { | ||
| #if UseCache | ||
| auto &Cached = Iter->second.Satisfaction; | ||
| Satisfaction.ContainsErrors = Cached.ContainsErrors; | ||
| Satisfaction.IsSatisfied = Cached.IsSatisfied; | ||
| Satisfaction.Details.insert(Satisfaction.Details.begin() + Size, | ||
| Cached.Details.begin(), Cached.Details.end()); | ||
| return Iter->second.SubstExpr; | ||
| #endif |
Owner
There was a problem hiding this comment.
Why are you doing that a second time?
Author
There was a problem hiding this comment.
They're adapted from what we have now
See Sema::CheckConstraintSatisfaction
// The evaluation of this constraint resulted in us trying to re-evaluate it
// recursively. This isn't really possible, except we try to form a
// RecoveryExpr as a part of the evaluation. If this is the case, just
// return the 'cached' version (which will have the same result), and save
// ourselves the extra-insert. If it ever becomes possible to legitimately
// recursively check a constraint, we should skip checking the 'inner' one
// above, and replace the cached version with this one, as it would be more
// specific.
That is a heavy operation!
b2a598b
into
cor3ntin:corentin/use_normalization_for_satisfaction
5 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.