Mrmaxmeier labeled issue #2903:
I'm experimenting with some cranelift codegen and I'm seeing a hang/OOM related to the variable ssa resolver.
Here's a minimal reproducer (for
cranelift/frontend/src/frontend.rs
):#[test] fn ssa_state_machine_hang() { let sig = Signature::new(CallConv::SystemV); let mut fn_ctx = FunctionBuilderContext::new(); let mut func = Function::with_name_signature(ExternalName::testcase("sample"), sig); { let mut builder = FunctionBuilder::new(&mut func, &mut fn_ctx); let a = Variable::new(0); builder.declare_var(a, I32); let entry = builder.create_block(); let block1 = builder.create_block(); let use_block = builder.create_block(); // fill entry block builder.switch_to_block(entry); use cranelift_codegen::ir::TrapCode; builder.ins().trap(TrapCode::User(0)); // fill block1 with back edge builder.switch_to_block(block1); let cond = builder.ins().iconst(I32, 0); builder.ins().brnz(cond, block1, &[]); builder.ins().jump(use_block, &[]); // use variable in use_block builder.switch_to_block(use_block); let _ = builder.use_var(a); builder.ins().return_(&[]); println!("sealing blocks..."); builder.seal_all_blocks(); // hangs builder.finalize(); } println!("{}", func.display(None).to_string()); }
It hangs in
seal_all_blocks -> run_state_machine
with a huge/growingself.calls
vec.Versions and Environment
Cranelift version or commit:
v0.73.0
and current main
Mrmaxmeier labeled issue #2903:
I'm experimenting with some cranelift codegen and I'm seeing a hang/OOM related to the variable ssa resolver.
Here's a minimal reproducer (for
cranelift/frontend/src/frontend.rs
):#[test] fn ssa_state_machine_hang() { let sig = Signature::new(CallConv::SystemV); let mut fn_ctx = FunctionBuilderContext::new(); let mut func = Function::with_name_signature(ExternalName::testcase("sample"), sig); { let mut builder = FunctionBuilder::new(&mut func, &mut fn_ctx); let a = Variable::new(0); builder.declare_var(a, I32); let entry = builder.create_block(); let block1 = builder.create_block(); let use_block = builder.create_block(); // fill entry block builder.switch_to_block(entry); use cranelift_codegen::ir::TrapCode; builder.ins().trap(TrapCode::User(0)); // fill block1 with back edge builder.switch_to_block(block1); let cond = builder.ins().iconst(I32, 0); builder.ins().brnz(cond, block1, &[]); builder.ins().jump(use_block, &[]); // use variable in use_block builder.switch_to_block(use_block); let _ = builder.use_var(a); builder.ins().return_(&[]); println!("sealing blocks..."); builder.seal_all_blocks(); // hangs builder.finalize(); } println!("{}", func.display(None).to_string()); }
It hangs in
seal_all_blocks -> run_state_machine
with a huge/growingself.calls
vec.Versions and Environment
Cranelift version or commit:
v0.73.0
and current main
Mrmaxmeier opened issue #2903:
I'm experimenting with some cranelift codegen and I'm seeing a hang/OOM related to the variable ssa resolver.
Here's a minimal reproducer (for
cranelift/frontend/src/frontend.rs
):#[test] fn ssa_state_machine_hang() { let sig = Signature::new(CallConv::SystemV); let mut fn_ctx = FunctionBuilderContext::new(); let mut func = Function::with_name_signature(ExternalName::testcase("sample"), sig); { let mut builder = FunctionBuilder::new(&mut func, &mut fn_ctx); let a = Variable::new(0); builder.declare_var(a, I32); let entry = builder.create_block(); let block1 = builder.create_block(); let use_block = builder.create_block(); // fill entry block builder.switch_to_block(entry); use cranelift_codegen::ir::TrapCode; builder.ins().trap(TrapCode::User(0)); // fill block1 with back edge builder.switch_to_block(block1); let cond = builder.ins().iconst(I32, 0); builder.ins().brnz(cond, block1, &[]); builder.ins().jump(use_block, &[]); // use variable in use_block builder.switch_to_block(use_block); let _ = builder.use_var(a); builder.ins().return_(&[]); println!("sealing blocks..."); builder.seal_all_blocks(); // hangs builder.finalize(); } println!("{}", func.display(None).to_string()); }
It hangs in
seal_all_blocks -> run_state_machine
with a huge/growingself.calls
vec.Versions and Environment
Cranelift version or commit:
v0.73.0
and current main
bjorn3 commented on issue #2903:
I think the problem here is that block1 has a single predecessor (itself) and it tries to handle this single predecessor first
Mrmaxmeier commented on issue #2903:
It looks like this was also discovered in #3094 and fixed in 6a9378e.
Mrmaxmeier closed issue #2903:
I'm experimenting with some cranelift codegen and I'm seeing a hang/OOM related to the variable ssa resolver.
Here's a minimal reproducer (for
cranelift/frontend/src/frontend.rs
):#[test] fn ssa_state_machine_hang() { let sig = Signature::new(CallConv::SystemV); let mut fn_ctx = FunctionBuilderContext::new(); let mut func = Function::with_name_signature(ExternalName::testcase("sample"), sig); { let mut builder = FunctionBuilder::new(&mut func, &mut fn_ctx); let a = Variable::new(0); builder.declare_var(a, I32); let entry = builder.create_block(); let block1 = builder.create_block(); let use_block = builder.create_block(); // fill entry block builder.switch_to_block(entry); use cranelift_codegen::ir::TrapCode; builder.ins().trap(TrapCode::User(0)); // fill block1 with back edge builder.switch_to_block(block1); let cond = builder.ins().iconst(I32, 0); builder.ins().brnz(cond, block1, &[]); builder.ins().jump(use_block, &[]); // use variable in use_block builder.switch_to_block(use_block); let _ = builder.use_var(a); builder.ins().return_(&[]); println!("sealing blocks..."); builder.seal_all_blocks(); // hangs builder.finalize(); } println!("{}", func.display(None).to_string()); }
It hangs in
seal_all_blocks -> run_state_machine
with a huge/growingself.calls
vec.Versions and Environment
Cranelift version or commit:
v0.73.0
and current main
Last updated: Nov 22 2024 at 17:03 UTC