0xPolygonMiden / compiler

Compiler from MidenIR to Miden Assembly

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unexpected controlling loop assertion in `BlockEmitter::target_controlling_loop` for `wee_alloc::alloc_first_fit` function in `tx_kernel::get_inputs` test

greenhat opened this issue · comments

To reproduce, run cargo test get_inputs in #199 branch

The assertion fails in the wee_alloc::alloc_first_fit function (the same function required new treeify pass) code with:

thread 'rust_masm_tests::abi_transform::tx_kernel::test_get_inputs' panicked at codegen/masm/src/codegen/emitter.rs:1008:17:
assertion `left == right` failed: unexpected controlling loop: block9, parent: Some(block2)
  left: Some(loop1)
 right: None
stack backtrace:
   0: rust_begin_unwind
             at /rustc/2d24fe591f30386d6d5fc2bb941c78d7266bf10f/library/std/src/panicking.rs:645:5
   1: core::panicking::panic_fmt
             at /rustc/2d24fe591f30386d6d5fc2bb941c78d7266bf10f/library/core/src/panicking.rs:72:14
   2: core::panicking::assert_failed_inner
   3: core::panicking::assert_failed
             at /rustc/2d24fe591f30386d6d5fc2bb941c78d7266bf10f/library/core/src/panicking.rs:298:5
   4: midenc_codegen_masm::codegen::emitter::BlockEmitter::target_controlling_loop
             at /Users/dzadorozhnyi/src/miden-ir/codegen/masm/src/codegen/emitter.rs:1008:17
   5: midenc_codegen_masm::codegen::emitter::BlockEmitter::emit_cond_br
             at /Users/dzadorozhnyi/src/miden-ir/codegen/masm/src/codegen/emitter.rs:394:40
   6: midenc_codegen_masm::codegen::emitter::BlockEmitter::emit_inst
             at /Users/dzadorozhnyi/src/miden-ir/codegen/masm/src/codegen/emitter.rs:218:44
   7: midenc_codegen_masm::codegen::emitter::BlockEmitter::emit
             at /Users/dzadorozhnyi/src/miden-ir/codegen/masm/src/codegen/emitter.rs:185:48
   8: midenc_codegen_masm::codegen::emitter::FunctionEmitter::emit
             at /Users/dzadorozhnyi/src/miden-ir/codegen/masm/src/codegen/emitter.rs:136:21
   9: <midenc_codegen_masm::convert::ConvertHirToMasm<&midenc_hir::function::Function> as midenc_hir::pass::conversion::ConversionPass>::convert
             at /Users/dzadorozhnyi/src/miden-ir/codegen/masm/src/convert.rs:188:13
  10: <midenc_codegen_masm::convert::ConvertHirToMasm<midenc_hir::module::Module> as midenc_hir::pass::conversion::ConversionPass>::convert
             at /Users/dzadorozhnyi/src/miden-ir/codegen/masm/src/convert.rs:136:33
  11: <midenc_compile::stages::codegen::CodegenStage as midenc_compile::stage::Stage>::run
             at /Users/dzadorozhnyi/src/miden-ir/midenc-compile/src/stages/codegen.rs:36:39
  12: <midenc_compile::stage::Chain<A,B> as midenc_compile::stage::Stage>::run
             at /Users/dzadorozhnyi/src/miden-ir/midenc-compile/src/stage.rs:81:9
  13: midenc_compile::compile_inputs
             at /Users/dzadorozhnyi/src/miden-ir/midenc-compile/src/lib.rs:191:5
  14: midenc_compile::compile_to_memory
             at /Users/dzadorozhnyi/src/miden-ir/midenc-compile/src/lib.rs:170:11
  15: miden_integration_tests::compiler_test::CompilerTest::compile_wasm_to_masm_program
             at ./src/compiler_test.rs:588:15
  16: miden_integration_tests::compiler_test::CompilerTest::ir_masm_program
             at ./src/compiler_test.rs:572:27
  17: miden_integration_tests::compiler_test::CompilerTest::expect_masm
             at ./src/compiler_test.rs:537:23
  18: miden_integration_tests::rust_masm_tests::abi_transform::tx_kernel::test_get_inputs
             at ./src/rust_masm_tests/abi_transform/tx_kernel.rs:14:5
  19: miden_integration_tests::rust_masm_tests::abi_transform::tx_kernel::test_get_inputs::{{closure}}
             at ./src/rust_masm_tests/abi_transform/tx_kernel.rs:7:21
  20: core::ops::function::FnOnce::call_once
             at /rustc/2d24fe591f30386d6d5fc2bb941c78d7266bf10f/library/core/src/ops/function.rs:250:5
  21: core::ops::function::FnOnce::call_once
             at /rustc/2d24fe591f30386d6d5fc2bb941c78d7266bf10f/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.


failures:
    rust_masm_tests::abi_transform::tx_kernel::test_get_inputs

@bitwalker I'm wondering if the controlling loop tracking in the block emitter needs to be updated to be in sync with the new changes introduced in treeify in #198