-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Strengthen state tracking in const-prop #108872
Conversation
r? @davidtwco (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 |
7677516
to
5f5ca66
Compare
Some changes occurred in src/tools/clippy cc @rust-lang/clippy |
source_info.span, | ||
)); | ||
*rval = | ||
Rvalue::Use(self.operand_from_scalar(scalar, value.layout.ty, DUMMY_SP)); |
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.
operand_from_scalar
could just stop taking a span alltogether
r=me with operand_from_scalar havings its span arg removed |
4d89b7b
to
8179b2e
Compare
@bors r+ rollup=never |
☀️ Test successful - checks-actions |
Finished benchmarking commit (b05bb29): comparison URL. Overall result: ❌✅ regressions and improvements - ACTION NEEDEDNext Steps: If you can justify the regressions found in this perf run, please indicate this with @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.
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.
|
for (local, &mode) in can_const_prop.iter_enumerated() { | ||
match mode { | ||
ConstPropMode::FullConstProp => {} |
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.
It looks to me like the regression is from this loop? At least that's what my profiler indicates. It looks like basically all the cycles in ConstProp
are driving this iterator and hitting this first case:
16.79 │ d0:┌─→inc %rdi
│ │<core::slice::iter::Iter<rustc_mir_transform::const_prop::ConstPropMode> as core::iter::traits::iterator::Iterator>::next:
16.05 │ │ add $0x48,%rdx
16.52 │ │ cmp %rdi,%rax
│ │↓ je 12e
│ │<rustc_middle::mir::Local>::from_usize:
│ │}
│ │
│ │///////////////////////////////////////////////////////////////////////////
│ │// Variables and temps
│ │
│ │rustc_index::newtype_index! {
25.17 │ dc:│ cmp %r8,%rdi
│ │↓ je 1b7
│ │<rustc_mir_transform::const_prop::ConstPropagator as rustc_middle::mir::visit::MutVisitor>::visit_basic_block_data:
│ │match mode {
25.18 │ ├──cmpb $0x1,(%rcx,%rdi,1)
│ └──jne d0
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 will not be working on this, but I suspect the problem centers around there being a lot of FullConstProp
in here and we could be iterating over less elements somehow.
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.
Thanks for the analysis. I'll handle it after hours.
Only clear written-to locals in ConstProp This aims to revert the regression in rust-lang#108872 Clearing all locals at the end of each bb is very costly. This PR goes back to the original implementation of recording which locals are modified.
Only clear written-to locals in ConstProp This aims to revert the regression in rust-lang/rust#108872 Clearing all locals at the end of each bb is very costly. This PR goes back to the original implementation of recording which locals are modified.
Strengthen state tracking in const-prop Some/many of the changes are replicated between both the const-prop lint and the const-prop optimization. Behaviour changes: - const-prop opt does not give a span to propagated values. This was useless as that span's primary purpose is to diagnose evaluation failure in codegen. - we remove the `OnlyPropagateInto` mode. It was only used for function arguments, which are better modeled by a write before entry. - the tracking of assignments and discriminants make clearer that we do nothing in `NoPropagation` mode or on indirect places.
Only clear written-to locals in ConstProp This aims to revert the regression in rust-lang/rust#108872 Clearing all locals at the end of each bb is very costly. This PR goes back to the original implementation of recording which locals are modified.
Only clear written-to locals in ConstProp This aims to revert the regression in rust-lang/rust#108872 Clearing all locals at the end of each bb is very costly. This PR goes back to the original implementation of recording which locals are modified.
Some/many of the changes are replicated between both the const-prop lint and the const-prop optimization.
Behaviour changes:
OnlyPropagateInto
mode. It was only used for function arguments, which are better modeled by a write before entry.NoPropagation
mode or on indirect places.