-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
make the eval() functions on our const types return the resulting value #115803
Conversation
r? @b-naber (rustbot has picked a reviewer for you, use r? to override) |
Some changes occurred to the CTFE / Miri engine cc @rust-lang/miri Some changes occurred in src/tools/clippy cc @rust-lang/clippy Some changes might have occurred in exhaustiveness checking cc @Nadrieril Some changes occurred in compiler/rustc_codegen_cranelift cc @bjorn3 Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
compiler/rustc_middle/src/mir/mod.rs
Outdated
ConstantKind::Ty(c) => { | ||
if let ty::ConstKind::Unevaluated(uv) = c.kind() { | ||
// Avoid the round-trip via valtree, evaluate directly to ConstValue. | ||
uv.expand() |
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 wanted to start with as small a change as possible, so this avoids the intermediate valtree for now.
r? @oli-obk |
This comment has been minimized.
This comment has been minimized.
make the eval() functions on our const types return the resulting value This is a part of rust-lang#115748 that's hopefully perf-neutral, and that does not depend on rust-lang#115764.
This comment has been minimized.
This comment has been minimized.
35fa022
to
a151f93
Compare
a151f93
to
6086a68
Compare
@bors try |
make the eval() functions on our const types return the resulting value This is a part of rust-lang#115748 that's hopefully perf-neutral, and that does not depend on rust-lang#115764.
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (d9931dc): comparison URL. Overall result: ❌ regressions - 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. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @bors rollup=never Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
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.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 631.022s -> 629.231s (-0.28%) |
tcx.erase_regions(param_env) | ||
.with_reveal_all_normalized(tcx) | ||
.and(tcx.erase_regions(unevaluated)) | ||
}; |
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.
This is some magic that only the Valtree path has, maybe that's where the perf diff comes from?
This comment has been minimized.
This comment has been minimized.
make the eval() functions on our const types return the resulting value This is a part of rust-lang#115748 that's hopefully perf-neutral, and that does not depend on rust-lang#115764.
☀️ Try build successful - checks-actions |
1 similar comment
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (1c3b6c4): 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.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 631.557s -> 631.698s (0.02%) |
Nice, so that Should be ready to land. This can be further cleaned up, but given how perf-sensitive this is I like landing this in small chunks that can be separately benchmarked. Further cleanup would be:
|
2c1c85b
to
8ef6b7a
Compare
|
||
/// Normalizes the constant to a value or an error if possible. | ||
#[inline] | ||
pub fn normalize(self, tcx: TyCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>) -> Self { |
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.
Do we want this method to translate a ValTree into a ConstValue? For normalization, it may be more interesting to keep the ValTree unchanged, as it is already a legal value.
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.
This is a MIR constant, its normal form is a ConstValue. (Also this matches prior behavior.)
If we leave this as a valtree, then every future call to eval
has to do the conversion again. That seems like a lot of wasted effort.
@bors r+ |
☀️ Test successful - checks-actions |
Finished benchmarking commit (76e59c7): 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.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 632.169s -> 632.671s (0.08%) |
This is a part of #115748 that's hopefully perf-neutral, and that does not depend on #115764.