-
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
Don't validate constants in const propagation #109521
Conversation
r? @wesleywiser (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 to MIR optimizations cc @rust-lang/wg-mir-opt |
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
⌛ Trying commit d2f3831869cf0cef3b9b1c64533e60b69c84e4e4 with merge 4ee8fa53366b8f492b736ddd0d3b28d579df07b4... |
cc @RalfJung |
@@ -36,16 +36,14 @@ macro_rules! throw_validation_failure { | |||
msg.push_str(", but expected "); | |||
write!(&mut msg, $($expected_fmt)*).unwrap(); | |||
)? | |||
let path = rustc_middle::ty::print::with_no_trimmed_paths!({ |
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, I hadn't even realized that this was added in the validity checker. Happy to see it gone!
I'm happy with the interpreter value validity checker change, but can't really comment on the ConstProp diff -- I have no idea why this check was added, and whether it was ever needed for correctness. |
☀️ 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 (4ee8fa53366b8f492b736ddd0d3b28d579df07b4): 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.
|
I do not understand the justification for this change. It doesn't make sense to me to justify changing the default behavior of the compiler based on the fact that we test in a special configuration with different behavior. |
hello visiting this PR, checking progress. @tmiasko can you share some thoughts about this comment ? thanks |
Validation is neither necessary nor desirable. The validation is already omitted at mir-opt-level >= 3, so there there are not changes in MIR test output (the propagation of invalid constants is covered by an existing test in tests/mir-opt/const_prop/invalid_constant.rs).
The constant validation errors are user facing and should always be emitted to the user - use trimmed path when constructing them.
Since constants are no longer validated before propagation the workaround is obsolete. Remove it.
d2f3831
to
4adb8fb
Compare
Thanks for reminder. The motivation for the change is to remove validation, because as far as I can see it is neither necessary for correctness nor desirable. Maybe Wesley still recalls why it was added in the first place (it started as an assertion)? Now that #109521 (comment) seems to be misreading a sentence about existing test coverage as justification, which indeed makes no sense. |
This comment has been minimized.
This comment has been minimized.
I looked through the history and couldn't figure out why I added the validation either. I also checked Zulip to see if there was some discussion or PMs around that time but didn't find anything. @bors r+ |
☀️ Test successful - checks-actions |
Finished benchmarking commit (5133e15): comparison URL. Overall result: ❌ regressions - no action needed@rustbot label: -perf-regression 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.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeResultsThis 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.
Bootstrap: 655.55s -> 657.612s (0.31%) |
Validation is neither necessary nor desirable.
The constant validation is already omitted at mir-opt-level >= 3, so there there are not changes in MIR test output (the propagation of invalid constants is covered by an existing test in tests/mir-opt/const_prop/invalid_constant.rs).