diff --git a/codegen/masm/src/codegen/emitter.rs b/codegen/masm/src/codegen/emitter.rs index 52aab1b22..cb3570d3d 100644 --- a/codegen/masm/src/codegen/emitter.rs +++ b/codegen/masm/src/codegen/emitter.rs @@ -204,7 +204,12 @@ impl<'b, 'f: 'b> BlockEmitter<'b, 'f> { // handled separately within the specific handlers for those instructions let args = self.function.f.dfg.inst_args(inst_info.inst); self.schedule_operands(args, inst_info.plain_arguments()).unwrap_or_else(|err| { - panic!("failed to schedule operands for {}: {err:?}", inst_info.inst) + panic!( + "failed to schedule operands: {:?} \n for inst:\n {}\n {:?}\n with error: {err:?}", + args, + inst_info.inst, + self.function.f.dfg.inst(inst_info.inst), + ) }); match self.function.f.dfg.inst(inst_info.inst) { @@ -1000,7 +1005,16 @@ impl<'b, 'f: 'b> BlockEmitter<'b, 'f> { // No loops involved (None, None) => { assert!(is_first_visit); - assert_eq!(self.controlling_loop, None); + assert_eq!( + self.controlling_loop, + None, + "unexpected controlling loop: {:?}, parent: {:?}", + self.function.loops.loop_header(self.controlling_loop.unwrap()), + self.function + .loops + .loop_parent(self.controlling_loop.unwrap()) + .map(|l| self.function.loops.loop_header(l)) + ); None } // Entering a top-level loop, set the controlling loop diff --git a/frontend-wasm/src/code_translator/mod.rs b/frontend-wasm/src/code_translator/mod.rs index 1446bac72..294666ac0 100644 --- a/frontend-wasm/src/code_translator/mod.rs +++ b/frontend-wasm/src/code_translator/mod.rs @@ -141,8 +141,14 @@ pub fn translate_operator( } /******************************* Memory management *********************************/ Operator::MemoryGrow { .. } => { - let arg = state.pop1_casted(U32, builder, span); - state.push1(builder.ins().mem_grow(arg, span)); + // let arg = state.pop1_casted(U32, builder, span); + // state.push1(builder.ins().mem_grow(arg, span)); + // TODO: temporary workaround until we have this instruction + // properly implemented in codegen Wasm `memory.grow` instruction is + // expected to return -1 if the memory cannot grow and the old mem + // page count if it can grow. + // Return total Miden memory size + state.push1(builder.ins().i32(mem_total_pages(), span)); } Operator::MemorySize { .. } => { // Return total Miden memory size diff --git a/frontend-wasm/src/code_translator/tests.rs b/frontend-wasm/src/code_translator/tests.rs index 2be96b954..72fe0cae5 100644 --- a/frontend-wasm/src/code_translator/tests.rs +++ b/frontend-wasm/src/code_translator/tests.rs @@ -54,8 +54,7 @@ fn memory_grow() { "#, expect![[r#" (let (v0 i32) (const.i32 1)) - (let (v1 u32) (cast v0)) - (let (v2 i32) (memory.grow v1)) + (let (v1 i32) (const.i32 1048575)) "#]], ) } diff --git a/tests/integration/expected/abi_transform_tx_kernel_get_inputs.hir b/tests/integration/expected/abi_transform_tx_kernel_get_inputs.hir index cc895102a..42648de1f 100644 --- a/tests/integration/expected/abi_transform_tx_kernel_get_inputs.hir +++ b/tests/integration/expected/abi_transform_tx_kernel_get_inputs.hir @@ -167,50 +167,49 @@ (let (v20 u32) (cast v18)) (let (v21 u32) (shr.wrapping v19 v20)) (let (v22 i32) (cast v21)) - (let (v23 u32) (cast v22)) - (let (v24 i32) (memory.grow v23)) - (let (v25 i32) (const.i32 -1)) - (let (v26 i1) (neq v24 v25)) - (let (v27 i32) (cast v26)) - (let (v28 i1) (neq v27 0)) - (condbr v28 (block 3) (block 4))) + (let (v23 i32) (const.i32 1048575)) + (let (v24 i32) (const.i32 -1)) + (let (v25 i1) (neq v23 v24)) + (let (v26 i32) (cast v25)) + (let (v27 i1) (neq v26 0)) + (condbr v27 (block 3) (block 4))) (block 1 (ret)) - (block 2 (param v45 i32) (param v46 i32) (param v50 i32) - (let (v47 u32) (cast v45)) - (let (v48 u32) (add.checked v47 4)) - (let (v49 (ptr i32)) (inttoptr v48)) - (store v49 v46) - (let (v51 u32) (cast v45)) - (let (v52 (ptr i32)) (inttoptr v51)) - (store v52 v50) + (block 2 (param v44 i32) (param v45 i32) (param v49 i32) + (let (v46 u32) (cast v44)) + (let (v47 u32) (add.checked v46 4)) + (let (v48 (ptr i32)) (inttoptr v47)) + (store v48 v45) + (let (v50 u32) (cast v44)) + (let (v51 (ptr i32)) (inttoptr v50)) + (store v51 v49) (br (block 1))) (block 3 - (let (v31 i32) (const.i32 16)) - (let (v32 i32) (shl.wrapping v24 v31)) - (let (v33 i64) (const.i64 0)) - (let (v34 u32) (cast v32)) - (let (v35 u32) (add.checked v34 4)) - (let (v36 (ptr i64)) (inttoptr v35)) - (store v36 v33) - (let (v37 i32) (const.i32 -65536)) - (let (v38 i32) (band v17 v37)) - (let (v39 i32) (add.wrapping v32 v38)) - (let (v40 i32) (const.i32 2)) - (let (v41 i32) (bor v39 v40)) - (let (v42 u32) (cast v32)) - (let (v43 (ptr i32)) (inttoptr v42)) - (store v43 v41) - (let (v44 i32) (const.i32 0)) - (br (block 2 v0 v32 v44))) + (let (v30 i32) (const.i32 16)) + (let (v31 i32) (shl.wrapping v23 v30)) + (let (v32 i64) (const.i64 0)) + (let (v33 u32) (cast v31)) + (let (v34 u32) (add.checked v33 4)) + (let (v35 (ptr i64)) (inttoptr v34)) + (store v35 v32) + (let (v36 i32) (const.i32 -65536)) + (let (v37 i32) (band v17 v36)) + (let (v38 i32) (add.wrapping v31 v37)) + (let (v39 i32) (const.i32 2)) + (let (v40 i32) (bor v38 v39)) + (let (v41 u32) (cast v31)) + (let (v42 (ptr i32)) (inttoptr v41)) + (store v42 v40) + (let (v43 i32) (const.i32 0)) + (br (block 2 v0 v31 v43))) (block 4 - (let (v29 i32) (const.i32 1)) - (let (v30 i32) (const.i32 0)) - (br (block 2 v0 v30 v29))) + (let (v28 i32) (const.i32 1)) + (let (v29 i32) (const.i32 0)) + (br (block 2 v0 v29 v28))) ) (func (export #wee_alloc::alloc_first_fit) diff --git a/tests/integration/expected/components/add_wasm_component.hir b/tests/integration/expected/components/add_wasm_component.hir index 55014a7ed..85763daa0 100644 --- a/tests/integration/expected/components/add_wasm_component.hir +++ b/tests/integration/expected/components/add_wasm_component.hir @@ -489,12 +489,12 @@ (block 1 (param v3 i32) (ret v3)) - (block 2 (param v87 i32) (param v91 i32) - (let (v88 i32) (const.i32 16)) - (let (v89 i32) (add.wrapping v87 v88)) - (let (v90 (ptr i32)) (global.symbol #__stack_pointer)) - (store v90 v89) - (br (block 1 v91))) + (block 2 (param v86 i32) (param v90 i32) + (let (v87 i32) (const.i32 16)) + (let (v88 i32) (add.wrapping v86 v87)) + (let (v89 (ptr i32)) (global.symbol #__stack_pointer)) + (store v89 v88) + (br (block 1 v90))) (block 3 (let (v10 u32) (cast v0)) @@ -520,15 +520,15 @@ (block 4 (br (block 2 v7 v1))) - (block 5 (param v79 i32) (param v80 i32) (param v92 i32) - (let (v81 u32) (cast v80)) - (let (v82 u32) (add.checked v81 12)) - (let (v83 (ptr i32)) (inttoptr v82)) - (let (v84 i32) (load v83)) - (let (v85 u32) (cast v79)) - (let (v86 (ptr i32)) (inttoptr v85)) - (store v86 v84) - (br (block 2 v80 v92))) + (block 5 (param v78 i32) (param v79 i32) (param v91 i32) + (let (v80 u32) (cast v79)) + (let (v81 u32) (add.checked v80 12)) + (let (v82 (ptr i32)) (inttoptr v81)) + (let (v83 i32) (load v82)) + (let (v84 u32) (cast v78)) + (let (v85 (ptr i32)) (inttoptr v84)) + (store v85 v83) + (br (block 2 v79 v91))) (block 6 (let (v27 i32) (const.i32 -4)) @@ -550,50 +550,49 @@ (let (v43 u32) (cast v41)) (let (v44 u32) (shr.wrapping v42 v43)) (let (v45 i32) (cast v44)) - (let (v46 u32) (cast v45)) - (let (v47 i32) (memory.grow v46)) - (let (v48 i32) (const.i32 -1)) - (let (v49 i1) (neq v47 v48)) - (let (v50 i32) (cast v49)) - (let (v51 i1) (neq v50 0)) - (condbr v51 (block 7) (block 8))) + (let (v46 i32) (const.i32 1048575)) + (let (v47 i32) (const.i32 -1)) + (let (v48 i1) (neq v46 v47)) + (let (v49 i32) (cast v48)) + (let (v50 i1) (neq v49 0)) + (condbr v50 (block 7) (block 8))) (block 7 - (let (v53 i32) (const.i32 16)) - (let (v54 i32) (shl.wrapping v47 v53)) - (let (v55 i32) (const.i32 0)) - (let (v56 u32) (cast v54)) - (let (v57 u32) (add.checked v56 4)) - (let (v58 (ptr i32)) (inttoptr v57)) - (store v58 v55) - (let (v59 u32) (cast v7)) - (let (v60 u32) (add.checked v59 12)) - (let (v61 (ptr i32)) (inttoptr v60)) - (let (v62 i32) (load v61)) - (let (v63 u32) (cast v54)) - (let (v64 u32) (add.checked v63 8)) - (let (v65 (ptr i32)) (inttoptr v64)) - (store v65 v62) - (let (v66 i32) (const.i32 -65536)) - (let (v67 i32) (band v40 v66)) - (let (v68 i32) (add.wrapping v54 v67)) - (let (v69 i32) (const.i32 2)) - (let (v70 i32) (bor v68 v69)) - (let (v71 u32) (cast v54)) - (let (v72 (ptr i32)) (inttoptr v71)) - (store v72 v70) - (let (v73 u32) (cast v7)) - (let (v74 u32) (add.checked v73 12)) - (let (v75 (ptr i32)) (inttoptr v74)) - (store v75 v54) - (let (v76 i32) (const.i32 12)) - (let (v77 i32) (add.wrapping v7 v76)) - (let (v78 i32) (call #wee_alloc::alloc_first_fit v22 v1 v77)) - (br (block 5 v0 v7 v78))) + (let (v52 i32) (const.i32 16)) + (let (v53 i32) (shl.wrapping v46 v52)) + (let (v54 i32) (const.i32 0)) + (let (v55 u32) (cast v53)) + (let (v56 u32) (add.checked v55 4)) + (let (v57 (ptr i32)) (inttoptr v56)) + (store v57 v54) + (let (v58 u32) (cast v7)) + (let (v59 u32) (add.checked v58 12)) + (let (v60 (ptr i32)) (inttoptr v59)) + (let (v61 i32) (load v60)) + (let (v62 u32) (cast v53)) + (let (v63 u32) (add.checked v62 8)) + (let (v64 (ptr i32)) (inttoptr v63)) + (store v64 v61) + (let (v65 i32) (const.i32 -65536)) + (let (v66 i32) (band v40 v65)) + (let (v67 i32) (add.wrapping v53 v66)) + (let (v68 i32) (const.i32 2)) + (let (v69 i32) (bor v67 v68)) + (let (v70 u32) (cast v53)) + (let (v71 (ptr i32)) (inttoptr v70)) + (store v71 v69) + (let (v72 u32) (cast v7)) + (let (v73 u32) (add.checked v72 12)) + (let (v74 (ptr i32)) (inttoptr v73)) + (store v74 v53) + (let (v75 i32) (const.i32 12)) + (let (v76 i32) (add.wrapping v7 v75)) + (let (v77 i32) (call #wee_alloc::alloc_first_fit v22 v1 v76)) + (br (block 5 v0 v7 v77))) (block 8 - (let (v52 i32) (const.i32 0)) - (br (block 5 v0 v7 v52))) + (let (v51 i32) (const.i32 0)) + (br (block 5 v0 v7 v51))) ) (func (export #::dealloc) diff --git a/tests/integration/expected/components/inc_wasm_component.hir b/tests/integration/expected/components/inc_wasm_component.hir index e5981a858..0ad9c128a 100644 --- a/tests/integration/expected/components/inc_wasm_component.hir +++ b/tests/integration/expected/components/inc_wasm_component.hir @@ -492,12 +492,12 @@ (block 1 (param v3 i32) (ret v3)) - (block 2 (param v87 i32) (param v91 i32) - (let (v88 i32) (const.i32 16)) - (let (v89 i32) (add.wrapping v87 v88)) - (let (v90 (ptr i32)) (global.symbol #__stack_pointer)) - (store v90 v89) - (br (block 1 v91))) + (block 2 (param v86 i32) (param v90 i32) + (let (v87 i32) (const.i32 16)) + (let (v88 i32) (add.wrapping v86 v87)) + (let (v89 (ptr i32)) (global.symbol #__stack_pointer)) + (store v89 v88) + (br (block 1 v90))) (block 3 (let (v10 u32) (cast v0)) @@ -523,15 +523,15 @@ (block 4 (br (block 2 v7 v1))) - (block 5 (param v79 i32) (param v80 i32) (param v92 i32) - (let (v81 u32) (cast v80)) - (let (v82 u32) (add.checked v81 12)) - (let (v83 (ptr i32)) (inttoptr v82)) - (let (v84 i32) (load v83)) - (let (v85 u32) (cast v79)) - (let (v86 (ptr i32)) (inttoptr v85)) - (store v86 v84) - (br (block 2 v80 v92))) + (block 5 (param v78 i32) (param v79 i32) (param v91 i32) + (let (v80 u32) (cast v79)) + (let (v81 u32) (add.checked v80 12)) + (let (v82 (ptr i32)) (inttoptr v81)) + (let (v83 i32) (load v82)) + (let (v84 u32) (cast v78)) + (let (v85 (ptr i32)) (inttoptr v84)) + (store v85 v83) + (br (block 2 v79 v91))) (block 6 (let (v27 i32) (const.i32 -4)) @@ -553,50 +553,49 @@ (let (v43 u32) (cast v41)) (let (v44 u32) (shr.wrapping v42 v43)) (let (v45 i32) (cast v44)) - (let (v46 u32) (cast v45)) - (let (v47 i32) (memory.grow v46)) - (let (v48 i32) (const.i32 -1)) - (let (v49 i1) (neq v47 v48)) - (let (v50 i32) (cast v49)) - (let (v51 i1) (neq v50 0)) - (condbr v51 (block 7) (block 8))) + (let (v46 i32) (const.i32 1048575)) + (let (v47 i32) (const.i32 -1)) + (let (v48 i1) (neq v46 v47)) + (let (v49 i32) (cast v48)) + (let (v50 i1) (neq v49 0)) + (condbr v50 (block 7) (block 8))) (block 7 - (let (v53 i32) (const.i32 16)) - (let (v54 i32) (shl.wrapping v47 v53)) - (let (v55 i32) (const.i32 0)) - (let (v56 u32) (cast v54)) - (let (v57 u32) (add.checked v56 4)) - (let (v58 (ptr i32)) (inttoptr v57)) - (store v58 v55) - (let (v59 u32) (cast v7)) - (let (v60 u32) (add.checked v59 12)) - (let (v61 (ptr i32)) (inttoptr v60)) - (let (v62 i32) (load v61)) - (let (v63 u32) (cast v54)) - (let (v64 u32) (add.checked v63 8)) - (let (v65 (ptr i32)) (inttoptr v64)) - (store v65 v62) - (let (v66 i32) (const.i32 -65536)) - (let (v67 i32) (band v40 v66)) - (let (v68 i32) (add.wrapping v54 v67)) - (let (v69 i32) (const.i32 2)) - (let (v70 i32) (bor v68 v69)) - (let (v71 u32) (cast v54)) - (let (v72 (ptr i32)) (inttoptr v71)) - (store v72 v70) - (let (v73 u32) (cast v7)) - (let (v74 u32) (add.checked v73 12)) - (let (v75 (ptr i32)) (inttoptr v74)) - (store v75 v54) - (let (v76 i32) (const.i32 12)) - (let (v77 i32) (add.wrapping v7 v76)) - (let (v78 i32) (call #wee_alloc::alloc_first_fit v22 v1 v77)) - (br (block 5 v0 v7 v78))) + (let (v52 i32) (const.i32 16)) + (let (v53 i32) (shl.wrapping v46 v52)) + (let (v54 i32) (const.i32 0)) + (let (v55 u32) (cast v53)) + (let (v56 u32) (add.checked v55 4)) + (let (v57 (ptr i32)) (inttoptr v56)) + (store v57 v54) + (let (v58 u32) (cast v7)) + (let (v59 u32) (add.checked v58 12)) + (let (v60 (ptr i32)) (inttoptr v59)) + (let (v61 i32) (load v60)) + (let (v62 u32) (cast v53)) + (let (v63 u32) (add.checked v62 8)) + (let (v64 (ptr i32)) (inttoptr v63)) + (store v64 v61) + (let (v65 i32) (const.i32 -65536)) + (let (v66 i32) (band v40 v65)) + (let (v67 i32) (add.wrapping v53 v66)) + (let (v68 i32) (const.i32 2)) + (let (v69 i32) (bor v67 v68)) + (let (v70 u32) (cast v53)) + (let (v71 (ptr i32)) (inttoptr v70)) + (store v71 v69) + (let (v72 u32) (cast v7)) + (let (v73 u32) (add.checked v72 12)) + (let (v74 (ptr i32)) (inttoptr v73)) + (store v74 v53) + (let (v75 i32) (const.i32 12)) + (let (v76 i32) (add.wrapping v7 v75)) + (let (v77 i32) (call #wee_alloc::alloc_first_fit v22 v1 v76)) + (br (block 5 v0 v7 v77))) (block 8 - (let (v52 i32) (const.i32 0)) - (br (block 5 v0 v7 v52))) + (let (v51 i32) (const.i32 0)) + (br (block 5 v0 v7 v51))) ) (func (export #::dealloc) diff --git a/tests/integration/expected/rust_sdk_account_test/miden_sdk_account_test.hir b/tests/integration/expected/rust_sdk_account_test/miden_sdk_account_test.hir index fe0889730..c82ded265 100644 --- a/tests/integration/expected/rust_sdk_account_test/miden_sdk_account_test.hir +++ b/tests/integration/expected/rust_sdk_account_test/miden_sdk_account_test.hir @@ -1241,50 +1241,49 @@ (let (v20 u32) (cast v18)) (let (v21 u32) (shr.wrapping v19 v20)) (let (v22 i32) (cast v21)) - (let (v23 u32) (cast v22)) - (let (v24 i32) (memory.grow v23)) - (let (v25 i32) (const.i32 -1)) - (let (v26 i1) (neq v24 v25)) - (let (v27 i32) (cast v26)) - (let (v28 i1) (neq v27 0)) - (condbr v28 (block 3) (block 4))) + (let (v23 i32) (const.i32 1048575)) + (let (v24 i32) (const.i32 -1)) + (let (v25 i1) (neq v23 v24)) + (let (v26 i32) (cast v25)) + (let (v27 i1) (neq v26 0)) + (condbr v27 (block 3) (block 4))) (block 1 (ret)) - (block 2 (param v45 i32) (param v46 i32) (param v50 i32) - (let (v47 u32) (cast v45)) - (let (v48 u32) (add.checked v47 4)) - (let (v49 (ptr i32)) (inttoptr v48)) - (store v49 v46) - (let (v51 u32) (cast v45)) - (let (v52 (ptr i32)) (inttoptr v51)) - (store v52 v50) + (block 2 (param v44 i32) (param v45 i32) (param v49 i32) + (let (v46 u32) (cast v44)) + (let (v47 u32) (add.checked v46 4)) + (let (v48 (ptr i32)) (inttoptr v47)) + (store v48 v45) + (let (v50 u32) (cast v44)) + (let (v51 (ptr i32)) (inttoptr v50)) + (store v51 v49) (br (block 1))) (block 3 - (let (v31 i32) (const.i32 16)) - (let (v32 i32) (shl.wrapping v24 v31)) - (let (v33 i64) (const.i64 0)) - (let (v34 u32) (cast v32)) - (let (v35 u32) (add.checked v34 4)) - (let (v36 (ptr i64)) (inttoptr v35)) - (store v36 v33) - (let (v37 i32) (const.i32 -65536)) - (let (v38 i32) (band v17 v37)) - (let (v39 i32) (add.wrapping v32 v38)) - (let (v40 i32) (const.i32 2)) - (let (v41 i32) (bor v39 v40)) - (let (v42 u32) (cast v32)) - (let (v43 (ptr i32)) (inttoptr v42)) - (store v43 v41) - (let (v44 i32) (const.i32 0)) - (br (block 2 v0 v32 v44))) + (let (v30 i32) (const.i32 16)) + (let (v31 i32) (shl.wrapping v23 v30)) + (let (v32 i64) (const.i64 0)) + (let (v33 u32) (cast v31)) + (let (v34 u32) (add.checked v33 4)) + (let (v35 (ptr i64)) (inttoptr v34)) + (store v35 v32) + (let (v36 i32) (const.i32 -65536)) + (let (v37 i32) (band v17 v36)) + (let (v38 i32) (add.wrapping v31 v37)) + (let (v39 i32) (const.i32 2)) + (let (v40 i32) (bor v38 v39)) + (let (v41 u32) (cast v31)) + (let (v42 (ptr i32)) (inttoptr v41)) + (store v42 v40) + (let (v43 i32) (const.i32 0)) + (br (block 2 v0 v31 v43))) (block 4 - (let (v29 i32) (const.i32 1)) - (let (v30 i32) (const.i32 0)) - (br (block 2 v0 v30 v29))) + (let (v28 i32) (const.i32 1)) + (let (v29 i32) (const.i32 0)) + (br (block 2 v0 v29 v28))) ) (func (export #wee_alloc::alloc_first_fit) diff --git a/tests/integration/expected/wit_sdk_basic_wallet/basic_wallet.hir b/tests/integration/expected/wit_sdk_basic_wallet/basic_wallet.hir index 9883c1a24..960f06555 100644 --- a/tests/integration/expected/wit_sdk_basic_wallet/basic_wallet.hir +++ b/tests/integration/expected/wit_sdk_basic_wallet/basic_wallet.hir @@ -586,12 +586,12 @@ (block 1 (param v3 i32) (ret v3)) - (block 2 (param v87 i32) (param v91 i32) - (let (v88 i32) (const.i32 16)) - (let (v89 i32) (add.wrapping v87 v88)) - (let (v90 (ptr i32)) (global.symbol #__stack_pointer)) - (store v90 v89) - (br (block 1 v91))) + (block 2 (param v86 i32) (param v90 i32) + (let (v87 i32) (const.i32 16)) + (let (v88 i32) (add.wrapping v86 v87)) + (let (v89 (ptr i32)) (global.symbol #__stack_pointer)) + (store v89 v88) + (br (block 1 v90))) (block 3 (let (v10 u32) (cast v0)) @@ -617,15 +617,15 @@ (block 4 (br (block 2 v7 v1))) - (block 5 (param v79 i32) (param v80 i32) (param v92 i32) - (let (v81 u32) (cast v80)) - (let (v82 u32) (add.checked v81 12)) - (let (v83 (ptr i32)) (inttoptr v82)) - (let (v84 i32) (load v83)) - (let (v85 u32) (cast v79)) - (let (v86 (ptr i32)) (inttoptr v85)) - (store v86 v84) - (br (block 2 v80 v92))) + (block 5 (param v78 i32) (param v79 i32) (param v91 i32) + (let (v80 u32) (cast v79)) + (let (v81 u32) (add.checked v80 12)) + (let (v82 (ptr i32)) (inttoptr v81)) + (let (v83 i32) (load v82)) + (let (v84 u32) (cast v78)) + (let (v85 (ptr i32)) (inttoptr v84)) + (store v85 v83) + (br (block 2 v79 v91))) (block 6 (let (v27 i32) (const.i32 -4)) @@ -647,50 +647,49 @@ (let (v43 u32) (cast v41)) (let (v44 u32) (shr.wrapping v42 v43)) (let (v45 i32) (cast v44)) - (let (v46 u32) (cast v45)) - (let (v47 i32) (memory.grow v46)) - (let (v48 i32) (const.i32 -1)) - (let (v49 i1) (neq v47 v48)) - (let (v50 i32) (cast v49)) - (let (v51 i1) (neq v50 0)) - (condbr v51 (block 7) (block 8))) + (let (v46 i32) (const.i32 1048575)) + (let (v47 i32) (const.i32 -1)) + (let (v48 i1) (neq v46 v47)) + (let (v49 i32) (cast v48)) + (let (v50 i1) (neq v49 0)) + (condbr v50 (block 7) (block 8))) (block 7 - (let (v53 i32) (const.i32 16)) - (let (v54 i32) (shl.wrapping v47 v53)) - (let (v55 i32) (const.i32 0)) - (let (v56 u32) (cast v54)) - (let (v57 u32) (add.checked v56 4)) - (let (v58 (ptr i32)) (inttoptr v57)) - (store v58 v55) - (let (v59 u32) (cast v7)) - (let (v60 u32) (add.checked v59 12)) - (let (v61 (ptr i32)) (inttoptr v60)) - (let (v62 i32) (load v61)) - (let (v63 u32) (cast v54)) - (let (v64 u32) (add.checked v63 8)) - (let (v65 (ptr i32)) (inttoptr v64)) - (store v65 v62) - (let (v66 i32) (const.i32 -65536)) - (let (v67 i32) (band v40 v66)) - (let (v68 i32) (add.wrapping v54 v67)) - (let (v69 i32) (const.i32 2)) - (let (v70 i32) (bor v68 v69)) - (let (v71 u32) (cast v54)) - (let (v72 (ptr i32)) (inttoptr v71)) - (store v72 v70) - (let (v73 u32) (cast v7)) - (let (v74 u32) (add.checked v73 12)) - (let (v75 (ptr i32)) (inttoptr v74)) - (store v75 v54) - (let (v76 i32) (const.i32 12)) - (let (v77 i32) (add.wrapping v7 v76)) - (let (v78 i32) (call #wee_alloc::alloc_first_fit v22 v1 v77)) - (br (block 5 v0 v7 v78))) + (let (v52 i32) (const.i32 16)) + (let (v53 i32) (shl.wrapping v46 v52)) + (let (v54 i32) (const.i32 0)) + (let (v55 u32) (cast v53)) + (let (v56 u32) (add.checked v55 4)) + (let (v57 (ptr i32)) (inttoptr v56)) + (store v57 v54) + (let (v58 u32) (cast v7)) + (let (v59 u32) (add.checked v58 12)) + (let (v60 (ptr i32)) (inttoptr v59)) + (let (v61 i32) (load v60)) + (let (v62 u32) (cast v53)) + (let (v63 u32) (add.checked v62 8)) + (let (v64 (ptr i32)) (inttoptr v63)) + (store v64 v61) + (let (v65 i32) (const.i32 -65536)) + (let (v66 i32) (band v40 v65)) + (let (v67 i32) (add.wrapping v53 v66)) + (let (v68 i32) (const.i32 2)) + (let (v69 i32) (bor v67 v68)) + (let (v70 u32) (cast v53)) + (let (v71 (ptr i32)) (inttoptr v70)) + (store v71 v69) + (let (v72 u32) (cast v7)) + (let (v73 u32) (add.checked v72 12)) + (let (v74 (ptr i32)) (inttoptr v73)) + (store v74 v53) + (let (v75 i32) (const.i32 12)) + (let (v76 i32) (add.wrapping v7 v75)) + (let (v77 i32) (call #wee_alloc::alloc_first_fit v22 v1 v76)) + (br (block 5 v0 v7 v77))) (block 8 - (let (v52 i32) (const.i32 0)) - (br (block 5 v0 v7 v52))) + (let (v51 i32) (const.i32 0)) + (br (block 5 v0 v7 v51))) ) (func (export #::dealloc) diff --git a/tests/integration/expected/wit_sdk_basic_wallet/basic_wallet_p2id_note.hir b/tests/integration/expected/wit_sdk_basic_wallet/basic_wallet_p2id_note.hir index 4ec5979a3..59950ce20 100644 --- a/tests/integration/expected/wit_sdk_basic_wallet/basic_wallet_p2id_note.hir +++ b/tests/integration/expected/wit_sdk_basic_wallet/basic_wallet_p2id_note.hir @@ -627,12 +627,12 @@ (block 1 (param v3 i32) (ret v3)) - (block 2 (param v87 i32) (param v91 i32) - (let (v88 i32) (const.i32 16)) - (let (v89 i32) (add.wrapping v87 v88)) - (let (v90 (ptr i32)) (global.symbol #__stack_pointer)) - (store v90 v89) - (br (block 1 v91))) + (block 2 (param v86 i32) (param v90 i32) + (let (v87 i32) (const.i32 16)) + (let (v88 i32) (add.wrapping v86 v87)) + (let (v89 (ptr i32)) (global.symbol #__stack_pointer)) + (store v89 v88) + (br (block 1 v90))) (block 3 (let (v10 u32) (cast v0)) @@ -658,15 +658,15 @@ (block 4 (br (block 2 v7 v1))) - (block 5 (param v79 i32) (param v80 i32) (param v92 i32) - (let (v81 u32) (cast v80)) - (let (v82 u32) (add.checked v81 12)) - (let (v83 (ptr i32)) (inttoptr v82)) - (let (v84 i32) (load v83)) - (let (v85 u32) (cast v79)) - (let (v86 (ptr i32)) (inttoptr v85)) - (store v86 v84) - (br (block 2 v80 v92))) + (block 5 (param v78 i32) (param v79 i32) (param v91 i32) + (let (v80 u32) (cast v79)) + (let (v81 u32) (add.checked v80 12)) + (let (v82 (ptr i32)) (inttoptr v81)) + (let (v83 i32) (load v82)) + (let (v84 u32) (cast v78)) + (let (v85 (ptr i32)) (inttoptr v84)) + (store v85 v83) + (br (block 2 v79 v91))) (block 6 (let (v27 i32) (const.i32 -4)) @@ -688,50 +688,49 @@ (let (v43 u32) (cast v41)) (let (v44 u32) (shr.wrapping v42 v43)) (let (v45 i32) (cast v44)) - (let (v46 u32) (cast v45)) - (let (v47 i32) (memory.grow v46)) - (let (v48 i32) (const.i32 -1)) - (let (v49 i1) (neq v47 v48)) - (let (v50 i32) (cast v49)) - (let (v51 i1) (neq v50 0)) - (condbr v51 (block 7) (block 8))) + (let (v46 i32) (const.i32 1048575)) + (let (v47 i32) (const.i32 -1)) + (let (v48 i1) (neq v46 v47)) + (let (v49 i32) (cast v48)) + (let (v50 i1) (neq v49 0)) + (condbr v50 (block 7) (block 8))) (block 7 - (let (v53 i32) (const.i32 16)) - (let (v54 i32) (shl.wrapping v47 v53)) - (let (v55 i32) (const.i32 0)) - (let (v56 u32) (cast v54)) - (let (v57 u32) (add.checked v56 4)) - (let (v58 (ptr i32)) (inttoptr v57)) - (store v58 v55) - (let (v59 u32) (cast v7)) - (let (v60 u32) (add.checked v59 12)) - (let (v61 (ptr i32)) (inttoptr v60)) - (let (v62 i32) (load v61)) - (let (v63 u32) (cast v54)) - (let (v64 u32) (add.checked v63 8)) - (let (v65 (ptr i32)) (inttoptr v64)) - (store v65 v62) - (let (v66 i32) (const.i32 -65536)) - (let (v67 i32) (band v40 v66)) - (let (v68 i32) (add.wrapping v54 v67)) - (let (v69 i32) (const.i32 2)) - (let (v70 i32) (bor v68 v69)) - (let (v71 u32) (cast v54)) - (let (v72 (ptr i32)) (inttoptr v71)) - (store v72 v70) - (let (v73 u32) (cast v7)) - (let (v74 u32) (add.checked v73 12)) - (let (v75 (ptr i32)) (inttoptr v74)) - (store v75 v54) - (let (v76 i32) (const.i32 12)) - (let (v77 i32) (add.wrapping v7 v76)) - (let (v78 i32) (call #wee_alloc::alloc_first_fit v22 v1 v77)) - (br (block 5 v0 v7 v78))) + (let (v52 i32) (const.i32 16)) + (let (v53 i32) (shl.wrapping v46 v52)) + (let (v54 i32) (const.i32 0)) + (let (v55 u32) (cast v53)) + (let (v56 u32) (add.checked v55 4)) + (let (v57 (ptr i32)) (inttoptr v56)) + (store v57 v54) + (let (v58 u32) (cast v7)) + (let (v59 u32) (add.checked v58 12)) + (let (v60 (ptr i32)) (inttoptr v59)) + (let (v61 i32) (load v60)) + (let (v62 u32) (cast v53)) + (let (v63 u32) (add.checked v62 8)) + (let (v64 (ptr i32)) (inttoptr v63)) + (store v64 v61) + (let (v65 i32) (const.i32 -65536)) + (let (v66 i32) (band v40 v65)) + (let (v67 i32) (add.wrapping v53 v66)) + (let (v68 i32) (const.i32 2)) + (let (v69 i32) (bor v67 v68)) + (let (v70 u32) (cast v53)) + (let (v71 (ptr i32)) (inttoptr v70)) + (store v71 v69) + (let (v72 u32) (cast v7)) + (let (v73 u32) (add.checked v72 12)) + (let (v74 (ptr i32)) (inttoptr v73)) + (store v74 v53) + (let (v75 i32) (const.i32 12)) + (let (v76 i32) (add.wrapping v7 v75)) + (let (v77 i32) (call #wee_alloc::alloc_first_fit v22 v1 v76)) + (br (block 5 v0 v7 v77))) (block 8 - (let (v52 i32) (const.i32 0)) - (br (block 5 v0 v7 v52))) + (let (v51 i32) (const.i32 0)) + (br (block 5 v0 v7 v51))) ) (func (export #::dealloc) diff --git a/tests/integration/src/rust_masm_tests/abi_transform/tx_kernel.rs b/tests/integration/src/rust_masm_tests/abi_transform/tx_kernel.rs index 5c317cea9..2ad31d939 100644 --- a/tests/integration/src/rust_masm_tests/abi_transform/tx_kernel.rs +++ b/tests/integration/src/rust_masm_tests/abi_transform/tx_kernel.rs @@ -5,9 +5,9 @@ use crate::CompilerTest; #[ignore = "until https://github.com/0xPolygonMiden/compiler/issues/200 is fixed"] #[test] fn test_get_inputs() { - let main_fn = format!("() -> Vec {{ get_inputs() }}"); + let main_fn = "() -> Vec {{ get_inputs() }}"; let artifact_name = "abi_transform_tx_kernel_get_inputs"; - let mut test = CompilerTest::rust_fn_body_with_sdk(&artifact_name, &main_fn, true); + let mut test = CompilerTest::rust_fn_body_with_sdk(artifact_name, main_fn, true); // Test expected compilation artifacts test.expect_wasm(expect_file![format!("../../../expected/{artifact_name}.wat")]); test.expect_ir(expect_file![format!("../../../expected/{artifact_name}.hir")]);