cfallin opened issue #10361:
With the following test-case
test compile target x86_64 function %f0(i32, i32) -> i32 { block0(v0: i32, v1: i32): v2 = band.i32 v0, v1 return v2 }
when running the following command
$ RUST_BACKTRACE=1 RUST_LOG=trace cargo run -p cranelift-tools -- test ./test.clif
I get a panic like so:
TRACE cranelift_codegen::machinst::lower > lowering: inst inst0: v2 = band.i32 v0, v1 [ ... ] thread 'worker #2' panicked at cranelift/codegen/src/isa/x64/inst/external.rs:95:9: internal error: entered unreachable code stack backtrace: [ ... ] 3: cranelift_codegen::isa::x64::inst::external::enc_gpr at ./cranelift/codegen/src/isa/x64/inst/external.rs:95:9 4: <cranelift_codegen::isa::x64::inst::external::PairedGpr as cranelift_assembler_x64::api::AsReg>::enc at ./cranelift/codegen/src/isa/x64/inst/external.rs:35:20 5: cranelift_assembler_x64::reg::Gpr<R>::enc at ./cranelift/assembler-x64/src/reg.rs:27:19 6: cranelift_assembler_x64::reg::Gpr<R>::to_string at ./cranelift/assembler-x64/src/reg.rs:34:24 7: <cranelift_assembler_x64::inst::andl_rm<R> as core::fmt::Display>::fmt at ./target/debug/build/cranelift-assembler-x64-0a4a19fac84309b6/out/assembler.rs:4336:19 [ ... ] 22: cranelift_codegen::isa::x64::inst::<impl cranelift_codegen::machinst::reg::PrettyPrint for cranelift_codegen::isa::x64::lower::isle::generated_code::MInst>::pretty_print at ./cranelift/codegen/src/isa/x64/inst/mod.rs:1983:17 23: cranelift_codegen::isa::x64::inst::<impl cranelift_codegen::machinst::MachInstEmit for cranelift_codegen::isa::x64::lower::isle::generated_code::MInst>::pretty_print_inst at ./cranelift/codegen/src/isa/x64/inst/mod.rs:2967:9 24: cranelift_codegen::isa::x64::inst::<impl core::fmt::Debug for cranelift_codegen::isa::x64::lower::isle::generated_code::MInst>::fmt at ./cranelift/codegen/src/isa/x64/inst/mod.rs:1991:27 [ ... ] 39: cranelift_codegen::machinst::lower::Lower<I>::emit at ./cranelift/codegen/src/lib.rs:103:13
Basically, it seems that the new assembler generates a Debug impl that only works post-regalloc, but we have trace-log messages that print instructions pre-regalloc; we need to handle this as well somehow. Perhaps we can make
AsReg::enc()
return anOption<u8>
and use the underlyingDebug
(AsReg
requiresDebug
) if the plugged-in register value does not have a hardware encoding (as a vreg won't)?cc @abrown
abrown assigned abrown to issue #10361.
abrown closed issue #10361:
With the following test-case
test compile target x86_64 function %f0(i32, i32) -> i32 { block0(v0: i32, v1: i32): v2 = band.i32 v0, v1 return v2 }
when running the following command
$ RUST_BACKTRACE=1 RUST_LOG=trace cargo run -p cranelift-tools -- test ./test.clif
I get a panic like so:
TRACE cranelift_codegen::machinst::lower > lowering: inst inst0: v2 = band.i32 v0, v1 [ ... ] thread 'worker #2' panicked at cranelift/codegen/src/isa/x64/inst/external.rs:95:9: internal error: entered unreachable code stack backtrace: [ ... ] 3: cranelift_codegen::isa::x64::inst::external::enc_gpr at ./cranelift/codegen/src/isa/x64/inst/external.rs:95:9 4: <cranelift_codegen::isa::x64::inst::external::PairedGpr as cranelift_assembler_x64::api::AsReg>::enc at ./cranelift/codegen/src/isa/x64/inst/external.rs:35:20 5: cranelift_assembler_x64::reg::Gpr<R>::enc at ./cranelift/assembler-x64/src/reg.rs:27:19 6: cranelift_assembler_x64::reg::Gpr<R>::to_string at ./cranelift/assembler-x64/src/reg.rs:34:24 7: <cranelift_assembler_x64::inst::andl_rm<R> as core::fmt::Display>::fmt at ./target/debug/build/cranelift-assembler-x64-0a4a19fac84309b6/out/assembler.rs:4336:19 [ ... ] 22: cranelift_codegen::isa::x64::inst::<impl cranelift_codegen::machinst::reg::PrettyPrint for cranelift_codegen::isa::x64::lower::isle::generated_code::MInst>::pretty_print at ./cranelift/codegen/src/isa/x64/inst/mod.rs:1983:17 23: cranelift_codegen::isa::x64::inst::<impl cranelift_codegen::machinst::MachInstEmit for cranelift_codegen::isa::x64::lower::isle::generated_code::MInst>::pretty_print_inst at ./cranelift/codegen/src/isa/x64/inst/mod.rs:2967:9 24: cranelift_codegen::isa::x64::inst::<impl core::fmt::Debug for cranelift_codegen::isa::x64::lower::isle::generated_code::MInst>::fmt at ./cranelift/codegen/src/isa/x64/inst/mod.rs:1991:27 [ ... ] 39: cranelift_codegen::machinst::lower::Lower<I>::emit at ./cranelift/codegen/src/lib.rs:103:13
Basically, it seems that the new assembler generates a Debug impl that only works post-regalloc, but we have trace-log messages that print instructions pre-regalloc; we need to handle this as well somehow. Perhaps we can make
AsReg::enc()
return anOption<u8>
and use the underlyingDebug
(AsReg
requiresDebug
) if the plugged-in register value does not have a hardware encoding (as a vreg won't)?cc @abrown
Last updated: Apr 17 2025 at 18:04 UTC