diff --git a/compiler/noirc_evaluator/src/ssa/opt/mem2reg.rs b/compiler/noirc_evaluator/src/ssa/opt/mem2reg.rs index a4e5f7dd8be..92b23f9285b 100644 --- a/compiler/noirc_evaluator/src/ssa/opt/mem2reg.rs +++ b/compiler/noirc_evaluator/src/ssa/opt/mem2reg.rs @@ -459,13 +459,9 @@ impl<'f> PerFunctionContext<'f> { self.instructions_to_remove.insert(*last_store); } - if let Some(expression) = references.expressions.get(&value) { - if let Some(aliases) = references.aliases.get(expression) { - aliases.for_each(|alias| { - self.aliased_references.entry(alias).or_default().insert(instruction); - }); - } - } + references.for_each_alias_of(value, |_, alias| { + self.aliased_references.entry(alias).or_default().insert(instruction); + }); references.set_known_value(address, value); // If we see a store to an address, the last load to that address needs to remain. @@ -521,20 +517,14 @@ impl<'f> PerFunctionContext<'f> { } } Instruction::Call { arguments, .. } => { - // We want to fetch all aliases of each argument to be marked unknown as an array - // containing references internally can potentially be aliased by those references. - let mut all_aliases = Vec::new(); + // We need to appropriately mark each alias of a reference as being used as a call argument. + // This prevents us potentially removing a last store that is altered within another function. for arg in arguments { - if let Some(expression) = references.expressions.get(arg) { - if let Some(aliases) = references.aliases.get(expression) { - aliases.for_each(|alias| { - self.instruction_input_references.insert(alias); - all_aliases.push(alias); - }); - } - } + references.for_each_alias_of(*arg, |_, alias| { + self.instruction_input_references.insert(alias); + }); } - self.mark_all_unknown(&all_aliases, references); + self.mark_all_unknown(arguments, references); } Instruction::MakeArray { elements, typ } => { // If `array` is an array constant that contains reference types, then insert each element @@ -575,7 +565,8 @@ impl<'f> PerFunctionContext<'f> { fn mark_all_unknown(&self, values: &[ValueId], references: &mut Block) { for value in values { - if self.inserter.function.dfg.value_is_reference(*value) { + let typ = self.inserter.function.dfg.type_of_value(*value); + if Self::contains_references(&typ) { let value = *value; references.set_unknown(value); references.mark_value_used(value, self.inserter.function); @@ -1296,4 +1287,50 @@ mod tests { assert_normalized_ssa_equals(ssa, src); } + + #[test] + fn keep_last_store_used_in_make_array_returned_from_function() { + let src = " + brillig(inline) fn main f0 { + b0(): + v0 = call f1() -> [&mut u1; 2] + return + } + brillig(inline) fn foo f1 { + b0(): + v0 = allocate -> &mut u1 + store u1 1 at v0 + v2 = allocate -> &mut u1 + store u1 0 at v2 + v4 = make_array [v0, v2] : [&mut u1; 2] + return v4 + } + "; + + let ssa = Ssa::from_str(src).unwrap(); + let ssa = ssa.mem2reg(); + assert_normalized_ssa_equals(ssa, src); + } + + #[test] + fn keep_last_store_in_make_array_where_aliases_are_none() { + let src = " + brillig(inline) fn foo f1 { + b0(v0: &mut u1): + v1 = call f2() -> &mut u1 + store u1 1 at v1 + v3 = make_array [v1] : [&mut u1; 1] + return v3 + } + brillig(inline) fn get_ref f2 { + b0(): + v0 = allocate -> &mut u1 + store u1 1 at v0 + return v0 + } + "; + let ssa = Ssa::from_str(src).unwrap(); + let ssa = ssa.mem2reg(); + assert_normalized_ssa_equals(ssa, src); + } } diff --git a/compiler/noirc_evaluator/src/ssa/opt/mem2reg/block.rs b/compiler/noirc_evaluator/src/ssa/opt/mem2reg/block.rs index 0d5c6ac3848..25a0b230f8e 100644 --- a/compiler/noirc_evaluator/src/ssa/opt/mem2reg/block.rs +++ b/compiler/noirc_evaluator/src/ssa/opt/mem2reg/block.rs @@ -172,7 +172,7 @@ impl Block { } /// Iterate through each known alias of the given address and apply the function `f` to each. - fn for_each_alias_of( + pub(super) fn for_each_alias_of( &mut self, address: ValueId, mut f: impl FnMut(&mut Self, ValueId) -> T, diff --git a/test_programs/execution_success/array_with_refs_return/Nargo.toml b/test_programs/execution_success/array_with_refs_return/Nargo.toml new file mode 100644 index 00000000000..aa3fb26babf --- /dev/null +++ b/test_programs/execution_success/array_with_refs_return/Nargo.toml @@ -0,0 +1,6 @@ +[package] +name = "array_with_refs_return" +type = "bin" +authors = [""] + +[dependencies] \ No newline at end of file diff --git a/test_programs/execution_success/array_with_refs_return/src/main.nr b/test_programs/execution_success/array_with_refs_return/src/main.nr new file mode 100644 index 00000000000..074b5925927 --- /dev/null +++ b/test_programs/execution_success/array_with_refs_return/src/main.nr @@ -0,0 +1,11 @@ +// Regression for issue #8786 (https://github.com/noir-lang/noir/issues/8786) +unconstrained fn main() -> pub [i8; 2] { + if (*func_5()[1].0) { + [0, 1] + } else { + [2, 3] + } +} +unconstrained fn func_5() -> [(&mut bool, str<2>, str<4>, str<4>); 2] { + [((&mut true), "AB", "WTGS", "AELL"), ((&mut false), "CD", "PKHQ", "LDWE")] +} diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/array_with_refs_return/execute__tests__expanded.snap b/tooling/nargo_cli/tests/snapshots/execution_success/array_with_refs_return/execute__tests__expanded.snap new file mode 100644 index 00000000000..fe82b3fcd4f --- /dev/null +++ b/tooling/nargo_cli/tests/snapshots/execution_success/array_with_refs_return/execute__tests__expanded.snap @@ -0,0 +1,15 @@ +--- +source: tooling/nargo_cli/tests/execute.rs +expression: expanded_code +--- +unconstrained fn main() -> pub [i8; 2] { + if *func_5()[1].0 { + [0, 1] + } else { + [2, 3] + } +} + +unconstrained fn func_5() -> [(&mut bool, str<2>, str<4>, str<4>); 2] { + [(&mut true, "AB", "WTGS", "AELL"), (&mut false, "CD", "PKHQ", "LDWE")] +} diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/array_with_refs_return/execute__tests__force_brillig_false_inliner_-9223372036854775808.snap b/tooling/nargo_cli/tests/snapshots/execution_success/array_with_refs_return/execute__tests__force_brillig_false_inliner_-9223372036854775808.snap new file mode 100644 index 00000000000..3d90eacc56b --- /dev/null +++ b/tooling/nargo_cli/tests/snapshots/execution_success/array_with_refs_return/execute__tests__force_brillig_false_inliner_-9223372036854775808.snap @@ -0,0 +1,52 @@ +--- +source: tooling/nargo_cli/tests/execute.rs +expression: artifact +--- +{ + "noir_version": "[noir_version]", + "hash": "[hash]", + "abi": { + "parameters": [], + "return_type": { + "abi_type": { + "kind": "array", + "length": 2, + "type": { + "kind": "integer", + "sign": "signed", + "width": 8 + } + }, + "visibility": "public" + }, + "error_types": { + "17843811134343075018": { + "error_kind": "string", + "string": "Stack too deep" + } + } + }, + "bytecode": [ + "func 0", + "current witness index : _1", + "private parameters indices : []", + "public parameters indices : []", + "return value indices : [_0, _1]", + "BRILLIG CALL func 0: inputs: [], outputs: [Array([Witness(0), Witness(1)])]", + "unconstrained func 0", + "[Const { destination: Direct(2), bit_size: Integer(U32), value: 1 }, Const { destination: Direct(1), bit_size: Integer(U32), value: 32838 }, Const { destination: Direct(0), bit_size: Integer(U32), value: 3 }, Const { destination: Relative(1), bit_size: Integer(U32), value: 0 }, Const { destination: Relative(2), bit_size: Integer(U32), value: 0 }, CalldataCopy { destination_address: Direct(32836), size_address: Relative(1), offset_address: Relative(2) }, Call { location: 18 }, Call { location: 19 }, BinaryIntOp { destination: Relative(2), op: Add, bit_size: U32, lhs: Relative(1), rhs: Direct(2) }, Const { destination: Relative(3), bit_size: Integer(U32), value: 32836 }, Const { destination: Relative(4), bit_size: Integer(U32), value: 2 }, Mov { destination: Direct(32771), source: Relative(2) }, Mov { destination: Direct(32772), source: Relative(3) }, Mov { destination: Direct(32773), source: Relative(4) }, Call { location: 59 }, Const { destination: Relative(2), bit_size: Integer(U32), value: 32836 }, Const { destination: Relative(3), bit_size: Integer(U32), value: 2 }, Stop { return_data: HeapVector { pointer: Relative(2), size: Relative(3) } }, Return, Call { location: 70 }, Const { destination: Relative(3), bit_size: Integer(U32), value: 4 }, Mov { destination: Relative(4), source: Direct(0) }, BinaryIntOp { destination: Direct(0), op: Add, bit_size: U32, lhs: Direct(0), rhs: Relative(3) }, Call { location: 76 }, Mov { destination: Direct(0), source: Relative(0) }, Mov { destination: Relative(2), source: Relative(5) }, Const { destination: Relative(3), bit_size: Integer(U32), value: 5 }, BinaryIntOp { destination: Relative(5), op: Add, bit_size: U32, lhs: Relative(2), rhs: Relative(3) }, Load { destination: Relative(4), source_pointer: Relative(5) }, Load { destination: Relative(2), source_pointer: Relative(4) }, JumpIf { condition: Relative(2), location: 45 }, Jump { location: 32 }, Const { destination: Relative(2), bit_size: Integer(U8), value: 2 }, Const { destination: Relative(3), bit_size: Integer(U8), value: 3 }, Mov { destination: Relative(4), source: Direct(1) }, Const { destination: Relative(5), bit_size: Integer(U32), value: 3 }, BinaryIntOp { destination: Direct(1), op: Add, bit_size: U32, lhs: Direct(1), rhs: Relative(5) }, IndirectConst { destination_pointer: Relative(4), bit_size: Integer(U32), value: 1 }, BinaryIntOp { destination: Relative(5), op: Add, bit_size: U32, lhs: Relative(4), rhs: Direct(2) }, Mov { destination: Relative(6), source: Relative(5) }, Store { destination_pointer: Relative(6), source: Relative(2) }, BinaryIntOp { destination: Relative(6), op: Add, bit_size: U32, lhs: Relative(6), rhs: Direct(2) }, Store { destination_pointer: Relative(6), source: Relative(3) }, Mov { destination: Relative(1), source: Relative(4) }, Jump { location: 58 }, Const { destination: Relative(2), bit_size: Integer(U8), value: 0 }, Const { destination: Relative(3), bit_size: Integer(U8), value: 1 }, Mov { destination: Relative(4), source: Direct(1) }, Const { destination: Relative(5), bit_size: Integer(U32), value: 3 }, BinaryIntOp { destination: Direct(1), op: Add, bit_size: U32, lhs: Direct(1), rhs: Relative(5) }, IndirectConst { destination_pointer: Relative(4), bit_size: Integer(U32), value: 1 }, BinaryIntOp { destination: Relative(5), op: Add, bit_size: U32, lhs: Relative(4), rhs: Direct(2) }, Mov { destination: Relative(6), source: Relative(5) }, Store { destination_pointer: Relative(6), source: Relative(2) }, BinaryIntOp { destination: Relative(6), op: Add, bit_size: U32, lhs: Relative(6), rhs: Direct(2) }, Store { destination_pointer: Relative(6), source: Relative(3) }, Mov { destination: Relative(1), source: Relative(4) }, Jump { location: 58 }, Return, BinaryIntOp { destination: Direct(32775), op: Add, bit_size: U32, lhs: Direct(32771), rhs: Direct(32773) }, Mov { destination: Direct(32776), source: Direct(32771) }, Mov { destination: Direct(32777), source: Direct(32772) }, BinaryIntOp { destination: Direct(32778), op: Equals, bit_size: U32, lhs: Direct(32776), rhs: Direct(32775) }, JumpIf { condition: Direct(32778), location: 69 }, Load { destination: Direct(32774), source_pointer: Direct(32776) }, Store { destination_pointer: Direct(32777), source: Direct(32774) }, BinaryIntOp { destination: Direct(32776), op: Add, bit_size: U32, lhs: Direct(32776), rhs: Direct(2) }, BinaryIntOp { destination: Direct(32777), op: Add, bit_size: U32, lhs: Direct(32777), rhs: Direct(2) }, Jump { location: 62 }, Return, Const { destination: Direct(32772), bit_size: Integer(U32), value: 30720 }, BinaryIntOp { destination: Direct(32771), op: LessThan, bit_size: U32, lhs: Direct(0), rhs: Direct(32772) }, JumpIf { condition: Direct(32771), location: 75 }, IndirectConst { destination_pointer: Direct(1), bit_size: Integer(U64), value: 17843811134343075018 }, Trap { revert_data: HeapVector { pointer: Direct(1), size: Direct(2) } }, Return, Call { location: 70 }, Mov { destination: Relative(1), source: Direct(1) }, BinaryIntOp { destination: Direct(1), op: Add, bit_size: U32, lhs: Direct(1), rhs: Direct(2) }, Const { destination: Relative(2), bit_size: Integer(U1), value: 1 }, Store { destination_pointer: Relative(1), source: Relative(2) }, Const { destination: Relative(2), bit_size: Integer(U8), value: 65 }, Const { destination: Relative(3), bit_size: Integer(U8), value: 66 }, Mov { destination: Relative(4), source: Direct(1) }, Const { destination: Relative(5), bit_size: Integer(U32), value: 3 }, BinaryIntOp { destination: Direct(1), op: Add, bit_size: U32, lhs: Direct(1), rhs: Relative(5) }, IndirectConst { destination_pointer: Relative(4), bit_size: Integer(U32), value: 1 }, BinaryIntOp { destination: Relative(5), op: Add, bit_size: U32, lhs: Relative(4), rhs: Direct(2) }, Mov { destination: Relative(6), source: Relative(5) }, Store { destination_pointer: Relative(6), source: Relative(2) }, BinaryIntOp { destination: Relative(6), op: Add, bit_size: U32, lhs: Relative(6), rhs: Direct(2) }, Store { destination_pointer: Relative(6), source: Relative(3) }, Const { destination: Relative(3), bit_size: Integer(U8), value: 87 }, Const { destination: Relative(5), bit_size: Integer(U8), value: 84 }, Const { destination: Relative(6), bit_size: Integer(U8), value: 71 }, Const { destination: Relative(7), bit_size: Integer(U8), value: 83 }, Mov { destination: Relative(8), source: Direct(1) }, Const { destination: Relative(9), bit_size: Integer(U32), value: 5 }, BinaryIntOp { destination: Direct(1), op: Add, bit_size: U32, lhs: Direct(1), rhs: Relative(9) }, IndirectConst { destination_pointer: Relative(8), bit_size: Integer(U32), value: 1 }, BinaryIntOp { destination: Relative(9), op: Add, bit_size: U32, lhs: Relative(8), rhs: Direct(2) }, Mov { destination: Relative(10), source: Relative(9) }, Store { destination_pointer: Relative(10), source: Relative(3) }, BinaryIntOp { destination: Relative(10), op: Add, bit_size: U32, lhs: Relative(10), rhs: Direct(2) }, Store { destination_pointer: Relative(10), source: Relative(5) }, BinaryIntOp { destination: Relative(10), op: Add, bit_size: U32, lhs: Relative(10), rhs: Direct(2) }, Store { destination_pointer: Relative(10), source: Relative(6) }, BinaryIntOp { destination: Relative(10), op: Add, bit_size: U32, lhs: Relative(10), rhs: Direct(2) }, Store { destination_pointer: Relative(10), source: Relative(7) }, Const { destination: Relative(5), bit_size: Integer(U8), value: 69 }, Const { destination: Relative(6), bit_size: Integer(U8), value: 76 }, Mov { destination: Relative(7), source: Direct(1) }, Const { destination: Relative(9), bit_size: Integer(U32), value: 5 }, BinaryIntOp { destination: Direct(1), op: Add, bit_size: U32, lhs: Direct(1), rhs: Relative(9) }, IndirectConst { destination_pointer: Relative(7), bit_size: Integer(U32), value: 1 }, BinaryIntOp { destination: Relative(9), op: Add, bit_size: U32, lhs: Relative(7), rhs: Direct(2) }, Mov { destination: Relative(10), source: Relative(9) }, Store { destination_pointer: Relative(10), source: Relative(2) }, BinaryIntOp { destination: Relative(10), op: Add, bit_size: U32, lhs: Relative(10), rhs: Direct(2) }, Store { destination_pointer: Relative(10), source: Relative(5) }, BinaryIntOp { destination: Relative(10), op: Add, bit_size: U32, lhs: Relative(10), rhs: Direct(2) }, Store { destination_pointer: Relative(10), source: Relative(6) }, BinaryIntOp { destination: Relative(10), op: Add, bit_size: U32, lhs: Relative(10), rhs: Direct(2) }, Store { destination_pointer: Relative(10), source: Relative(6) }, Mov { destination: Relative(2), source: Direct(1) }, BinaryIntOp { destination: Direct(1), op: Add, bit_size: U32, lhs: Direct(1), rhs: Direct(2) }, Const { destination: Relative(9), bit_size: Integer(U1), value: 0 }, Store { destination_pointer: Relative(2), source: Relative(9) }, Const { destination: Relative(9), bit_size: Integer(U8), value: 67 }, Const { destination: Relative(10), bit_size: Integer(U8), value: 68 }, Mov { destination: Relative(11), source: Direct(1) }, Const { destination: Relative(12), bit_size: Integer(U32), value: 3 }, BinaryIntOp { destination: Direct(1), op: Add, bit_size: U32, lhs: Direct(1), rhs: Relative(12) }, IndirectConst { destination_pointer: Relative(11), bit_size: Integer(U32), value: 1 }, BinaryIntOp { destination: Relative(12), op: Add, bit_size: U32, lhs: Relative(11), rhs: Direct(2) }, Mov { destination: Relative(13), source: Relative(12) }, Store { destination_pointer: Relative(13), source: Relative(9) }, BinaryIntOp { destination: Relative(13), op: Add, bit_size: U32, lhs: Relative(13), rhs: Direct(2) }, Store { destination_pointer: Relative(13), source: Relative(10) }, Const { destination: Relative(9), bit_size: Integer(U8), value: 80 }, Const { destination: Relative(12), bit_size: Integer(U8), value: 75 }, Const { destination: Relative(13), bit_size: Integer(U8), value: 72 }, Const { destination: Relative(14), bit_size: Integer(U8), value: 81 }, Mov { destination: Relative(15), source: Direct(1) }, Const { destination: Relative(16), bit_size: Integer(U32), value: 5 }, BinaryIntOp { destination: Direct(1), op: Add, bit_size: U32, lhs: Direct(1), rhs: Relative(16) }, IndirectConst { destination_pointer: Relative(15), bit_size: Integer(U32), value: 1 }, BinaryIntOp { destination: Relative(16), op: Add, bit_size: U32, lhs: Relative(15), rhs: Direct(2) }, Mov { destination: Relative(17), source: Relative(16) }, Store { destination_pointer: Relative(17), source: Relative(9) }, BinaryIntOp { destination: Relative(17), op: Add, bit_size: U32, lhs: Relative(17), rhs: Direct(2) }, Store { destination_pointer: Relative(17), source: Relative(12) }, BinaryIntOp { destination: Relative(17), op: Add, bit_size: U32, lhs: Relative(17), rhs: Direct(2) }, Store { destination_pointer: Relative(17), source: Relative(13) }, BinaryIntOp { destination: Relative(17), op: Add, bit_size: U32, lhs: Relative(17), rhs: Direct(2) }, Store { destination_pointer: Relative(17), source: Relative(14) }, Mov { destination: Relative(9), source: Direct(1) }, Const { destination: Relative(12), bit_size: Integer(U32), value: 5 }, BinaryIntOp { destination: Direct(1), op: Add, bit_size: U32, lhs: Direct(1), rhs: Relative(12) }, IndirectConst { destination_pointer: Relative(9), bit_size: Integer(U32), value: 1 }, BinaryIntOp { destination: Relative(12), op: Add, bit_size: U32, lhs: Relative(9), rhs: Direct(2) }, Mov { destination: Relative(13), source: Relative(12) }, Store { destination_pointer: Relative(13), source: Relative(6) }, BinaryIntOp { destination: Relative(13), op: Add, bit_size: U32, lhs: Relative(13), rhs: Direct(2) }, Store { destination_pointer: Relative(13), source: Relative(10) }, BinaryIntOp { destination: Relative(13), op: Add, bit_size: U32, lhs: Relative(13), rhs: Direct(2) }, Store { destination_pointer: Relative(13), source: Relative(3) }, BinaryIntOp { destination: Relative(13), op: Add, bit_size: U32, lhs: Relative(13), rhs: Direct(2) }, Store { destination_pointer: Relative(13), source: Relative(5) }, Mov { destination: Relative(3), source: Direct(1) }, Const { destination: Relative(5), bit_size: Integer(U32), value: 9 }, BinaryIntOp { destination: Direct(1), op: Add, bit_size: U32, lhs: Direct(1), rhs: Relative(5) }, IndirectConst { destination_pointer: Relative(3), bit_size: Integer(U32), value: 1 }, BinaryIntOp { destination: Relative(5), op: Add, bit_size: U32, lhs: Relative(3), rhs: Direct(2) }, Mov { destination: Relative(6), source: Relative(5) }, Store { destination_pointer: Relative(6), source: Relative(1) }, BinaryIntOp { destination: Relative(6), op: Add, bit_size: U32, lhs: Relative(6), rhs: Direct(2) }, Store { destination_pointer: Relative(6), source: Relative(4) }, BinaryIntOp { destination: Relative(6), op: Add, bit_size: U32, lhs: Relative(6), rhs: Direct(2) }, Store { destination_pointer: Relative(6), source: Relative(8) }, BinaryIntOp { destination: Relative(6), op: Add, bit_size: U32, lhs: Relative(6), rhs: Direct(2) }, Store { destination_pointer: Relative(6), source: Relative(7) }, BinaryIntOp { destination: Relative(6), op: Add, bit_size: U32, lhs: Relative(6), rhs: Direct(2) }, Store { destination_pointer: Relative(6), source: Relative(2) }, BinaryIntOp { destination: Relative(6), op: Add, bit_size: U32, lhs: Relative(6), rhs: Direct(2) }, Store { destination_pointer: Relative(6), source: Relative(11) }, BinaryIntOp { destination: Relative(6), op: Add, bit_size: U32, lhs: Relative(6), rhs: Direct(2) }, Store { destination_pointer: Relative(6), source: Relative(15) }, BinaryIntOp { destination: Relative(6), op: Add, bit_size: U32, lhs: Relative(6), rhs: Direct(2) }, Store { destination_pointer: Relative(6), source: Relative(9) }, Mov { destination: Relative(1), source: Relative(3) }, Return]" + ], + "debug_symbols": "ndXLbuJAEIXhd/HaC1e7r3mVKIocYiJLlkEOjDRCvPu0OT+TZJENGx+Mqa9boqp9ad7Ht/PH67TsD5/N0/OleVuneZ4+XufDbjhNh6V+e2m67eLq1drGmcIpeoVXBEVsnlyNpMiKcou+1vU1eoVXBEVUJEVWlFv4TmEKKb7W+RpRkRRZUW4ROoUpnKJXeIWUpGWTlk1aNmvZrGWzls3afNbmszaftfksJUvJUoqUIqVIKVKKlCKlSClSipQixbqONNKRPenJQEYykZnEMzzDMzzDMzzDMzzDMzzDc3gOz+E5PIfn8Byew3N4Dq/H6/HoHaN5jO4x2sfoH6OBjA4yWsjoIaOJjC4yj+fxPJ7H83gez+MFvIAX8AJewAt4AS/gBbyAF/EiXsSLeBEv4kW8iBfxIl7CS3gJL+ElvISX8JgEYxSMWTCGwZgGYxyMeTAGwpgIYySMmTCGwm5Tcb22zf2QeT2t47idMd9OnXoWHYd1XE7N03Ke57b5M8zn248+j8Nyy9Ow1qdd24zLe80K7qd53D5d26/q7vfS2nEU1975Xx4eqi+P1Odwr88PrR/SvT7kH/Uv9W7YTeuPc/y6Ses0vM0jt/vzsvv29PT3eH9yfw8c18NufD+v4yZ9vQzqP/4cShvLy3ae1JvUtSm8XLeV/wE=", + "file_map": { + "50": { + "source": "// Regression for issue #8786 (https://github.com/noir-lang/noir/issues/8786)\nunconstrained fn main() -> pub [i8; 2] {\n if (*func_5()[1].0) {\n [0, 1]\n } else {\n [2, 3]\n }\n}\nunconstrained fn func_5() -> [(&mut bool, str<2>, str<4>, str<4>); 2] {\n [((&mut true), \"AB\", \"WTGS\", \"AELL\"), ((&mut false), \"CD\", \"PKHQ\", \"LDWE\")]\n}\n", + "path": "" + } + }, + "names": [ + "main" + ], + "brillig_names": [ + "main" + ] +} diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/array_with_refs_return/execute__tests__force_brillig_false_inliner_0.snap b/tooling/nargo_cli/tests/snapshots/execution_success/array_with_refs_return/execute__tests__force_brillig_false_inliner_0.snap new file mode 100644 index 00000000000..56ed18dee66 --- /dev/null +++ b/tooling/nargo_cli/tests/snapshots/execution_success/array_with_refs_return/execute__tests__force_brillig_false_inliner_0.snap @@ -0,0 +1,52 @@ +--- +source: tooling/nargo_cli/tests/execute.rs +expression: artifact +--- +{ + "noir_version": "[noir_version]", + "hash": "[hash]", + "abi": { + "parameters": [], + "return_type": { + "abi_type": { + "kind": "array", + "length": 2, + "type": { + "kind": "integer", + "sign": "signed", + "width": 8 + } + }, + "visibility": "public" + }, + "error_types": { + "17843811134343075018": { + "error_kind": "string", + "string": "Stack too deep" + } + } + }, + "bytecode": [ + "func 0", + "current witness index : _1", + "private parameters indices : []", + "public parameters indices : []", + "return value indices : [_0, _1]", + "BRILLIG CALL func 0: inputs: [], outputs: [Array([Witness(0), Witness(1)])]", + "unconstrained func 0", + "[Const { destination: Direct(2), bit_size: Integer(U32), value: 1 }, Const { destination: Direct(1), bit_size: Integer(U32), value: 32838 }, Const { destination: Direct(0), bit_size: Integer(U32), value: 3 }, Const { destination: Relative(1), bit_size: Integer(U32), value: 0 }, Const { destination: Relative(2), bit_size: Integer(U32), value: 0 }, CalldataCopy { destination_address: Direct(32836), size_address: Relative(1), offset_address: Relative(2) }, Call { location: 18 }, Call { location: 19 }, BinaryIntOp { destination: Relative(2), op: Add, bit_size: U32, lhs: Relative(1), rhs: Direct(2) }, Const { destination: Relative(3), bit_size: Integer(U32), value: 32836 }, Const { destination: Relative(4), bit_size: Integer(U32), value: 2 }, Mov { destination: Direct(32771), source: Relative(2) }, Mov { destination: Direct(32772), source: Relative(3) }, Mov { destination: Direct(32773), source: Relative(4) }, Call { location: 33 }, Const { destination: Relative(2), bit_size: Integer(U32), value: 32836 }, Const { destination: Relative(3), bit_size: Integer(U32), value: 2 }, Stop { return_data: HeapVector { pointer: Relative(2), size: Relative(3) } }, Return, Call { location: 44 }, Const { destination: Relative(1), bit_size: Integer(U8), value: 2 }, Const { destination: Relative(2), bit_size: Integer(U8), value: 3 }, Mov { destination: Relative(3), source: Direct(1) }, Const { destination: Relative(4), bit_size: Integer(U32), value: 3 }, BinaryIntOp { destination: Direct(1), op: Add, bit_size: U32, lhs: Direct(1), rhs: Relative(4) }, IndirectConst { destination_pointer: Relative(3), bit_size: Integer(U32), value: 1 }, BinaryIntOp { destination: Relative(4), op: Add, bit_size: U32, lhs: Relative(3), rhs: Direct(2) }, Mov { destination: Relative(5), source: Relative(4) }, Store { destination_pointer: Relative(5), source: Relative(1) }, BinaryIntOp { destination: Relative(5), op: Add, bit_size: U32, lhs: Relative(5), rhs: Direct(2) }, Store { destination_pointer: Relative(5), source: Relative(2) }, Mov { destination: Relative(1), source: Relative(3) }, Return, BinaryIntOp { destination: Direct(32775), op: Add, bit_size: U32, lhs: Direct(32771), rhs: Direct(32773) }, Mov { destination: Direct(32776), source: Direct(32771) }, Mov { destination: Direct(32777), source: Direct(32772) }, BinaryIntOp { destination: Direct(32778), op: Equals, bit_size: U32, lhs: Direct(32776), rhs: Direct(32775) }, JumpIf { condition: Direct(32778), location: 43 }, Load { destination: Direct(32774), source_pointer: Direct(32776) }, Store { destination_pointer: Direct(32777), source: Direct(32774) }, BinaryIntOp { destination: Direct(32776), op: Add, bit_size: U32, lhs: Direct(32776), rhs: Direct(2) }, BinaryIntOp { destination: Direct(32777), op: Add, bit_size: U32, lhs: Direct(32777), rhs: Direct(2) }, Jump { location: 36 }, Return, Const { destination: Direct(32772), bit_size: Integer(U32), value: 30720 }, BinaryIntOp { destination: Direct(32771), op: LessThan, bit_size: U32, lhs: Direct(0), rhs: Direct(32772) }, JumpIf { condition: Direct(32771), location: 49 }, IndirectConst { destination_pointer: Direct(1), bit_size: Integer(U64), value: 17843811134343075018 }, Trap { revert_data: HeapVector { pointer: Direct(1), size: Direct(2) } }, Return]" + ], + "debug_symbols": "dZBBDoMgEEXvMmsWItjaXsUYgzo2JAQNhSaN4e4dpLZ20Q2PmeH/IX+FEftw67Sd5jtcmxV6p43Rt87Mg/J6ttRdoUhHSSdnUPKMMkNkyIwq45RxzqgzLhtEcomRwb6g8w4x+R820j8W5dB6uNpgDIOHMmF7dF+U3eiVo2nBAO1IJMNJG0y3yL7q4r+U19VbzOvTR16RvqVKDdr9ZBCTk9OqN/gup2CHw9Q/l32yZ7i4ecAxOExO3yApskYIJkXLgFOnkZLJSxvT5hc=", + "file_map": { + "50": { + "source": "// Regression for issue #8786 (https://github.com/noir-lang/noir/issues/8786)\nunconstrained fn main() -> pub [i8; 2] {\n if (*func_5()[1].0) {\n [0, 1]\n } else {\n [2, 3]\n }\n}\nunconstrained fn func_5() -> [(&mut bool, str<2>, str<4>, str<4>); 2] {\n [((&mut true), \"AB\", \"WTGS\", \"AELL\"), ((&mut false), \"CD\", \"PKHQ\", \"LDWE\")]\n}\n", + "path": "" + } + }, + "names": [ + "main" + ], + "brillig_names": [ + "main" + ] +} diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/array_with_refs_return/execute__tests__force_brillig_false_inliner_9223372036854775807.snap b/tooling/nargo_cli/tests/snapshots/execution_success/array_with_refs_return/execute__tests__force_brillig_false_inliner_9223372036854775807.snap new file mode 100644 index 00000000000..56ed18dee66 --- /dev/null +++ b/tooling/nargo_cli/tests/snapshots/execution_success/array_with_refs_return/execute__tests__force_brillig_false_inliner_9223372036854775807.snap @@ -0,0 +1,52 @@ +--- +source: tooling/nargo_cli/tests/execute.rs +expression: artifact +--- +{ + "noir_version": "[noir_version]", + "hash": "[hash]", + "abi": { + "parameters": [], + "return_type": { + "abi_type": { + "kind": "array", + "length": 2, + "type": { + "kind": "integer", + "sign": "signed", + "width": 8 + } + }, + "visibility": "public" + }, + "error_types": { + "17843811134343075018": { + "error_kind": "string", + "string": "Stack too deep" + } + } + }, + "bytecode": [ + "func 0", + "current witness index : _1", + "private parameters indices : []", + "public parameters indices : []", + "return value indices : [_0, _1]", + "BRILLIG CALL func 0: inputs: [], outputs: [Array([Witness(0), Witness(1)])]", + "unconstrained func 0", + "[Const { destination: Direct(2), bit_size: Integer(U32), value: 1 }, Const { destination: Direct(1), bit_size: Integer(U32), value: 32838 }, Const { destination: Direct(0), bit_size: Integer(U32), value: 3 }, Const { destination: Relative(1), bit_size: Integer(U32), value: 0 }, Const { destination: Relative(2), bit_size: Integer(U32), value: 0 }, CalldataCopy { destination_address: Direct(32836), size_address: Relative(1), offset_address: Relative(2) }, Call { location: 18 }, Call { location: 19 }, BinaryIntOp { destination: Relative(2), op: Add, bit_size: U32, lhs: Relative(1), rhs: Direct(2) }, Const { destination: Relative(3), bit_size: Integer(U32), value: 32836 }, Const { destination: Relative(4), bit_size: Integer(U32), value: 2 }, Mov { destination: Direct(32771), source: Relative(2) }, Mov { destination: Direct(32772), source: Relative(3) }, Mov { destination: Direct(32773), source: Relative(4) }, Call { location: 33 }, Const { destination: Relative(2), bit_size: Integer(U32), value: 32836 }, Const { destination: Relative(3), bit_size: Integer(U32), value: 2 }, Stop { return_data: HeapVector { pointer: Relative(2), size: Relative(3) } }, Return, Call { location: 44 }, Const { destination: Relative(1), bit_size: Integer(U8), value: 2 }, Const { destination: Relative(2), bit_size: Integer(U8), value: 3 }, Mov { destination: Relative(3), source: Direct(1) }, Const { destination: Relative(4), bit_size: Integer(U32), value: 3 }, BinaryIntOp { destination: Direct(1), op: Add, bit_size: U32, lhs: Direct(1), rhs: Relative(4) }, IndirectConst { destination_pointer: Relative(3), bit_size: Integer(U32), value: 1 }, BinaryIntOp { destination: Relative(4), op: Add, bit_size: U32, lhs: Relative(3), rhs: Direct(2) }, Mov { destination: Relative(5), source: Relative(4) }, Store { destination_pointer: Relative(5), source: Relative(1) }, BinaryIntOp { destination: Relative(5), op: Add, bit_size: U32, lhs: Relative(5), rhs: Direct(2) }, Store { destination_pointer: Relative(5), source: Relative(2) }, Mov { destination: Relative(1), source: Relative(3) }, Return, BinaryIntOp { destination: Direct(32775), op: Add, bit_size: U32, lhs: Direct(32771), rhs: Direct(32773) }, Mov { destination: Direct(32776), source: Direct(32771) }, Mov { destination: Direct(32777), source: Direct(32772) }, BinaryIntOp { destination: Direct(32778), op: Equals, bit_size: U32, lhs: Direct(32776), rhs: Direct(32775) }, JumpIf { condition: Direct(32778), location: 43 }, Load { destination: Direct(32774), source_pointer: Direct(32776) }, Store { destination_pointer: Direct(32777), source: Direct(32774) }, BinaryIntOp { destination: Direct(32776), op: Add, bit_size: U32, lhs: Direct(32776), rhs: Direct(2) }, BinaryIntOp { destination: Direct(32777), op: Add, bit_size: U32, lhs: Direct(32777), rhs: Direct(2) }, Jump { location: 36 }, Return, Const { destination: Direct(32772), bit_size: Integer(U32), value: 30720 }, BinaryIntOp { destination: Direct(32771), op: LessThan, bit_size: U32, lhs: Direct(0), rhs: Direct(32772) }, JumpIf { condition: Direct(32771), location: 49 }, IndirectConst { destination_pointer: Direct(1), bit_size: Integer(U64), value: 17843811134343075018 }, Trap { revert_data: HeapVector { pointer: Direct(1), size: Direct(2) } }, Return]" + ], + "debug_symbols": "dZBBDoMgEEXvMmsWItjaXsUYgzo2JAQNhSaN4e4dpLZ20Q2PmeH/IX+FEftw67Sd5jtcmxV6p43Rt87Mg/J6ttRdoUhHSSdnUPKMMkNkyIwq45RxzqgzLhtEcomRwb6g8w4x+R820j8W5dB6uNpgDIOHMmF7dF+U3eiVo2nBAO1IJMNJG0y3yL7q4r+U19VbzOvTR16RvqVKDdr9ZBCTk9OqN/gup2CHw9Q/l32yZ7i4ecAxOExO3yApskYIJkXLgFOnkZLJSxvT5hc=", + "file_map": { + "50": { + "source": "// Regression for issue #8786 (https://github.com/noir-lang/noir/issues/8786)\nunconstrained fn main() -> pub [i8; 2] {\n if (*func_5()[1].0) {\n [0, 1]\n } else {\n [2, 3]\n }\n}\nunconstrained fn func_5() -> [(&mut bool, str<2>, str<4>, str<4>); 2] {\n [((&mut true), \"AB\", \"WTGS\", \"AELL\"), ((&mut false), \"CD\", \"PKHQ\", \"LDWE\")]\n}\n", + "path": "" + } + }, + "names": [ + "main" + ], + "brillig_names": [ + "main" + ] +} diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/array_with_refs_return/execute__tests__force_brillig_true_inliner_-9223372036854775808.snap b/tooling/nargo_cli/tests/snapshots/execution_success/array_with_refs_return/execute__tests__force_brillig_true_inliner_-9223372036854775808.snap new file mode 100644 index 00000000000..3d90eacc56b --- /dev/null +++ b/tooling/nargo_cli/tests/snapshots/execution_success/array_with_refs_return/execute__tests__force_brillig_true_inliner_-9223372036854775808.snap @@ -0,0 +1,52 @@ +--- +source: tooling/nargo_cli/tests/execute.rs +expression: artifact +--- +{ + "noir_version": "[noir_version]", + "hash": "[hash]", + "abi": { + "parameters": [], + "return_type": { + "abi_type": { + "kind": "array", + "length": 2, + "type": { + "kind": "integer", + "sign": "signed", + "width": 8 + } + }, + "visibility": "public" + }, + "error_types": { + "17843811134343075018": { + "error_kind": "string", + "string": "Stack too deep" + } + } + }, + "bytecode": [ + "func 0", + "current witness index : _1", + "private parameters indices : []", + "public parameters indices : []", + "return value indices : [_0, _1]", + "BRILLIG CALL func 0: inputs: [], outputs: [Array([Witness(0), Witness(1)])]", + "unconstrained func 0", + "[Const { destination: Direct(2), bit_size: Integer(U32), value: 1 }, Const { destination: Direct(1), bit_size: Integer(U32), value: 32838 }, Const { destination: Direct(0), bit_size: Integer(U32), value: 3 }, Const { destination: Relative(1), bit_size: Integer(U32), value: 0 }, Const { destination: Relative(2), bit_size: Integer(U32), value: 0 }, CalldataCopy { destination_address: Direct(32836), size_address: Relative(1), offset_address: Relative(2) }, Call { location: 18 }, Call { location: 19 }, BinaryIntOp { destination: Relative(2), op: Add, bit_size: U32, lhs: Relative(1), rhs: Direct(2) }, Const { destination: Relative(3), bit_size: Integer(U32), value: 32836 }, Const { destination: Relative(4), bit_size: Integer(U32), value: 2 }, Mov { destination: Direct(32771), source: Relative(2) }, Mov { destination: Direct(32772), source: Relative(3) }, Mov { destination: Direct(32773), source: Relative(4) }, Call { location: 59 }, Const { destination: Relative(2), bit_size: Integer(U32), value: 32836 }, Const { destination: Relative(3), bit_size: Integer(U32), value: 2 }, Stop { return_data: HeapVector { pointer: Relative(2), size: Relative(3) } }, Return, Call { location: 70 }, Const { destination: Relative(3), bit_size: Integer(U32), value: 4 }, Mov { destination: Relative(4), source: Direct(0) }, BinaryIntOp { destination: Direct(0), op: Add, bit_size: U32, lhs: Direct(0), rhs: Relative(3) }, Call { location: 76 }, Mov { destination: Direct(0), source: Relative(0) }, Mov { destination: Relative(2), source: Relative(5) }, Const { destination: Relative(3), bit_size: Integer(U32), value: 5 }, BinaryIntOp { destination: Relative(5), op: Add, bit_size: U32, lhs: Relative(2), rhs: Relative(3) }, Load { destination: Relative(4), source_pointer: Relative(5) }, Load { destination: Relative(2), source_pointer: Relative(4) }, JumpIf { condition: Relative(2), location: 45 }, Jump { location: 32 }, Const { destination: Relative(2), bit_size: Integer(U8), value: 2 }, Const { destination: Relative(3), bit_size: Integer(U8), value: 3 }, Mov { destination: Relative(4), source: Direct(1) }, Const { destination: Relative(5), bit_size: Integer(U32), value: 3 }, BinaryIntOp { destination: Direct(1), op: Add, bit_size: U32, lhs: Direct(1), rhs: Relative(5) }, IndirectConst { destination_pointer: Relative(4), bit_size: Integer(U32), value: 1 }, BinaryIntOp { destination: Relative(5), op: Add, bit_size: U32, lhs: Relative(4), rhs: Direct(2) }, Mov { destination: Relative(6), source: Relative(5) }, Store { destination_pointer: Relative(6), source: Relative(2) }, BinaryIntOp { destination: Relative(6), op: Add, bit_size: U32, lhs: Relative(6), rhs: Direct(2) }, Store { destination_pointer: Relative(6), source: Relative(3) }, Mov { destination: Relative(1), source: Relative(4) }, Jump { location: 58 }, Const { destination: Relative(2), bit_size: Integer(U8), value: 0 }, Const { destination: Relative(3), bit_size: Integer(U8), value: 1 }, Mov { destination: Relative(4), source: Direct(1) }, Const { destination: Relative(5), bit_size: Integer(U32), value: 3 }, BinaryIntOp { destination: Direct(1), op: Add, bit_size: U32, lhs: Direct(1), rhs: Relative(5) }, IndirectConst { destination_pointer: Relative(4), bit_size: Integer(U32), value: 1 }, BinaryIntOp { destination: Relative(5), op: Add, bit_size: U32, lhs: Relative(4), rhs: Direct(2) }, Mov { destination: Relative(6), source: Relative(5) }, Store { destination_pointer: Relative(6), source: Relative(2) }, BinaryIntOp { destination: Relative(6), op: Add, bit_size: U32, lhs: Relative(6), rhs: Direct(2) }, Store { destination_pointer: Relative(6), source: Relative(3) }, Mov { destination: Relative(1), source: Relative(4) }, Jump { location: 58 }, Return, BinaryIntOp { destination: Direct(32775), op: Add, bit_size: U32, lhs: Direct(32771), rhs: Direct(32773) }, Mov { destination: Direct(32776), source: Direct(32771) }, Mov { destination: Direct(32777), source: Direct(32772) }, BinaryIntOp { destination: Direct(32778), op: Equals, bit_size: U32, lhs: Direct(32776), rhs: Direct(32775) }, JumpIf { condition: Direct(32778), location: 69 }, Load { destination: Direct(32774), source_pointer: Direct(32776) }, Store { destination_pointer: Direct(32777), source: Direct(32774) }, BinaryIntOp { destination: Direct(32776), op: Add, bit_size: U32, lhs: Direct(32776), rhs: Direct(2) }, BinaryIntOp { destination: Direct(32777), op: Add, bit_size: U32, lhs: Direct(32777), rhs: Direct(2) }, Jump { location: 62 }, Return, Const { destination: Direct(32772), bit_size: Integer(U32), value: 30720 }, BinaryIntOp { destination: Direct(32771), op: LessThan, bit_size: U32, lhs: Direct(0), rhs: Direct(32772) }, JumpIf { condition: Direct(32771), location: 75 }, IndirectConst { destination_pointer: Direct(1), bit_size: Integer(U64), value: 17843811134343075018 }, Trap { revert_data: HeapVector { pointer: Direct(1), size: Direct(2) } }, Return, Call { location: 70 }, Mov { destination: Relative(1), source: Direct(1) }, BinaryIntOp { destination: Direct(1), op: Add, bit_size: U32, lhs: Direct(1), rhs: Direct(2) }, Const { destination: Relative(2), bit_size: Integer(U1), value: 1 }, Store { destination_pointer: Relative(1), source: Relative(2) }, Const { destination: Relative(2), bit_size: Integer(U8), value: 65 }, Const { destination: Relative(3), bit_size: Integer(U8), value: 66 }, Mov { destination: Relative(4), source: Direct(1) }, Const { destination: Relative(5), bit_size: Integer(U32), value: 3 }, BinaryIntOp { destination: Direct(1), op: Add, bit_size: U32, lhs: Direct(1), rhs: Relative(5) }, IndirectConst { destination_pointer: Relative(4), bit_size: Integer(U32), value: 1 }, BinaryIntOp { destination: Relative(5), op: Add, bit_size: U32, lhs: Relative(4), rhs: Direct(2) }, Mov { destination: Relative(6), source: Relative(5) }, Store { destination_pointer: Relative(6), source: Relative(2) }, BinaryIntOp { destination: Relative(6), op: Add, bit_size: U32, lhs: Relative(6), rhs: Direct(2) }, Store { destination_pointer: Relative(6), source: Relative(3) }, Const { destination: Relative(3), bit_size: Integer(U8), value: 87 }, Const { destination: Relative(5), bit_size: Integer(U8), value: 84 }, Const { destination: Relative(6), bit_size: Integer(U8), value: 71 }, Const { destination: Relative(7), bit_size: Integer(U8), value: 83 }, Mov { destination: Relative(8), source: Direct(1) }, Const { destination: Relative(9), bit_size: Integer(U32), value: 5 }, BinaryIntOp { destination: Direct(1), op: Add, bit_size: U32, lhs: Direct(1), rhs: Relative(9) }, IndirectConst { destination_pointer: Relative(8), bit_size: Integer(U32), value: 1 }, BinaryIntOp { destination: Relative(9), op: Add, bit_size: U32, lhs: Relative(8), rhs: Direct(2) }, Mov { destination: Relative(10), source: Relative(9) }, Store { destination_pointer: Relative(10), source: Relative(3) }, BinaryIntOp { destination: Relative(10), op: Add, bit_size: U32, lhs: Relative(10), rhs: Direct(2) }, Store { destination_pointer: Relative(10), source: Relative(5) }, BinaryIntOp { destination: Relative(10), op: Add, bit_size: U32, lhs: Relative(10), rhs: Direct(2) }, Store { destination_pointer: Relative(10), source: Relative(6) }, BinaryIntOp { destination: Relative(10), op: Add, bit_size: U32, lhs: Relative(10), rhs: Direct(2) }, Store { destination_pointer: Relative(10), source: Relative(7) }, Const { destination: Relative(5), bit_size: Integer(U8), value: 69 }, Const { destination: Relative(6), bit_size: Integer(U8), value: 76 }, Mov { destination: Relative(7), source: Direct(1) }, Const { destination: Relative(9), bit_size: Integer(U32), value: 5 }, BinaryIntOp { destination: Direct(1), op: Add, bit_size: U32, lhs: Direct(1), rhs: Relative(9) }, IndirectConst { destination_pointer: Relative(7), bit_size: Integer(U32), value: 1 }, BinaryIntOp { destination: Relative(9), op: Add, bit_size: U32, lhs: Relative(7), rhs: Direct(2) }, Mov { destination: Relative(10), source: Relative(9) }, Store { destination_pointer: Relative(10), source: Relative(2) }, BinaryIntOp { destination: Relative(10), op: Add, bit_size: U32, lhs: Relative(10), rhs: Direct(2) }, Store { destination_pointer: Relative(10), source: Relative(5) }, BinaryIntOp { destination: Relative(10), op: Add, bit_size: U32, lhs: Relative(10), rhs: Direct(2) }, Store { destination_pointer: Relative(10), source: Relative(6) }, BinaryIntOp { destination: Relative(10), op: Add, bit_size: U32, lhs: Relative(10), rhs: Direct(2) }, Store { destination_pointer: Relative(10), source: Relative(6) }, Mov { destination: Relative(2), source: Direct(1) }, BinaryIntOp { destination: Direct(1), op: Add, bit_size: U32, lhs: Direct(1), rhs: Direct(2) }, Const { destination: Relative(9), bit_size: Integer(U1), value: 0 }, Store { destination_pointer: Relative(2), source: Relative(9) }, Const { destination: Relative(9), bit_size: Integer(U8), value: 67 }, Const { destination: Relative(10), bit_size: Integer(U8), value: 68 }, Mov { destination: Relative(11), source: Direct(1) }, Const { destination: Relative(12), bit_size: Integer(U32), value: 3 }, BinaryIntOp { destination: Direct(1), op: Add, bit_size: U32, lhs: Direct(1), rhs: Relative(12) }, IndirectConst { destination_pointer: Relative(11), bit_size: Integer(U32), value: 1 }, BinaryIntOp { destination: Relative(12), op: Add, bit_size: U32, lhs: Relative(11), rhs: Direct(2) }, Mov { destination: Relative(13), source: Relative(12) }, Store { destination_pointer: Relative(13), source: Relative(9) }, BinaryIntOp { destination: Relative(13), op: Add, bit_size: U32, lhs: Relative(13), rhs: Direct(2) }, Store { destination_pointer: Relative(13), source: Relative(10) }, Const { destination: Relative(9), bit_size: Integer(U8), value: 80 }, Const { destination: Relative(12), bit_size: Integer(U8), value: 75 }, Const { destination: Relative(13), bit_size: Integer(U8), value: 72 }, Const { destination: Relative(14), bit_size: Integer(U8), value: 81 }, Mov { destination: Relative(15), source: Direct(1) }, Const { destination: Relative(16), bit_size: Integer(U32), value: 5 }, BinaryIntOp { destination: Direct(1), op: Add, bit_size: U32, lhs: Direct(1), rhs: Relative(16) }, IndirectConst { destination_pointer: Relative(15), bit_size: Integer(U32), value: 1 }, BinaryIntOp { destination: Relative(16), op: Add, bit_size: U32, lhs: Relative(15), rhs: Direct(2) }, Mov { destination: Relative(17), source: Relative(16) }, Store { destination_pointer: Relative(17), source: Relative(9) }, BinaryIntOp { destination: Relative(17), op: Add, bit_size: U32, lhs: Relative(17), rhs: Direct(2) }, Store { destination_pointer: Relative(17), source: Relative(12) }, BinaryIntOp { destination: Relative(17), op: Add, bit_size: U32, lhs: Relative(17), rhs: Direct(2) }, Store { destination_pointer: Relative(17), source: Relative(13) }, BinaryIntOp { destination: Relative(17), op: Add, bit_size: U32, lhs: Relative(17), rhs: Direct(2) }, Store { destination_pointer: Relative(17), source: Relative(14) }, Mov { destination: Relative(9), source: Direct(1) }, Const { destination: Relative(12), bit_size: Integer(U32), value: 5 }, BinaryIntOp { destination: Direct(1), op: Add, bit_size: U32, lhs: Direct(1), rhs: Relative(12) }, IndirectConst { destination_pointer: Relative(9), bit_size: Integer(U32), value: 1 }, BinaryIntOp { destination: Relative(12), op: Add, bit_size: U32, lhs: Relative(9), rhs: Direct(2) }, Mov { destination: Relative(13), source: Relative(12) }, Store { destination_pointer: Relative(13), source: Relative(6) }, BinaryIntOp { destination: Relative(13), op: Add, bit_size: U32, lhs: Relative(13), rhs: Direct(2) }, Store { destination_pointer: Relative(13), source: Relative(10) }, BinaryIntOp { destination: Relative(13), op: Add, bit_size: U32, lhs: Relative(13), rhs: Direct(2) }, Store { destination_pointer: Relative(13), source: Relative(3) }, BinaryIntOp { destination: Relative(13), op: Add, bit_size: U32, lhs: Relative(13), rhs: Direct(2) }, Store { destination_pointer: Relative(13), source: Relative(5) }, Mov { destination: Relative(3), source: Direct(1) }, Const { destination: Relative(5), bit_size: Integer(U32), value: 9 }, BinaryIntOp { destination: Direct(1), op: Add, bit_size: U32, lhs: Direct(1), rhs: Relative(5) }, IndirectConst { destination_pointer: Relative(3), bit_size: Integer(U32), value: 1 }, BinaryIntOp { destination: Relative(5), op: Add, bit_size: U32, lhs: Relative(3), rhs: Direct(2) }, Mov { destination: Relative(6), source: Relative(5) }, Store { destination_pointer: Relative(6), source: Relative(1) }, BinaryIntOp { destination: Relative(6), op: Add, bit_size: U32, lhs: Relative(6), rhs: Direct(2) }, Store { destination_pointer: Relative(6), source: Relative(4) }, BinaryIntOp { destination: Relative(6), op: Add, bit_size: U32, lhs: Relative(6), rhs: Direct(2) }, Store { destination_pointer: Relative(6), source: Relative(8) }, BinaryIntOp { destination: Relative(6), op: Add, bit_size: U32, lhs: Relative(6), rhs: Direct(2) }, Store { destination_pointer: Relative(6), source: Relative(7) }, BinaryIntOp { destination: Relative(6), op: Add, bit_size: U32, lhs: Relative(6), rhs: Direct(2) }, Store { destination_pointer: Relative(6), source: Relative(2) }, BinaryIntOp { destination: Relative(6), op: Add, bit_size: U32, lhs: Relative(6), rhs: Direct(2) }, Store { destination_pointer: Relative(6), source: Relative(11) }, BinaryIntOp { destination: Relative(6), op: Add, bit_size: U32, lhs: Relative(6), rhs: Direct(2) }, Store { destination_pointer: Relative(6), source: Relative(15) }, BinaryIntOp { destination: Relative(6), op: Add, bit_size: U32, lhs: Relative(6), rhs: Direct(2) }, Store { destination_pointer: Relative(6), source: Relative(9) }, Mov { destination: Relative(1), source: Relative(3) }, Return]" + ], + "debug_symbols": "ndXLbuJAEIXhd/HaC1e7r3mVKIocYiJLlkEOjDRCvPu0OT+TZJENGx+Mqa9boqp9ad7Ht/PH67TsD5/N0/OleVuneZ4+XufDbjhNh6V+e2m67eLq1drGmcIpeoVXBEVsnlyNpMiKcou+1vU1eoVXBEVUJEVWlFv4TmEKKb7W+RpRkRRZUW4ROoUpnKJXeIWUpGWTlk1aNmvZrGWzls3afNbmszaftfksJUvJUoqUIqVIKVKKlCKlSClSipQixbqONNKRPenJQEYykZnEMzzDMzzDMzzDMzzDMzzDc3gOz+E5PIfn8Byew3N4Dq/H6/HoHaN5jO4x2sfoH6OBjA4yWsjoIaOJjC4yj+fxPJ7H83gez+MFvIAX8AJewAt4AS/gBbyAF/EiXsSLeBEv4kW8iBfxIl7CS3gJL+ElvISX8JgEYxSMWTCGwZgGYxyMeTAGwpgIYySMmTCGwm5Tcb22zf2QeT2t47idMd9OnXoWHYd1XE7N03Ke57b5M8zn248+j8Nyy9Ow1qdd24zLe80K7qd53D5d26/q7vfS2nEU1975Xx4eqi+P1Odwr88PrR/SvT7kH/Uv9W7YTeuPc/y6Ses0vM0jt/vzsvv29PT3eH9yfw8c18NufD+v4yZ9vQzqP/4cShvLy3ae1JvUtSm8XLeV/wE=", + "file_map": { + "50": { + "source": "// Regression for issue #8786 (https://github.com/noir-lang/noir/issues/8786)\nunconstrained fn main() -> pub [i8; 2] {\n if (*func_5()[1].0) {\n [0, 1]\n } else {\n [2, 3]\n }\n}\nunconstrained fn func_5() -> [(&mut bool, str<2>, str<4>, str<4>); 2] {\n [((&mut true), \"AB\", \"WTGS\", \"AELL\"), ((&mut false), \"CD\", \"PKHQ\", \"LDWE\")]\n}\n", + "path": "" + } + }, + "names": [ + "main" + ], + "brillig_names": [ + "main" + ] +} diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/array_with_refs_return/execute__tests__force_brillig_true_inliner_0.snap b/tooling/nargo_cli/tests/snapshots/execution_success/array_with_refs_return/execute__tests__force_brillig_true_inliner_0.snap new file mode 100644 index 00000000000..56ed18dee66 --- /dev/null +++ b/tooling/nargo_cli/tests/snapshots/execution_success/array_with_refs_return/execute__tests__force_brillig_true_inliner_0.snap @@ -0,0 +1,52 @@ +--- +source: tooling/nargo_cli/tests/execute.rs +expression: artifact +--- +{ + "noir_version": "[noir_version]", + "hash": "[hash]", + "abi": { + "parameters": [], + "return_type": { + "abi_type": { + "kind": "array", + "length": 2, + "type": { + "kind": "integer", + "sign": "signed", + "width": 8 + } + }, + "visibility": "public" + }, + "error_types": { + "17843811134343075018": { + "error_kind": "string", + "string": "Stack too deep" + } + } + }, + "bytecode": [ + "func 0", + "current witness index : _1", + "private parameters indices : []", + "public parameters indices : []", + "return value indices : [_0, _1]", + "BRILLIG CALL func 0: inputs: [], outputs: [Array([Witness(0), Witness(1)])]", + "unconstrained func 0", + "[Const { destination: Direct(2), bit_size: Integer(U32), value: 1 }, Const { destination: Direct(1), bit_size: Integer(U32), value: 32838 }, Const { destination: Direct(0), bit_size: Integer(U32), value: 3 }, Const { destination: Relative(1), bit_size: Integer(U32), value: 0 }, Const { destination: Relative(2), bit_size: Integer(U32), value: 0 }, CalldataCopy { destination_address: Direct(32836), size_address: Relative(1), offset_address: Relative(2) }, Call { location: 18 }, Call { location: 19 }, BinaryIntOp { destination: Relative(2), op: Add, bit_size: U32, lhs: Relative(1), rhs: Direct(2) }, Const { destination: Relative(3), bit_size: Integer(U32), value: 32836 }, Const { destination: Relative(4), bit_size: Integer(U32), value: 2 }, Mov { destination: Direct(32771), source: Relative(2) }, Mov { destination: Direct(32772), source: Relative(3) }, Mov { destination: Direct(32773), source: Relative(4) }, Call { location: 33 }, Const { destination: Relative(2), bit_size: Integer(U32), value: 32836 }, Const { destination: Relative(3), bit_size: Integer(U32), value: 2 }, Stop { return_data: HeapVector { pointer: Relative(2), size: Relative(3) } }, Return, Call { location: 44 }, Const { destination: Relative(1), bit_size: Integer(U8), value: 2 }, Const { destination: Relative(2), bit_size: Integer(U8), value: 3 }, Mov { destination: Relative(3), source: Direct(1) }, Const { destination: Relative(4), bit_size: Integer(U32), value: 3 }, BinaryIntOp { destination: Direct(1), op: Add, bit_size: U32, lhs: Direct(1), rhs: Relative(4) }, IndirectConst { destination_pointer: Relative(3), bit_size: Integer(U32), value: 1 }, BinaryIntOp { destination: Relative(4), op: Add, bit_size: U32, lhs: Relative(3), rhs: Direct(2) }, Mov { destination: Relative(5), source: Relative(4) }, Store { destination_pointer: Relative(5), source: Relative(1) }, BinaryIntOp { destination: Relative(5), op: Add, bit_size: U32, lhs: Relative(5), rhs: Direct(2) }, Store { destination_pointer: Relative(5), source: Relative(2) }, Mov { destination: Relative(1), source: Relative(3) }, Return, BinaryIntOp { destination: Direct(32775), op: Add, bit_size: U32, lhs: Direct(32771), rhs: Direct(32773) }, Mov { destination: Direct(32776), source: Direct(32771) }, Mov { destination: Direct(32777), source: Direct(32772) }, BinaryIntOp { destination: Direct(32778), op: Equals, bit_size: U32, lhs: Direct(32776), rhs: Direct(32775) }, JumpIf { condition: Direct(32778), location: 43 }, Load { destination: Direct(32774), source_pointer: Direct(32776) }, Store { destination_pointer: Direct(32777), source: Direct(32774) }, BinaryIntOp { destination: Direct(32776), op: Add, bit_size: U32, lhs: Direct(32776), rhs: Direct(2) }, BinaryIntOp { destination: Direct(32777), op: Add, bit_size: U32, lhs: Direct(32777), rhs: Direct(2) }, Jump { location: 36 }, Return, Const { destination: Direct(32772), bit_size: Integer(U32), value: 30720 }, BinaryIntOp { destination: Direct(32771), op: LessThan, bit_size: U32, lhs: Direct(0), rhs: Direct(32772) }, JumpIf { condition: Direct(32771), location: 49 }, IndirectConst { destination_pointer: Direct(1), bit_size: Integer(U64), value: 17843811134343075018 }, Trap { revert_data: HeapVector { pointer: Direct(1), size: Direct(2) } }, Return]" + ], + "debug_symbols": "dZBBDoMgEEXvMmsWItjaXsUYgzo2JAQNhSaN4e4dpLZ20Q2PmeH/IX+FEftw67Sd5jtcmxV6p43Rt87Mg/J6ttRdoUhHSSdnUPKMMkNkyIwq45RxzqgzLhtEcomRwb6g8w4x+R820j8W5dB6uNpgDIOHMmF7dF+U3eiVo2nBAO1IJMNJG0y3yL7q4r+U19VbzOvTR16RvqVKDdr9ZBCTk9OqN/gup2CHw9Q/l32yZ7i4ecAxOExO3yApskYIJkXLgFOnkZLJSxvT5hc=", + "file_map": { + "50": { + "source": "// Regression for issue #8786 (https://github.com/noir-lang/noir/issues/8786)\nunconstrained fn main() -> pub [i8; 2] {\n if (*func_5()[1].0) {\n [0, 1]\n } else {\n [2, 3]\n }\n}\nunconstrained fn func_5() -> [(&mut bool, str<2>, str<4>, str<4>); 2] {\n [((&mut true), \"AB\", \"WTGS\", \"AELL\"), ((&mut false), \"CD\", \"PKHQ\", \"LDWE\")]\n}\n", + "path": "" + } + }, + "names": [ + "main" + ], + "brillig_names": [ + "main" + ] +} diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/array_with_refs_return/execute__tests__force_brillig_true_inliner_9223372036854775807.snap b/tooling/nargo_cli/tests/snapshots/execution_success/array_with_refs_return/execute__tests__force_brillig_true_inliner_9223372036854775807.snap new file mode 100644 index 00000000000..56ed18dee66 --- /dev/null +++ b/tooling/nargo_cli/tests/snapshots/execution_success/array_with_refs_return/execute__tests__force_brillig_true_inliner_9223372036854775807.snap @@ -0,0 +1,52 @@ +--- +source: tooling/nargo_cli/tests/execute.rs +expression: artifact +--- +{ + "noir_version": "[noir_version]", + "hash": "[hash]", + "abi": { + "parameters": [], + "return_type": { + "abi_type": { + "kind": "array", + "length": 2, + "type": { + "kind": "integer", + "sign": "signed", + "width": 8 + } + }, + "visibility": "public" + }, + "error_types": { + "17843811134343075018": { + "error_kind": "string", + "string": "Stack too deep" + } + } + }, + "bytecode": [ + "func 0", + "current witness index : _1", + "private parameters indices : []", + "public parameters indices : []", + "return value indices : [_0, _1]", + "BRILLIG CALL func 0: inputs: [], outputs: [Array([Witness(0), Witness(1)])]", + "unconstrained func 0", + "[Const { destination: Direct(2), bit_size: Integer(U32), value: 1 }, Const { destination: Direct(1), bit_size: Integer(U32), value: 32838 }, Const { destination: Direct(0), bit_size: Integer(U32), value: 3 }, Const { destination: Relative(1), bit_size: Integer(U32), value: 0 }, Const { destination: Relative(2), bit_size: Integer(U32), value: 0 }, CalldataCopy { destination_address: Direct(32836), size_address: Relative(1), offset_address: Relative(2) }, Call { location: 18 }, Call { location: 19 }, BinaryIntOp { destination: Relative(2), op: Add, bit_size: U32, lhs: Relative(1), rhs: Direct(2) }, Const { destination: Relative(3), bit_size: Integer(U32), value: 32836 }, Const { destination: Relative(4), bit_size: Integer(U32), value: 2 }, Mov { destination: Direct(32771), source: Relative(2) }, Mov { destination: Direct(32772), source: Relative(3) }, Mov { destination: Direct(32773), source: Relative(4) }, Call { location: 33 }, Const { destination: Relative(2), bit_size: Integer(U32), value: 32836 }, Const { destination: Relative(3), bit_size: Integer(U32), value: 2 }, Stop { return_data: HeapVector { pointer: Relative(2), size: Relative(3) } }, Return, Call { location: 44 }, Const { destination: Relative(1), bit_size: Integer(U8), value: 2 }, Const { destination: Relative(2), bit_size: Integer(U8), value: 3 }, Mov { destination: Relative(3), source: Direct(1) }, Const { destination: Relative(4), bit_size: Integer(U32), value: 3 }, BinaryIntOp { destination: Direct(1), op: Add, bit_size: U32, lhs: Direct(1), rhs: Relative(4) }, IndirectConst { destination_pointer: Relative(3), bit_size: Integer(U32), value: 1 }, BinaryIntOp { destination: Relative(4), op: Add, bit_size: U32, lhs: Relative(3), rhs: Direct(2) }, Mov { destination: Relative(5), source: Relative(4) }, Store { destination_pointer: Relative(5), source: Relative(1) }, BinaryIntOp { destination: Relative(5), op: Add, bit_size: U32, lhs: Relative(5), rhs: Direct(2) }, Store { destination_pointer: Relative(5), source: Relative(2) }, Mov { destination: Relative(1), source: Relative(3) }, Return, BinaryIntOp { destination: Direct(32775), op: Add, bit_size: U32, lhs: Direct(32771), rhs: Direct(32773) }, Mov { destination: Direct(32776), source: Direct(32771) }, Mov { destination: Direct(32777), source: Direct(32772) }, BinaryIntOp { destination: Direct(32778), op: Equals, bit_size: U32, lhs: Direct(32776), rhs: Direct(32775) }, JumpIf { condition: Direct(32778), location: 43 }, Load { destination: Direct(32774), source_pointer: Direct(32776) }, Store { destination_pointer: Direct(32777), source: Direct(32774) }, BinaryIntOp { destination: Direct(32776), op: Add, bit_size: U32, lhs: Direct(32776), rhs: Direct(2) }, BinaryIntOp { destination: Direct(32777), op: Add, bit_size: U32, lhs: Direct(32777), rhs: Direct(2) }, Jump { location: 36 }, Return, Const { destination: Direct(32772), bit_size: Integer(U32), value: 30720 }, BinaryIntOp { destination: Direct(32771), op: LessThan, bit_size: U32, lhs: Direct(0), rhs: Direct(32772) }, JumpIf { condition: Direct(32771), location: 49 }, IndirectConst { destination_pointer: Direct(1), bit_size: Integer(U64), value: 17843811134343075018 }, Trap { revert_data: HeapVector { pointer: Direct(1), size: Direct(2) } }, Return]" + ], + "debug_symbols": "dZBBDoMgEEXvMmsWItjaXsUYgzo2JAQNhSaN4e4dpLZ20Q2PmeH/IX+FEftw67Sd5jtcmxV6p43Rt87Mg/J6ttRdoUhHSSdnUPKMMkNkyIwq45RxzqgzLhtEcomRwb6g8w4x+R820j8W5dB6uNpgDIOHMmF7dF+U3eiVo2nBAO1IJMNJG0y3yL7q4r+U19VbzOvTR16RvqVKDdr9ZBCTk9OqN/gup2CHw9Q/l32yZ7i4ecAxOExO3yApskYIJkXLgFOnkZLJSxvT5hc=", + "file_map": { + "50": { + "source": "// Regression for issue #8786 (https://github.com/noir-lang/noir/issues/8786)\nunconstrained fn main() -> pub [i8; 2] {\n if (*func_5()[1].0) {\n [0, 1]\n } else {\n [2, 3]\n }\n}\nunconstrained fn func_5() -> [(&mut bool, str<2>, str<4>, str<4>); 2] {\n [((&mut true), \"AB\", \"WTGS\", \"AELL\"), ((&mut false), \"CD\", \"PKHQ\", \"LDWE\")]\n}\n", + "path": "" + } + }, + "names": [ + "main" + ], + "brillig_names": [ + "main" + ] +} diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/array_with_refs_return/execute__tests__stdout.snap b/tooling/nargo_cli/tests/snapshots/execution_success/array_with_refs_return/execute__tests__stdout.snap new file mode 100644 index 00000000000..b42c5749a80 --- /dev/null +++ b/tooling/nargo_cli/tests/snapshots/execution_success/array_with_refs_return/execute__tests__stdout.snap @@ -0,0 +1,5 @@ +--- +source: tooling/nargo_cli/tests/execute.rs +expression: stdout +--- +[array_with_refs_return] Circuit output: Vec([Field(2), Field(3)])