Closed l4l closed 4 years ago
That's called IR, right?
It's called MIR.
It seems that I haven't implemented something regarding Pin<&mut [generator]>
as self(?) arg correctly.
Thank you very much for testing all those crates!
Current repro:
use futures_util::{compat::Future01CompatExt, future::FutureExt};
use std::future::Future;
pub fn spawn(
future: Box<dyn futures_01::Future<Item = (), Error = ()> + Send>,
context: &mut std::task::Context,
) {
let future = future.compat().map(|_| ());
let _ = Box::pin(with(future)).as_mut().poll(context);
}
async fn with(f: impl Future<Output = ()>) {
f.await
}
No external crates:
use std::future::Future;
use std::task::*;
use std::pin::Pin;
pub fn spawn(context: &mut Context) {
let future = Compat01As03;
let _ = Box::pin(with(future)).as_mut().poll(context);
}
pub struct Compat01As03;
impl Future for Compat01As03 {
type Output = ();
fn poll(
self: Pin<&mut Self>,
_cx: &mut Context<'_>,
) -> Poll<Self::Output> {
loop {}
}
}
async fn with(f: impl Future<Output = ()>) {
f.await
}
Minimal repro:
#![feature(generators, generator_trait)]
use std::ops::Generator;
pub fn with() {
Box::pin(move |mut _task_context| {
yield ();
}).as_mut().resume(0);
}
Fixed in eab4c9063ec63bf484347cbd6b21117d336db4a5. I had to sync fn_sig_for_fn_abi with upstream for the generator resume arg support that recently landed in rustc.
This one looks a bit more complicated. Got
entry block parameters (2) must match function signature (1)
for https://github.com/tokio-rs/tokio-compat/commit/180076a0d31f12c19c4a7e0f449487a22a7fea02 (master).rustc_codegen_cranelift: 9f602bf4dae1a86dde890552e3c0c7fa2ca9196f
VerifierErrors
``` error: VerifierErrors([VerifierError { location: block0, context: None, message: "entry block parameters (2) must match function signature (1)" }]) error: cranelift verify error: function u0:6(i64) -> i8 system_v { ss0 = explicit_slot 1 ss1 = explicit_slot 8 ss2 = explicit_slot 8 ss3 = explicit_slot 1 ss4 = explicit_slot 32 ss5 = explicit_slot 1 ss6 = explicit_slot 8 ss7 = explicit_slot 8 ss8 = explicit_slot 1 ss9 = explicit_slot 8 ss10 = explicit_slot 8 ss11 = explicit_slot 8 gv0 = symbol colocated u1:0 gv1 = symbol colocated u1:1 gv2 = symbol colocated u1:0 sig0 = (i64) -> i64 system_v sig1 = (i64, i8) -> i64 system_v sig2 = (i64, i64) system_v sig3 = (i64) -> i64 system_v sig4 = (i64) -> i64 system_v sig5 = (i64, i64) -> i8 system_v sig6 = (i64) system_v sig7 = (i64) system_v sig8 = (i64) system_v sig9 = (i64) system_v fn0 = u0:15 sig0 fn1 = u0:16 sig1 fn2 = u0:17 sig2 fn3 = colocated u0:4 sig3 fn4 = u0:18 sig4 fn5 = u0:19 sig5 fn6 = u0:20 sig6 fn7 = u0:21 sig7 fn8 = u0:20 sig8 fn9 = u0:20 sig9 jt0 = jump_table [block2, block18] jt1 = jump_table [block15, block13] block0(v0: i64, v1: i64): ; ^~~~~~~~~~~~~~~~~~~~~~~~~ ; error: block0: entry block parameters (2) must match function signature (1) nop stack_store v0, ss1 stack_store v1, ss2 jump block1 block1: nop @0000 v2 = stack_load.i64 ss1 @0000 v3 = load.i8 v2+48 @0000 v4 = uextend.i64 v3 @0000 v5 = icmp_imm eq v4, 3 @0000 brnz v5, block17 @0000 jump block20 block20: @0000 br_table.i64 v4, block19, jt0 block2: @0000 nop @0000 v6 = stack_load.i64 ss2 @0000 stack_store v6, ss10 @0001 v7 = stack_load.i64 ss1 @0001 v8 = stack_load.i64 ss1 @0001 v9 = load.i64 v8 @0001 store v9, v7+8 @0002 jump block3 block3: @0002 nop @0005 v10 = stack_load.i64 ss1 @0005 v11 = load.i64 v10+8 @0005 v12 = iadd_imm v11, 8 @0005 v13 = call fn0(v12) v14 -> v13 @0005 jump block4 block4: @0005 nop @0007 v15 = iconst.i8 2 @0007 stack_store v15, ss3 @0004 v16 = stack_load.i8 ss3 @0004 v17 = call fn1(v14, v16) v18 -> v17 @0004 jump block5 block5: @0004 nop @0009 v19 = iconst.i64 0 @0009 v20 = icmp.i64 ne v18, v19 @0009 v21 = bint.i8 v20 @0002 v22 = uextend.i32 v21 @0002 brz v22, block6 @0002 jump block7 block6: @0002 nop @0002 v23 = iconst.i64 8 @000c v24 = iconst.i8 1 @000c stack_store v24, ss0 @000c v25 = stack_load.i64 ss1 @000c v26 = iconst.i8 1 @000c store v26, v25+48 @000c v27 = stack_load.i8 ss0 @000c return v27 block7: @000c nop @000e v28 = stack_load.i64 ss1 @000e v29 = load.i64 v28+8 @000d v30 = stack_addr.i64 ss4 @000d call fn2(v30, v29) @000d jump block8 block8: @000d nop @0010 v31 = stack_load.i64 ss1 @0010 v32 = stack_addr.i64 ss4 @0010 v33 = iadd_imm v31, 16 @0010 v34 = load.i64 aligned v32 @0010 v35 = load.i64 aligned v32+8 @0010 v36 = load.i64 aligned v32+16 @0010 v37 = load.i64 aligned v32+24 @0010 store aligned v34, v33 @0010 store aligned v35, v33+8 @0010 store aligned v36, v33+16 @0010 store aligned v37, v33+24 @0011 jump block9 block9: @0011 nop @0012 v38 = stack_load.i64 ss1 @0012 v39 = iadd_imm v38, 16 @0012 v40 = call fn3(v39) @0012 stack_store v40, ss6 @0012 jump block10 block10: @0012 nop @0012 v41 = stack_load.i64 ss10 @0012 stack_store v41, ss7 @0014 v42 = stack_load.i64 ss7 @0014 v43 = call fn4(v42) v44 -> v43 @0014 jump block11 block11: @0014 nop @0012 v45 = stack_load.i64 ss6 @0012 v46 = call fn5(v45, v44) @0012 stack_store v46, ss5 @0012 jump block12 block12: @0012 nop @0011 v47 = stack_load.i8 ss5 @0011 v48 = iadd_imm v47, -2 @0011 v49 = icmp_imm ule v48, 0 @0011 v50 = iconst.i64 0 @0011 v51 = iadd_imm v50, 1 @0011 v52 = iconst.i64 0 @0011 v53 = select v49, v51, v52 @0011 jump block21 block21: @0011 br_table.i64 v53, block14, jt1 block13: @0011 nop @0011 v54 = iconst.i8 0 @0011 stack_store v54, ss0 @0011 v55 = stack_load.i64 ss1 @0011 v56 = iconst.i8 3 @0011 store v56, v55+48 @0011 v57 = stack_load.i8 ss0 @0011 return v57 block14: @0011 nop @0011 v58 = global_value.i64 gv0 @0011 call fn6(v58) @0011 trap unreachable block15: @0011 nop @0011 v59 = stack_load.i8 ss5 @0011 stack_store v59, ss8 @0018 v60 = stack_load.i64 ss1 @0018 v61 = iadd_imm v60, 16 @0018 stack_store v61, ss11 @0018 v62 = stack_load.i64 ss11 @0018 call fn7(v62) @0018 jump block16 block16: @0018 nop @0002 jump block3 block17: @0002 nop @0000 v63 = stack_load.i64 ss2 @0000 stack_store v63, ss9 @0011 v64 = stack_load.i64 ss9 @0011 stack_store v64, ss10 @0011 jump block9 block18: @0011 nop @0000 v65 = iconst.i8 0 @0000 brz v65, block22 @0000 jump block18 block22: @0000 v66 = global_value.i64 gv1 @0000 call fn8(v66) @0000 trap user0 block19: @0000 nop @0000 v67 = global_value.i64 gv2 @0000 call fn9(v67) @0000 trap unreachable } ; 1 verifier error detected (see above). Compilation aborted. ```That's called IR, right?
``` // WARNING: This output format is intended for human consumers only // and is subject to change without notice. Knock yourself out. fn runtime::idle::