Improve method resolution by using indexes - #4847
Merged
Merged
Conversation
philberty
force-pushed
the
phil/method-resolution-perf
branch
from
September 4, 2026 22:10
f11f9ba to
3aa4156
Compare
This is part 1 of more series of patches to improve method resolution perf because its incredibly expensive operation. This changes it so that we try predicates up front before looking up anything. gcc/rust/ChangeLog: * typecheck/rust-hir-dot-operator.cc (MethodResolver::select): look at predicates first Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog: * typecheck/rust-hir-dot-operator.cc (MethodResolver::select): use sperate index * util/rust-hir-map.cc (Mappings::insert_hir_impl_block): new indexes * util/rust-hir-map.h: likewise Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog: * typecheck/rust-tyty-bounds.cc (TypeBoundsProbe::scan): use trait index Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog: * typecheck/rust-hir-dot-operator.cc: use item name indexes * util/rust-hir-map.cc (Mappings::insert_hir_impl_block): new index (Mappings::insert_trait_item_mapping): likewise * util/rust-hir-map.h: likewise Signed-off-by: Philip Herron <herron.philip@googlemail.com>
…ndexes I used a node-id mapping just out of handyness because the trait-impls or impls to defid's uses the name resolver to NodeIds but to use DefId we need to do an indexing pass at the end of hir lowering then to get the DefId mappings. gcc/rust/ChangeLog: * hir/rust-ast-lower-item.cc (register_adt_impl): remove (ASTLoweringItem::visit): likewise * rust-session-manager.cc (Session::compile_crate): call new indexer * typecheck/rust-hir-dot-operator.cc (MethodResolver::try_select_predicate_candidates): use indexes * typecheck/rust-hir-path-probe-expr.cc (PathProbeExpr::probe_adt_impls): likewise * typecheck/rust-hir-path-probe-impl-trait.cc (PathProbeImplTrait::process_trait_impl_items_for_candidates): likewise * typecheck/rust-hir-path-probe-type.cc (TypePathProbe::probe_adt): likewise * typecheck/rust-tyty-bounds.cc (TypeBoundsProbe::scan): likewise * util/rust-hir-map.cc (Mappings::Mappings): new indexer (Mappings::insert_hir_impl_block): likewise (Mappings::insert_adt_impl_mapping): likewise (Mappings::build_impl_indexes): likewise (Mappings::insert_trait_impl_mapping): likewise (Mappings::insert_trait_item_mapping): likewise * util/rust-hir-map.h: likewise Signed-off-by: Philip Herron <herron.philip@googlemail.com>
philberty
force-pushed
the
phil/method-resolution-perf
branch
from
September 6, 2026 15:22
3aa4156 to
abe8b0e
Compare
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.
A set of patches to improve our method resolution