-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Refactor HIR item-like traversal #95004
Comments
@rustbot claim |
Not sure why rustbot is ignoring me but I'd like to pick this up. I'll have some bandwidth in the next couple of weeks to work on this. |
… r=cjgillot Refactor HIR item-like traversal (part 1) Issue rust-lang#95004 - Create hir_crate_items query which traverses tcx.hir_crate(()).owners to return a hir::ModuleItems - use tcx.hir_crate_items in tcx.hir().items() to return an iterator of hir::ItemId - use tcx.hir_crate_items to introduce a tcx.hir().par_items(impl Fn(hir::ItemId)) to traverse all items in parallel; Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com> cc `@cjgillot`
… r=cjgillot Refactor HIR item-like traversal (part 1) Issue rust-lang#95004 - Create hir_crate_items query which traverses tcx.hir_crate(()).owners to return a hir::ModuleItems - use tcx.hir_crate_items in tcx.hir().items() to return an iterator of hir::ItemId - use tcx.hir_crate_items to introduce a tcx.hir().par_items(impl Fn(hir::ItemId)) to traverse all items in parallel; Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com> cc `@cjgillot`
…-rustc-typeck, r=cjgillot Remove ItemLikeVisitor impls from rustc_typeck Issue rust-lang#95004 cc `@cjgillot`
…t, r=cjgillot Retire `ItemLikeVisitor` trait Issue rust-lang#95004 cc `@cjgillot`
…-rustc-typeck, r=cjgillot Remove ItemLikeVisitor impls from rustc_typeck Issue rust-lang#95004 cc `@cjgillot`
…t, r=cjgillot Retire `ItemLikeVisitor` trait Issue rust-lang#95004 cc `@cjgillot`
@cjgillot I think #96825, #96531, and #95655 have address the tasks in this issue. We have created If the parallelization of the compiler still in early stages, maybe it would be better to address the parallelization-related tasks in this issue in a future issue along with other parallelization-related endeavors? If so, I'll leave it up to you to review and approve or close #97998. |
HIR is globally traversed using the
tcx.hir().{,par_}visit_all_item_likes{,_in_module}
family of functions. These functions create a lot of dependency edges (they call thehir_crate
query, or callhir_owner
for each item-like). These dependencies are not always useful: many use sites only requireitem
s, and don't care for impl items, trait items or foreign items.This can be avoided by replacing those functions by a scheme based on
ItemId
s. Actual user will be responsible for callingtcx.hir().item
to get the HIR. The amount of access to HIR will be further reduced by pre-filtering usingtcx.def_kind
query.Steps:
hir_crate_items
query which traversestcx.hir_crate(()).owners
to collect all the ids and return arustc_middle::hir::ModuleItems
;tcx.hir_crate_items
intcx.hir().items
to return an iterator ofhir::ItemId
;tcx.hir_crate_items
to introduce atcx.hir().par_items(impl Fn(hir::ItemId))
to traverse all items in parallel;tcx.hir().{,par_}visit_all_item_likes
withtcx.hir().par_items
ortcx.hir().items
;when possible, create a fast path using
tcx.def_kind(item_id.def_id)
before callingtcx.hir().item(item_id)
;tcx.hir().items_in_module
andtcx.hir().par_items_in_module
which do the same thing withtcx.hir_module_items
instead oftcx.hir_crate_items
;tcx.hir().visit_all_item_likes_in_module
withtcx.hir().par_items_in_module
ortcx.hir().items_in_module
;hir::ItemLikeVisitor
.The steps starting with "gradually" can be split into several PRs.
I am available on zulip for any question.
The text was updated successfully, but these errors were encountered: