From 32c4e57dc94291e525e6fbedd1996f341de577ae Mon Sep 17 00:00:00 2001 From: Ary Borenszweig Date: Wed, 18 Jun 2025 09:18:08 -0300 Subject: [PATCH 1/3] Fix comment inside `should_inline_call` lambda --- compiler/noirc_evaluator/src/ssa/opt/inline_simple_functions.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/noirc_evaluator/src/ssa/opt/inline_simple_functions.rs b/compiler/noirc_evaluator/src/ssa/opt/inline_simple_functions.rs index 90d903da726..0a3449a6314 100644 --- a/compiler/noirc_evaluator/src/ssa/opt/inline_simple_functions.rs +++ b/compiler/noirc_evaluator/src/ssa/opt/inline_simple_functions.rs @@ -59,7 +59,7 @@ impl Ssa { return true; } - // Check whether the only instruction is a recursive call, which prevents inlining the callee. + // Don't inline recursive functions if recursive_functions.contains(&callee.id()) { return false; } From 57f0b630dfc06de0de8c4a46b5013f457ca7a1c6 Mon Sep 17 00:00:00 2001 From: Ary Borenszweig Date: Wed, 18 Jun 2025 09:23:04 -0300 Subject: [PATCH 2/3] Only mark instruction as modified when it was actually modified --- compiler/noirc_evaluator/src/ssa/opt/defunctionalize.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/compiler/noirc_evaluator/src/ssa/opt/defunctionalize.rs b/compiler/noirc_evaluator/src/ssa/opt/defunctionalize.rs index d8b6d39f459..4449e585238 100644 --- a/compiler/noirc_evaluator/src/ssa/opt/defunctionalize.rs +++ b/compiler/noirc_evaluator/src/ssa/opt/defunctionalize.rs @@ -256,12 +256,17 @@ fn remove_first_class_functions_in_instruction( *arg = map_value(*arg); } } else if let Instruction::MakeArray { typ, .. } = instruction { + let mut modified_type = false; if let Some(rep) = replacement_type(typ) { *typ = rep; + modified_type = true; } + instruction.map_values_mut(map_value); - modified = true; + if modified_type { + modified = true; + } } else { instruction.map_values_mut(map_value); } From 0204ab9cd41bbb0d74a0470978d2d42601559b7e Mon Sep 17 00:00:00 2001 From: Ary Borenszweig Date: Wed, 18 Jun 2025 09:35:58 -0300 Subject: [PATCH 3/3] Improve comment --- compiler/noirc_evaluator/src/ssa/opt/defunctionalize.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/noirc_evaluator/src/ssa/opt/defunctionalize.rs b/compiler/noirc_evaluator/src/ssa/opt/defunctionalize.rs index 4449e585238..a93fc07ebe6 100644 --- a/compiler/noirc_evaluator/src/ssa/opt/defunctionalize.rs +++ b/compiler/noirc_evaluator/src/ssa/opt/defunctionalize.rs @@ -583,7 +583,8 @@ fn create_apply_function( // local_end_block3--/ // // This is necessary since SSA panics during flattening if we immediately - // try to jump directly to end block instead: https://github.com/noir-lang/noir/issues/7323. + // try to jump directly to end block instead + // (see https://github.com/noir-lang/noir/issues/7323 for a case where this happens). // // It'd also be more efficient to merge them tournament-bracket style but that // also leads to panics during flattening for similar reasons.