Stream: git-wasmtime

Topic: wasmtime / issue #3920 Cranelift: cfg had unexpected succ...


view this post on Zulip Wasmtime GitHub notifications bot (Mar 13 2022 at 17:30):

jfecher edited issue #3920:

.clif Test Case

function u0:0() -> i32 apple_aarch64 {
    sig0 = (i64) -> i64 fast
    sig1 = (i64) -> i64 system_v
    fn0 = colocated u0:2 sig0
    fn1 = u0:3 sig1
    jt0 = jump_table [block3, block4]

block0:
    v0 = iconst.i64 104
    v1 = call fn0(v0)
    v2 = load.i64 v1
    br_table v2, block4, jt0

block3:
    v3 = load.i64 v1+1
    jump block1

block4:
    jump block2

block1:
    v5 = call fn1(v3)
    jump block5(v5)

block2:
    v6 = iconst.i64 0
    jump block5(v6)

block5(v4: i64):
    v7 = iconst.i32 0
    return v7
}

Apologies I can't seem to find where to install clif-util so that I can run clif-util bugpoint.

Steps to Reproduce

Create the above IR via cranelift_jit and the FunctionBuilder API.

Expected Results

Expected the IR to be valid without panicking given that it had passed the cranelift_codegen::verifier::verify_function check.

Actual Results

Panics with:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Compilation(Verifier(VerifierErrors([VerifierError { location: block0, context: None, me
ssage: "cfg had unexpected successor(s) [block3, block4]" }])))', src/cranelift_backend/context.rs:188:14

The line in question is:

module.define_function(function_id, module_context).unwrap();

where module: cranelift_jit::backend::JITModule

Versions and Environment

Cranelift version or commit: 0.82.1

Operating system: Mac OSX 12.2.1

Architecture: arm64

Extra Info

This function IR fails at define_function despite passing the cranelift_codegen::verifier::verify_function check.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 13 2022 at 17:30):

jfecher edited issue #3920:

.clif Test Case

function u0:0() -> i32 apple_aarch64 {
    sig0 = (i64) -> i64 fast
    sig1 = (i64) -> i64 system_v
    fn0 = colocated u0:2 sig0
    fn1 = u0:3 sig1
    jt0 = jump_table [block3, block4]

block0:
    v0 = iconst.i64 104
    v1 = call fn0(v0)
    v2 = load.i64 v1
    br_table v2, block4, jt0

block3:
    v3 = load.i64 v1+1
    jump block1

block4:
    jump block2

block1:
    v5 = call fn1(v3)
    jump block5(v5)

block2:
    v6 = iconst.i64 0
    jump block5(v6)

block5(v4: i64):
    v7 = iconst.i32 0
    return v7
}

Apologies I can't seem to find where to install clif-util so that I can run clif-util bugpoint.

Steps to Reproduce

Create the above IR via cranelift_jit and the FunctionBuilder API.

Expected Results

Expected the IR to be valid without panicking given that it had passed the cranelift_codegen::verifier::verify_function check.

Actual Results

Panics with:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Compilation(Verifier(VerifierErrors([VerifierError { location: block0, context: None, me
ssage: "cfg had unexpected successor(s) [block3, block4]" }])))', src/cranelift_backend/context.rs:188:14

The line in question is:

module.define_function(function_id, module_context).unwrap();

where module: cranelift_jit::backend::JITModule

Versions and Environment

Cranelift version or commit: 0.82.1

Operating system: Mac OSX 12.2.1

Architecture: arm64

Extra Info

This function IR fails at define_function despite passing the cranelift_codegen::verifier::verify_function check.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 13 2022 at 18:01):

bjorn3 commented on issue #3920:

Apologies I can't seem to find where to install clif-util so that I can run clif-util bugpoint.

You can use cd cranelift && cargo run -- bugpoint.

Create the above IR via cranelift_jit and the FunctionBuilder API.

Can you be a bit more specific? Using clif-util compile crash.clif --target aarch64 works fine for me.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 13 2022 at 18:40):

jfecher commented on issue #3920:

Running cargo run -- bugpoint crash.clif aarch64" gives me Warning: Given function compiled successfully or gave a verifier error. I'm assuming it compiled correctly since cargo run -- compile crash.clif --target aarch64` compiles successfully for me. I'll work to try to get a more specific example of how the IR was constructed.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 13 2022 at 20:26):

jfecher commented on issue #3920:

I believe I've discovered/fixed my error. I was calling define_function after _each_ function finished codegen rather than only after all functions have finished codegen. So define_function(u0:0) in the above example was being called before define_function(fn0) or define_function(fn1)

view this post on Zulip Wasmtime GitHub notifications bot (Mar 13 2022 at 20:26):

jfecher closed issue #3920:

.clif Test Case

function u0:0() -> i32 apple_aarch64 {
    sig0 = (i64) -> i64 fast
    sig1 = (i64) -> i64 system_v
    fn0 = colocated u0:2 sig0
    fn1 = u0:3 sig1
    jt0 = jump_table [block3, block4]

block0:
    v0 = iconst.i64 104
    v1 = call fn0(v0)
    v2 = load.i64 v1
    br_table v2, block4, jt0

block3:
    v3 = load.i64 v1+1
    jump block1

block4:
    jump block2

block1:
    v5 = call fn1(v3)
    jump block5(v5)

block2:
    v6 = iconst.i64 0
    jump block5(v6)

block5(v4: i64):
    v7 = iconst.i32 0
    return v7
}

Apologies I can't seem to find where to install clif-util so that I can run clif-util bugpoint.

Steps to Reproduce

Create the above IR via cranelift_jit and the FunctionBuilder API.

Expected Results

Expected the IR to be valid without panicking given that it had passed the cranelift_codegen::verifier::verify_function check.

Actual Results

Panics with:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Compilation(Verifier(VerifierErrors([VerifierError { location: block0, context: None, me
ssage: "cfg had unexpected successor(s) [block3, block4]" }])))', src/cranelift_backend/context.rs:188:14

The line in question is:

module.define_function(function_id, module_context).unwrap();

where module: cranelift_jit::backend::JITModule

Versions and Environment

Cranelift version or commit: 0.82.1

Operating system: Mac OSX 12.2.1

Architecture: arm64

Extra Info

This function IR fails at define_function despite passing the cranelift_codegen::verifier::verify_function check.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 13 2022 at 20:37):

bjorn3 commented on issue #3920:

define_function needs to be called for each individual function. Afterwards the context needs to be cleared using .clear() (or discarded entirely) before codegenning the next function.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 13 2022 at 20:46):

jfecher commented on issue #3920:

Ah, I believe that was the true error then. .clear() wasn't being called after compiling u0:0.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 13 2022 at 20:46):

jfecher edited a comment on issue #3920:

Ah, I believe that was the true error then. .clear() wasn't being called after compiling u0:0. Thanks for your help.


Last updated: Dec 23 2024 at 12:05 UTC