rust-lang / rustc_codegen_cranelift

Cranelift based backend for rustc
Apache License 2.0
1.52k stars 94 forks source link

Field access on vector types crashes #1318

Closed bjorn3 closed 1 year ago

bjorn3 commented 1 year ago

This causes the src/test/ui/simd/intrinsic/generic-as.rs test to fail.

#![feature(repr_simd)]

#[derive(Copy, Clone)]
#[repr(simd)]
struct V([f64; 2]);

fn main() {
    unsafe {
        let f = V([f64::MIN, f64::MAX]);
        let _a = f.0[0];
    }
}
error: internal compiler error: src/value_and_place.rs:472:48: Expected CPlace::Addr, found CPlace { inner: Var(_1, var0), layout: TyAndLayout { ty: [f64; 2], layout: Layout { size: Size(16 bytes), align: AbiAndPrefAlign { abi: Align(8 bytes), pref: Align(8 bytes) }, abi: Aggregate { sized: true }, fields: Array { stride: Size(8 bytes), count: 2 }, largest_niche: None, variants: Single { index: 0 } } } }

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/37d7de337903a558dbeb1e82c844fe915ab8ff25/compiler/rustc_errors/src/lib.rs:1576:9
stack backtrace:
   0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
   1: std::panic::panic_any::<rustc_errors::ExplicitBug>
   2: <rustc_errors::HandlerInner>::bug::<&alloc::string::String>
   3: <rustc_errors::Handler>::bug::<&alloc::string::String>
   4: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_opt<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, ()>::{closure#0}, ()>
   5: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>
   6: rustc_middle::util::bug::bug_fmt
   7: rustc_codegen_cranelift::value_and_place::CPlace::place_index
   8: rustc_codegen_cranelift::base::codegen_place
   9: rustc_codegen_cranelift::base::codegen_fn_body
bjorn3 commented 1 year ago

This is now fixed. I think by https://github.com/bjorn3/rustc_codegen_cranelift/commit/5bf5153d0051d05d9f5e85f76327cb70a2666049.