-
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
Read from non-scalar constants and statics in dataflow const-prop #115705
Conversation
Some changes occurred to the CTFE / Miri engine cc @rust-lang/miri Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
This comment has been minimized.
This comment has been minimized.
impl<'mir, 'tcx: 'mir> rustc_const_eval::interpret::Machine<'mir, 'tcx> for DummyMachine { | ||
rustc_const_eval::interpret::compile_time_machine!(<'mir, 'tcx>); | ||
type MemoryKind = !; | ||
const PANIC_ON_ALLOC_FAIL: bool = true; | ||
|
||
#[inline(always)] | ||
fn cur_span(_ecx: &InterpCx<'mir, 'tcx, Self>) -> Span { |
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.
Hm, I wonder if this could also help avoid this nonsense in the old const-prop-lint pass
rust/compiler/rustc_mir_transform/src/const_prop_lint.rs
Lines 281 to 282 in 38bbc2c
// Overwrite the PC -- whatever the interpreter does to it does not make any sense anyway. | |
self.ecx.frame_mut().loc = Left(location); |
Specifically, we really should make loc
private, maybe we can with this hook.
|
The |
This comment has been minimized.
This comment has been minimized.
054860b
to
cc3778b
Compare
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.
r=me
45ec58e
to
6984030
Compare
@bors r+ |
☀️ Test successful - checks-actions |
Finished benchmarking commit (cc7a9d6): 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.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 631.075s -> 632.792s (0.27%) |
DataflowConstProp is designed to handle scalar values. When MIR features an assignment from a non-scalar constant, we need to manually decompose it into the custom state space.
This PR tweaks interpreter callbacks to allow reusing
eval_mir_constant
without having a stack frame to get a span from.r? @oli-obk
cc @jachris