@oli @Wesley Wiser hey, do you think it would be cheap to check in the constant folder if a local always has a constant value whenever initialized?
I guess it could be its own pass post-constant-folding, that checks for one initialization and no mutation
I want to have
debug x => _123; replaced with e.g.
debug x => const 42usize; wherever possible
the other thing we could do is
debug a => &b.c; (value of debug var a is always the address of a place with no runtime indexing or derefs)
the latter wouldn't count as a borrow because only the debugger would see it, and also both it and the constant form could use
the goal is to reduce the impact of debuginfo on optimizations and codegen
but maybe I should do some statistics on the kinds of things that are e.g. unnecessarily on the stack in debug mode
@eddyb By "constant folder" do you mean const-prop or something else?
yeah I guess it's called const-prop
I'd argue propagation is just replacing uses with the value at the definition, whereas folding is e.g.
_5 = 1 + 2 =>
_5 = 3 (there's no propagation there)
the current pass is a combination of propagation and folding
I can't imagine it would be expensive
We've already done that check and know what locals satisfy that constraint
oh right you're not relying on dataflow?
I guess you couldn't have, @ecstatic-morse's stuff is pretty recent
Nah, not yet