From a5e35dd106e84e5db0cacde27be4b492df309705 Mon Sep 17 00:00:00 2001 From: Prashant-Shekhar-Rao <139104389+Prashant-Shekhar-Rao@users.noreply.github.com> Date: Thu, 7 Sep 2023 19:18:37 +0530 Subject: [PATCH] Updated index.md to add a command which can show unoptimized MIR The current playground link used in the page of MIR shows a optimized version of MIR which is missing some statements such as StorageLive . Updated to use a local command which shows unoptimized MIR that would be more useful for pedagogical purposes. --- src/mir/index.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/mir/index.md b/src/mir/index.md index dc0be167..b90c5ad8 100644 --- a/src/mir/index.md +++ b/src/mir/index.md @@ -62,6 +62,12 @@ show you the MIR for your program. Try putting this program into play button on the top: [sample-play]: https://play.rust-lang.org/?gist=30074856e62e74e91f06abd19bd72ece&version=stable +MIR shown by above link is optimized. +Some statements like `StorageLive` are removed in optimization. +This happens because compiler notices the value is never acessed in the code. +We can use `rustc [filename].rs -Z mir-opt-level=0 --emit mir` to view unoptimized MIR. +This requires the nightly toolchain. + ```rust fn main() {