-
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
Further simplify the macros generated by rustc_queries
#101173
Conversation
7b9cf74
to
f96d7fa
Compare
[$($attrs:tt)*] | ||
$variant:ident $(( $tuple_arg_ty:ty $(,)? ))* | ||
,)* | ||
$( $( #[$attr:meta] )* $variant:ident, )+ |
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.
We lose the documentation for variants defined using the proc-macro, but get some for the nodes defined in this file. Shouldn't we have documentation for all or nothing?
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.
Oh, excellent catch. Yes, I forgot that previously attrs
could include doc-comments, I agree we should keep those.
I almost wonder if we should remove rustc_query_names
altogether and force everyone to match on the tokens for rustc_query_append
. It's not that much extra work and it allows getting rid of another macro, and makes it easy to extend all the callsites to use the additional info in the future if they need it.
(Just as a note, we weren't including the doc-comments even before my change, we would match on them and then immediately discard them.)
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.
Having just rustc_query_append
seems great. We'll just need a bit of creativity to give a signature to the 5 extra dep-nodes. Actually, could we declare those 5 extra dep-nodes inside rustc_middle::query
directly, and get rid of the _append
part of the macro?
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.
Yes, I think I can do both those things :) and it should be possible to get rid of rustc_cached_queries
at the same time, since we can match on the cache
modifier in the macro rather than requiring it be done by the proc-macro.
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.
I'm going to avoid declaring the 5 dep-nodes in rustc_middle::query
for now; ignoring the snake_case
warning is harder than I expected (at least until #101512 is fixed), and it's not that hard to add the extra matchers in the other macros. I'll try and follow up on that later.
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.
Ok, got rid of rustc_query_names
and rustc_cached_queries
. I think it might be possible to remove rustc_query_description
after #101307 is merged, using (cache = $expr)
and (desc = $fmt_str, $($arg),*)
.
5210df9
to
64aa648
Compare
- Add a new `rustc_query_names` macro. This allows a much simpler syntax for the matchers in the macros passed to it as a callback. - Convert `define_dep_nodes` and `alloc_once` to use `rustc_query_names`. This is possible because they only use the names (despite the quite complicated matchers in `define_dep_nodes`, none of the other arguments are used). - Get rid of `rustc_dep_node_append`.
This comment has been minimized.
This comment has been minimized.
… macro We can avoid these by adding slightly more information to `rustc_query_append` instead.
64aa648
to
3a4e3c7
Compare
@bors try @rust-timer perf |
⌛ Trying commit cb2949e with merge 39c01438377c09997b8cb33020a9c4636ea8d7f8... |
☀️ Try build successful - checks-actions |
@rust-timer build 39c01438377c09997b8cb33020a9c4636ea8d7f8 |
Queued 39c01438377c09997b8cb33020a9c4636ea8d7f8 with parent c97922d, future comparison URL. |
Finished benchmarking commit (39c01438377c09997b8cb33020a9c4636ea8d7f8): comparison URL. Overall result: no relevant changes - no action neededBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. @bors rollup=never Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Footnotes |
@bors r+ |
☀️ Test successful - checks-actions |
Finished benchmarking commit (294f0ee): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Footnotes |
Use function pointers instead of macro-unrolled loops in rustc_query_impl By making these standalone functions, we a) allow making them extensible in the future with a new `QueryStruct` b) greatly decrease the amount of code in each individual function, avoiding exponential blowup in llvm Helps with rust-lang#96524. Based on rust-lang#101173; only the last commit is relevant. r? `@cjgillot`
This doesn't actually move anything outside the macros, but it makes them simpler to read.
rustc_query_names
macro. This allows a much simpler syntax for the matchers in the macros passed to it as a callback.define_dep_nodes
andalloc_once
to userustc_query_names
. This is possible because they only use the names(despite the quite complicated matchers in
define_dep_nodes
, none of the other arguments are used).rustc_dep_node_append
.r? @cjgillot