Do we have a pass that can eliminate stores that are never read? Const prop can leave a lot of those behind when it runs.
SimplifyLocals does a rather naive form of DSE
Specifically it removes stores to locals where the local is never read, rather than where the stored value is never read.
Ah I see, that should already help
More robust DSE is one of the things I wanted to implement now that intrablock liveness is easy to compute.
I think I'll work on that next week.
Somewhat related, I'm working on being able to remove locals that are only used for debug info while still preserving the debug info data.
Hi! I played around with the playground, looking for simple MIR optimizations. In this code https://play.rust-lang.org/?version=nightly&mode=release&edition=2018&gist=5e51319bc039ba93e4006ce775988439 "x" is const so no side effects and completely dead. It is however not removed.
I'm reviving this topic as that seems to be the "more robust DSE" being talked about. Any progress on that @ecstatic-morse , @Wesley Wiser ? If not, I could be interested in giving a (simple) pass a shot. Would this fit inside SimplifyLocals, or should it be pulled out into a separate dead-code-elimination pass?
Hi @Simon Vandel Sillesen! I've actually got a PR up that's waiting to merge that resolves that https://github.com/rust-lang/rust/pull/73210
(The thing that's causing
x to hang around is because it's being used by debuginfo)
Alright, that sounds good!
If you're looking for an optimization to work on, I think @oli has some "beginner" ones in mind :slight_smile: