From ac865b1b83952015d89cc8fde4702148c5eac3c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Rodr=C3=ADguez?= Date: Thu, 20 Jul 2023 15:24:53 +0200 Subject: [PATCH] fix: Only flatten main (#1984) --- crates/noirc_evaluator/src/ssa_refactor/opt/flatten_cfg.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/crates/noirc_evaluator/src/ssa_refactor/opt/flatten_cfg.rs b/crates/noirc_evaluator/src/ssa_refactor/opt/flatten_cfg.rs index 3b6512a3c45..6ffbacf652c 100644 --- a/crates/noirc_evaluator/src/ssa_refactor/opt/flatten_cfg.rs +++ b/crates/noirc_evaluator/src/ssa_refactor/opt/flatten_cfg.rs @@ -157,16 +157,14 @@ use crate::ssa_refactor::{ mod branch_analysis; impl Ssa { - /// Flattens the control flow graph of each function such that the function is left with a + /// Flattens the control flow graph of main such that the function is left with a /// single block containing all instructions and no more control-flow. /// /// This pass will modify any instructions with side effects in particular, often multiplying /// them by jump conditions to maintain correctness even when all branches of a jmpif are inlined. /// For more information, see the module-level comment at the top of this file. pub(crate) fn flatten_cfg(mut self) -> Ssa { - for function in self.functions.values_mut() { - flatten_function_cfg(function); - } + flatten_function_cfg(self.main_mut()); self } }