Stream: t-compiler/wg-mir-opt

Topic: Apache Arrow ICE #64908


nikomatsakis (Oct 03 2019 at 14:50, on Zulip):

Hey @Wesley Wiser have you investigated this at all?

nikomatsakis (Oct 03 2019 at 14:51, on Zulip):

I could try to put in some effort to help, prob tomorrow

Wesley Wiser (Oct 03 2019 at 15:38, on Zulip):

Hi @nikomatsakis, I have a few hours this morning to look at it. Investigating now...

Wesley Wiser (Oct 03 2019 at 16:23, on Zulip):

Can you have polymorphic promoted MIR? I thought it had to be monomorphic?

Wesley Wiser (Oct 03 2019 at 16:33, on Zulip):

I guess that's allowed since it's doing the same thing on stable/beta. The call to std::mem::size_of::<T::Native>() gets promoted to

promoted[2] in  new: usize = {
    let mut _0: usize;                   // return place in scope 0 at <::core::macros::assert_eq macros>:3:23: 3:32
    let mut _1: usize;                   // in scope 0 at src/main.rs:6:19: 6:51
    scope 1 {
        scope 2 {
        }
    }

    bb0: {
        _1 = const std::mem::size_of::<<T as ArrowPrimitiveType>::Native>() -> bb1; // bb0[0]: scope 0 at src/main.rs:6:19: 6:51
                                         // ty::Const
                                         // + ty: fn() -> usize {std::mem::size_of::<<T as ArrowPrimitiveType>::Native>}
                                         // + val: Scalar(<ZST>)
                                         // mir::Constant
                                         // + span: src/main.rs:6:19: 6:49
                                         // + user_ty: UserType(0)
                                         // + literal: Const { ty: fn() -> usize {std::mem::size_of::<<T as ArrowPrimitiveType>::Native>}, val: Scalar(<ZST>) }
    }

    bb1: {
        _0 = move _1;                    // bb1[0]: scope 0 at <::core::macros::assert_eq macros>:3:23: 3:32
        return;                          // bb1[1]: scope 0 at <::core::macros::assert_eq macros>:3:23: 3:32
    }
}
Wesley Wiser (Oct 03 2019 at 17:05, on Zulip):

Made some progress. I don't have a solution yet but here's a few things that jump out to me:

- This is the line that's failing because we can't normalize the type. That's not actually needed at this point because we just want to get at Ty.kind which doesn't need to be normalized. Changing this to just call self.tcx.type_of(instance.def_id()) gets us slightly further along.

- The next thing that fails is this where we actually try to call the intrinsic. What's interesting is that M is not ConstPropMachine which bails out of running intrinsics but a CompileTimeInterpreter which will try to eval intrinsics. I believe this is happening because InterpCx::eval_static_to_mplace() calls self.tcx.const_eval_raw() regardless of what the M: Machine is on our context. That seems fishy to me.

Wesley Wiser (Oct 03 2019 at 17:05, on Zulip):

cc @nikomatsakis ^^

Wesley Wiser (Oct 03 2019 at 17:06, on Zulip):

We may be able to fix this by throw_inval!(TooGeneric) at the right place

Wesley Wiser (Oct 03 2019 at 17:06, on Zulip):

Where ever that is... :laughing:

Wesley Wiser (Oct 03 2019 at 17:48, on Zulip):

I have a fix assuming @oli approves :)
https://github.com/rust-lang/rust/pull/65066

Last update: Nov 17 2019 at 07:15UTC