Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICE: ../src/librustc_trans/mir/operand.rs:82: impossible case reached while using inline assembly #37437

Closed
SethDusek opened this issue Oct 27, 2016 · 6 comments
Labels
A-inline-assembly Area: inline asm!(..) C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@SethDusek
Copy link

So I was messing around with inline assembly and sse, when I tried doing this

#![feature(asm)]

fn xor_buf(buf: [u32; 4], buf2: [u32; 4]) {
    let res: [u32; 4];
    unsafe { asm!("
        movaps xmm0, 1
        xorps xmm0, 2
        movaps 1, xmm0":"=r"(res):"a"(buf), "b"(buf):"xmm0":"intel") };
}

And instead of the expected result I got this

error: internal compiler error: ../src/librustc_trans/mir/operand.rs:82: impossible case reached

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

thread 'rustc' panicked at 'Box<Any>', ../src/librustc_errors/lib.rs:655
note: Run with `RUST_BACKTRACE=1` for a backtrace.

You can run it yourself here https://is.gd/VmN4SF

@TimNN TimNN added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ A-inline-assembly Area: inline asm!(..) labels Oct 28, 2016
@nagisa
Copy link
Member

nagisa commented Oct 28, 2016

stack backtrace:
   1:     0x7fd8d02ee03f - std::sys::backtrace::tracing::imp::write::h22f199c1dbb72ba2
   2:     0x7fd8d02fd59d - std::panicking::default_hook::{{closure}}::h9a389c462b6a22dd
   3:     0x7fd8d02fa9c6 - std::panicking::default_hook::h852b4223c1c00c59
   4:     0x7fd8d02fb0a8 - std::panicking::rust_panic_with_hook::hcd9d05f53fa0dafc
   5:     0x7fd8cc746657 - std::panicking::begin_panic::h2f463d37998ebeba
   6:     0x7fd8cc756578 - rustc_errors::Handler::bug::haca77c19c882b432
   7:     0x7fd8cd7b934a - rustc::session::opt_span_bug_fmt::{{closure}}::hfeb850fbe828b399
   8:     0x7fd8cd6f2ee5 - rustc::session::opt_span_bug_fmt::h46e45438a860a75e
   9:     0x7fd8cd6f2d22 - rustc::session::bug_fmt::hde22f071bf5a80ea
  10:     0x7fd8cee95910 - <collections::vec::Vec<T> as core::iter::traits::FromIterator<T>>::from_iter::hc5cbb62358ceb057
  11:     0x7fd8cef3b64f - rustc_trans::mir::rvalue::<impl rustc_trans::mir::MirContext<'bcx, 'tcx>>::trans_rvalue::h2a14de75e2fd4285
  12:     0x7fd8cef29969 - rustc_trans::mir::block::<impl rustc_trans::mir::MirContext<'bcx, 'tcx>>::trans_block::he67d3259f79e4177
  13:     0x7fd8cef27c58 - rustc_trans::mir::trans_mir::h2fb44ecb31cfdffa
  14:     0x7fd8ceec7b83 - rustc_trans::base::trans_closure::h941de14309416d66
  15:     0x7fd8cef47cd4 - rustc_trans::trans_item::TransItem::define::h2e690ccd1ee22f95
  16:     0x7fd8ceecb07a - rustc_trans::base::trans_crate::h9b06de31ed8799d1
  17:     0x7fd8d06827ed - rustc_driver::driver::phase_4_translate_to_llvm::hc3883ea2c4750179
  18:     0x7fd8d06ba8b5 - rustc_driver::driver::compile_input::{{closure}}::h9162a2fa292aeb3f
  19:     0x7fd8d06b1bb7 - rustc_driver::driver::phase_3_run_analysis_passes::{{closure}}::h1928c4704cfe9c61
  20:     0x7fd8d0680224 - rustc_driver::driver::phase_3_run_analysis_passes::he578df6b8805151c
  21:     0x7fd8d0667bfb - rustc_driver::driver::compile_input::h5b63ccd49eeeb98b
  22:     0x7fd8d06931da - rustc_driver::run_compiler::h98c7274e7cb1d11d
  23:     0x7fd8d05cfe0b - std::panicking::try::do_call::h99ed0da044e497c3
  24:     0x7fd8d0305496 - __rust_maybe_catch_panic
  25:     0x7fd8d05ed951 - <F as alloc::boxed::FnBox<A>>::call_box::hbdd5a14cd8e33b97
  26:     0x7fd8d02f9420 - std::sys::thread::Thread::new::thread_start::h50b05608a499d2b2
  27:     0x7fd8c85e2453 - start_thread
  28:     0x7fd8cffc97de - __GI___clone
  29:                0x0 - <unknown>

@cbiffle
Copy link
Contributor

cbiffle commented Oct 28, 2016

I believe this is the same issue as #37433, which happens when a non-scalar is passed as an input operand. You probably want to be passing pointers instead of buf and res directly, e.g. &buf as *const u32.

@aidanhs
Copy link
Member

aidanhs commented Dec 8, 2016

Small example with same error as top comment (yes, this is invalid):

#![feature(asm)]
fn main() {
    unsafe { asm!("" : : "i"("hello")) };
}

@istankovic
Copy link
Contributor

Still reproducible with rustc 1.26.0-nightly (adf2135ad 2018-03-17).

@levex
Copy link
Contributor

levex commented Oct 12, 2018

No longer reproduces:

$ rustc +nightly -vV
rustc 1.31.0-nightly (77af31408 2018-10-11)
binary: rustc
commit-hash: 77af314083e5acabf9ba5335e47271f35eef2e99
commit-date: 2018-10-11
host: x86_64-unknown-linux-gnu
release: 1.31.0-nightly
LLVM version: 8.0
$ rustc +nightly 37437.rs 
error[E0669]: invalid value for constraint in inline assembly
 --> 37437.rs:4:14
  |
4 |     unsafe { asm!("" : : "i"(hello)) };
  |              ^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0669`.

@estebank
Copy link
Contributor

There's already a similar test for this case. CC #53787.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-inline-assembly Area: inline asm!(..) C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

9 participants