If I compile with cargo rustc -- --emit=llvm-ir the compiler will emit LLVM IR.
Here are the LLVM passes that Rust uses. What LLVM passes, if any, have been performed on the emitted IR?
Is there any way to specify what passes you would like performed before emitting IR?
If you are using the nightly compiler, you could use the
-Z print-llvm-passesto let LLVM print what passes are run. I'd recommend passing in-Z no-parallel-llvmand-C codegen-units=1too to make the output cleaner and less repetitive.(The
-Z print-llvm-passesflag is equivalent to-C llvm-args=-debug-pass=Structurewhich is usable on stable rustc. However, without-Z no-parallel-llvmthe output is quite unreadable.)You could append additional passes using the
-C passesargument. You may also clear the default optimization passes with-C no-prepopulate-passes. Example: