resolver: Delay copy of TemplateState

Shows up in profiling, and doesn't always need to be done.

Change-Id: If8bf061563979d17dea4c48334dab4834770d921
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116865
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
This commit is contained in:
Ben Clayton 2023-01-11 22:16:08 +00:00 committed by Dawn LUCI CQ
parent c231e180d7
commit 6345562a98
1 changed files with 6 additions and 2 deletions

View File

@ -1154,7 +1154,7 @@ class Impl : public IntrinsicTable {
Candidate ScoreOverload(const OverloadInfo* overload,
utils::VectorRef<const type::Type*> args,
sem::EvaluationStage earliest_eval_stage,
TemplateState templates) const;
const TemplateState& templates) const;
/// Performs overload resolution given the list of candidates, by ranking the conversions of
/// arguments to the each of the candidate's parameter types.
@ -1560,7 +1560,7 @@ IntrinsicPrototype Impl::MatchIntrinsic(const IntrinsicInfo& intrinsic,
Impl::Candidate Impl::ScoreOverload(const OverloadInfo* overload,
utils::VectorRef<const type::Type*> args,
sem::EvaluationStage earliest_eval_stage,
TemplateState templates) const {
const TemplateState& in_templates) const {
// Penalty weights for overload mismatching.
// This scoring is used to order the suggested overloads in diagnostic on overload mismatch, and
// has no impact for a correct program.
@ -1580,6 +1580,10 @@ Impl::Candidate Impl::ScoreOverload(const OverloadInfo* overload,
std::min(num_parameters, num_arguments));
}
// Make a mutable copy of the input templates so we can implicitly match more templated
// arguments.
TemplateState templates(in_templates);
// Invoke the matchers for each parameter <-> argument pair.
// If any arguments cannot be matched, then `score` will be increased.
// If the overload has any template types or numbers then these will be set based on the