How can I disable all MIR optimizations during compilation?
I tried using the following flags, but it still applies various MIR optimization passes (including ElaborateDrops, etc.):
$ rustc --version
rustc 1.72.0-nightly (d59363ad0 2023-06-01)
$ rustc test.rs --emit=mir -C opt-level=0 -Z mir-opt-level=0 -Z dump-mir=all
Is there a way to completely turn off MIR optimization?
ElaborateDrops is not a mere optimization, it's a pass that's required to get to codegen. This is true for others as well. But you can generally turn off passes using
-Zmir-enable-passes=-PassName which I think takes a comma separated list or something like that.
Why do you want turn off all MIR opts?
I was debugging how
And also wanted to understand what's happening during compilation and make it easier to test while hacking on the implementation.
If I turn off ElaborateDrops(+others), will there be any issues during compilation?
A bunch of them are absolutely critical. For example, if you turn off
LowerIntrinsics a whole lot of things start ICEing in codegen.
If you just want to disable mir-opt for your function using custom-mir, then mark it as being in the final phase, like
#[custom_mir(dialect = "runtime", phase = "optimized")]
So if I only want to view the MIR that has been generated prior to any optimizations and do not care about the subsequent process,
the only way is disable all the passes using
(If it's not the case using custom_mir)
I'm doing it to write Rust code (which includes custom_mir) that generates ICE, based on MIR obtained from the ICE code samples.
-Zmir-opt-level=0 should disable all optimizations and none of the mandatory passes.
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.