Stream: git-cranelift

Topic: cranelift / Issue #1326 Indirect call instruction encoding


view this post on Zulip GitHub (Jan 09 2020 at 00:26):

tathanhdinh opened Issue #1326:

Hello all,
I'm still not yet familiar with cranelift, sorry if the question is trivial.

In my toy C compiler, after generating the following function

function u0:0(i32) -> i32 system_v {
    sig0 = (i32, i64) -> i32 system_v
    sig1 = (i32) -> i32 system_v
    fn0 = colocated u0:0 sig1

ebb0(v0: i32):
    v10 -> v0
    v8 = iconst.i32 0
    v6 -> v8
    v7 -> v8
    jump ebb1

ebb1:
    v1 = func_addr.i64 fn0
    v2 = imul.i32 v0, v0
    v3 = iadd_imm v2, 1
    v4 = imul.i32 v0, v2
    br_icmp ne v3, v4, ebb2
    jump ebb3

ebb3:
    v5 = call_indirect.i32 sig0, v0(v0, v1)
    jump ebb2

ebb2:
    v9 = iconst.i32 1
    v11 = iadd.i32 v10, v9
    return v11
}

then module.define_function(...) crashes with:

Compilation(Verifier(VerifierErrors([VerifierError { location: inst7, context: Some("v5 = call_indirect.i32 sig0, v0(v0, v1)"), message: "Call must have an encoding" }])))

I still don't understand why this error occurs, does it mean call_indirect needs an encoding? so how can I set the encoding for the instruction?

Many thanks for any response.

view this post on Zulip GitHub (Jan 09 2020 at 00:26):

tathanhdinh labeled Issue #1326:

Hello all,
I'm still not yet familiar with cranelift, sorry if the question is trivial.

In my toy C compiler, after generating the following function

function u0:0(i32) -> i32 system_v {
    sig0 = (i32, i64) -> i32 system_v
    sig1 = (i32) -> i32 system_v
    fn0 = colocated u0:0 sig1

ebb0(v0: i32):
    v10 -> v0
    v8 = iconst.i32 0
    v6 -> v8
    v7 -> v8
    jump ebb1

ebb1:
    v1 = func_addr.i64 fn0
    v2 = imul.i32 v0, v0
    v3 = iadd_imm v2, 1
    v4 = imul.i32 v0, v2
    br_icmp ne v3, v4, ebb2
    jump ebb3

ebb3:
    v5 = call_indirect.i32 sig0, v0(v0, v1)
    jump ebb2

ebb2:
    v9 = iconst.i32 1
    v11 = iadd.i32 v10, v9
    return v11
}

then module.define_function(...) crashes with:

Compilation(Verifier(VerifierErrors([VerifierError { location: inst7, context: Some("v5 = call_indirect.i32 sig0, v0(v0, v1)"), message: "Call must have an encoding" }])))

I still don't understand why this error occurs, does it mean call_indirect needs an encoding? so how can I set the encoding for the instruction?

Many thanks for any response.

view this post on Zulip GitHub (Jan 09 2020 at 00:30):

tathanhdinh edited Issue #1326:

Hello all,
I'm still not yet familiar with cranelift, sorry if the question is trivial.

In my toy C compiler, after generating the following function

function u0:0(i32) -> i32 system_v {
    sig0 = (i32, i64) -> i32 system_v
    sig1 = (i32) -> i32 system_v
    fn0 = colocated u0:0 sig1

ebb0(v0: i32):
    v10 -> v0
    v8 = iconst.i32 0
    v6 -> v8
    v7 -> v8
    jump ebb1

ebb1:
    v1 = func_addr.i64 fn0
    v2 = imul.i32 v0, v0
    v3 = iadd_imm v2, 1
    v4 = imul.i32 v0, v2
    br_icmp ne v3, v4, ebb2
    jump ebb3

ebb3:
    v5 = call_indirect.i32 sig0, v0(v0, v1)
    jump ebb2

ebb2:
    v9 = iconst.i32 1
    v11 = iadd.i32 v10, v9
    return v11
}

then module.define_function(...) crashes with:

Compilation(Verifier(VerifierErrors([VerifierError { location: inst7, context: Some("v5 = call_indirect.i32 sig0, v0(v0, v1)"), message: "Call must have an encoding" }])))

I still don't understand why this error occurs, does it mean call_indirect need an encoding? so how can I set the encoding for the instruction?

Many thanks for any response.

view this post on Zulip GitHub (Jan 09 2020 at 00:43):

tathanhdinh commented on Issue #1326:

I found it, v0 must be a pointer type.

view this post on Zulip GitHub (Jan 09 2020 at 00:43):

tathanhdinh closed Issue #1326:

Hello all,
I'm still not yet familiar with cranelift, sorry if the question is trivial.

In my toy C compiler, after generating the following function

function u0:0(i32) -> i32 system_v {
    sig0 = (i32, i64) -> i32 system_v
    sig1 = (i32) -> i32 system_v
    fn0 = colocated u0:0 sig1

ebb0(v0: i32):
    v10 -> v0
    v8 = iconst.i32 0
    v6 -> v8
    v7 -> v8
    jump ebb1

ebb1:
    v1 = func_addr.i64 fn0
    v2 = imul.i32 v0, v0
    v3 = iadd_imm v2, 1
    v4 = imul.i32 v0, v2
    br_icmp ne v3, v4, ebb2
    jump ebb3

ebb3:
    v5 = call_indirect.i32 sig0, v0(v0, v1)
    jump ebb2

ebb2:
    v9 = iconst.i32 1
    v11 = iadd.i32 v10, v9
    return v11
}

then module.define_function(...) crashes with:

Compilation(Verifier(VerifierErrors([VerifierError { location: inst7, context: Some("v5 = call_indirect.i32 sig0, v0(v0, v1)"), message: "Call must have an encoding" }])))

I still don't understand why this error occurs, does it mean call_indirect need an encoding? so how can I set the encoding for the instruction?

Many thanks for any response.


Last updated: Nov 22 2024 at 16:03 UTC