Skip to content

Conversation

zyn0217
Copy link

@zyn0217 zyn0217 commented Aug 11, 2025

No description provided.

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();
Copy link
Owner

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)

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
Copy link
Owner

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?

Copy link
Author

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.

@cor3ntin cor3ntin merged commit b2a598b into cor3ntin:corentin/use_normalization_for_satisfaction Aug 23, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants