Closed
Description
Take the following code:
#![feature(asm)]
pub fn boot(addr: Option<u32>) {
unsafe {
asm!(
"mov sp, $0"
:
: "r" (addr)
);
}
}
Attempting to compile this results in the following:
$ cargo build
Compiling ice v0.1.0 (file:///home/alex/code/ice)
error: internal compiler error: librustc_codegen_llvm/mir/operand.rs:145: not immediate: OperandRef(Pair((i32: %7 = load i32, i32* %6, align 4, !dbg !29, !range !31), (i32: %9 = load i32, i32* %8, align 4, !dbg !29)) @ TyLayout { ty: std::option::Option<u32>, details: LayoutDetails { variants: Tagged { tag: Scalar { value: Int(I32, false), valid_range: 0..=1 }, variants: [LayoutDetails { variants: Single { index: 0 }, fields: Arbitrary { offsets: [], memory_index: [] }, abi: Aggregate { sized: true }, align: Align { abi_pow2: 0, pref_pow2: 3 }, size: Size { raw: 4 } }, LayoutDetails { variants: Single { index: 1 }, fields: Arbitrary { offsets: [Size { raw: 4 }], memory_index: [0] }, abi: Aggregate { sized: true }, align: Align { abi_pow2: 2, pref_pow2: 3 }, size: Size { raw: 8 } }] }, fields: Arbitrary { offsets: [Size { raw: 0 }], memory_index: [0] }, abi: ScalarPair(Scalar { value: Int(I32, false), valid_range: 0..=1 }, Scalar { value: Int(I32, false), valid_range: 0..=4294967295 }), align: Align { abi_pow2: 2, pref_pow2: 3 }, size: Size { raw: 8 } } })
thread 'main' panicked at 'Box<Any>', librustc_errors/lib.rs:587:9
note: Run with `RUST_BACKTRACE=1` for a backtrace.
error: aborting due to previous error
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
note: rustc 1.30.0-nightly (fc81e3624 2018-09-07) running on x86_64-unknown-linux-gnu
note: compiler flags: -C debuginfo=2 -C incremental --crate-type lib
note: some of the compiler flags provided by cargo are hidden
error: Could not compile `ice`.
I think the compiler should fail with something along the lines of "you attempted to use a complex type (Option<u32>
) where I expected an immediate".
Metadata
Metadata
Assignees
Labels
Area: Inline assembly (`asm!(…)`)Category: This is a bug.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Relevant to the compiler team, which will review and decide on the PR/issue.This issue requires a nightly compiler in some way.