-
Notifications
You must be signed in to change notification settings - Fork 4
Do not normalize empty FoldExprs? #55
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
Do not normalize empty FoldExprs? #55
Conversation
clang/lib/Sema/SemaConcept.cpp
Outdated
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(); |
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.
You could compute the hash without having a FlattenedArgs vector (and I don't think you need to hash the size)
|
||
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 |
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.
Why are you doing that a second time?
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.
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
No description provided.