-
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
Polymorphization #69749
Polymorphization #69749
Conversation
This comment has been minimized.
This comment has been minimized.
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.
Some minor things...
src/librustc/ty/instance.rs
Outdated
if self.substs.has_param_types() { | ||
if self.substs.has_param_types() && !tcx.sess.opts.debugging_opts.polymorphize { | ||
bug!("Instance.ty called for type {:?} with params in substs: {:?}", ty, self.substs); |
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 forget where/if I left a comment, but the current situation with Instance
's types and Instance::ty_env
in particular is pretty bad and we should probably require passing ParamEnv
around a lot (or maybe start using ParamEnvAnd<Instance>
?).
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 think it was #67800 (comment).
Why does this use |
Using Also, if the parameters are truly unused then we might get away without a |
This commit implements the `unused_generic_params` query, an initial version of polymorphization which detects when an item does not use generic parameters and is being needlessly monomorphized as a result. Signed-off-by: David Wood <david@davidtw.co>
This commit normalizes function signatures for instances before substituting, a workaround for polymorphization considering parameters unused when they show up in the signature, but not the body (due to being normalized). Unfortunately, this causes test output to change with the parallel compiler only. Signed-off-by: David Wood <david@davidtw.co>
This commit records the results of `unused_generic_params` in crate metadata, hopefully improving performance. Signed-off-by: David Wood <david@davidtw.co>
This commit replaces the `-Z polymorphize-errors` debugging flag with a `#[rustc_polymorphize_error]` attribute for use on functions. Signed-off-by: David Wood <david@davidtw.co>
This commit introduces a `FiniteBitSet` type which replaces the manual bit manipulation which was being performed in polymorphization. Signed-off-by: David Wood <david@davidtw.co>
912db12
to
4b99699
Compare
@bors r=eddyb |
📌 Commit 4b99699 has been approved by |
🌲 The tree is currently closed for pull requests below priority 5, this pull request will be tested once the tree is reopened |
☀️ Test successful - checks-actions, checks-azure |
Tested on commit rust-lang/rust@b52522a. Direct link to PR: <rust-lang/rust#69749> 💔 miri on windows: test-pass → build-fail (cc @oli-obk @eddyb @RalfJung). 💔 miri on linux: test-pass → build-fail (cc @oli-obk @eddyb @RalfJung).
rustup Following rust-lang/rust#69749 I added some `ty::ParamEnv::reveal_all()` even though @eddyb advised me in the past to avoid those.
This was a perf loss on landing, as expected. |
This PR implements an analysis to detect when functions could remain polymorphic during code generation.
Fixes #46477
r? @eddyb
cc @rust-lang/wg-mir-opt @nikomatsakis @pnkfelix