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: None, asm #1428

Closed
matthiaskrgr opened this issue Nov 21, 2023 · 1 comment · Fixed by #1481
Closed

ice: None, asm #1428

matthiaskrgr opened this issue Nov 21, 2023 · 1 comment · Fixed by #1481
Labels
C-bug Category: This is a bug.

Comments

@matthiaskrgr
Copy link
Member

auto-reduced (treereduce-rust):

#![crate_type = "rlib"]

use std::arch::asm;
use std::mem::MaybeUninit;

pub unsafe fn inout(mut x: i32) -> MaybeUninit<i32> {
    let y: MaybeUninit<i32>;
    asm!("/*{}{}*/", in(reg) x, out(reg) y);
    y
}

original:

// compile-flags: -O
// only-x86_64

#![crate_type = "rlib"]
#![allow(asm_sub_register)]

use std::mem::MaybeUninit;
use std::arch::asm;

// CHECK-LABEL: @int
#[no_mangle]
pub unsafe fn int(x: MaybeUninit<i32>) -> MaybeUninit<i32> {
    let y: MaybeUninit<i32>;
    asm!("/*{}{}*/", in(reg) x, out(reg) y);
    y
}

// CHECK-LABEL: @inout
#[no_mangle]
pub unsafe fn inout(mut x: i32) -> MaybeUninit<i32> {
    let y: MaybeUninit<i32>;
    asm!("/*{}{}*/", in(reg) x, out(reg) y);
    y
}

Version information

rustc 1.76.0-nightly (e24e5af78 2023-11-21)
binary: rustc
commit-hash: e24e5af787f7015914cbf316063ed5821f370b71
commit-date: 2023-11-21
host: x86_64-unknown-linux-gnu
release: 1.76.0-nightly
LLVM version: 17.0.5

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zcodegen-backend=cranelift

Program output

warning: formatting may not be suitable for sub-register argument
 --> /tmp/icemaker_global_tempdir.Tt4eJle1ugDg/rustc_testrunner_tmpdir_reporting.vPTLPZ3IgX7I/mvce.rs:8:13
  |
8 |     asm!("/*{}{}*/", in(reg) x, out(reg) y);
  |             ^^               - for this argument
  |
  = help: use `{0:e}` to have the register formatted as `eax`
  = help: or use `{0:r}` to keep the default formatting of `rax`
  = note: `#[warn(asm_sub_register)]` on by default

warning: formatting may not be suitable for sub-register argument
 --> /tmp/icemaker_global_tempdir.Tt4eJle1ugDg/rustc_testrunner_tmpdir_reporting.vPTLPZ3IgX7I/mvce.rs:8:15
  |
8 |     asm!("/*{}{}*/", in(reg) x, out(reg) y);
  |               ^^                         - for this argument
  |
  = help: use `{1:e}` to have the register formatted as `eax`
  = help: or use `{1:r}` to keep the default formatting of `rax`

warning: variable does not need to be mutable
 --> /tmp/icemaker_global_tempdir.Tt4eJle1ugDg/rustc_testrunner_tmpdir_reporting.vPTLPZ3IgX7I/mvce.rs:6:21
  |
6 | pub unsafe fn inout(mut x: i32) -> MaybeUninit<i32> {
  |                     ----^
  |                     |
  |                     help: remove this `mut`
  |
  = note: `#[warn(unused_mut)]` on by default

thread 'rustc' panicked at src/inline_asm.rs:764:45:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0:     0x7f0ae758aafc - std::backtrace_rs::backtrace::libunwind::trace::h0b040baf97a1a814
                               at /rustc/e24e5af787f7015914cbf316063ed5821f370b71/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7f0ae758aafc - std::backtrace_rs::backtrace::trace_unsynchronized::h3bb4f35c883ef0b7
                               at /rustc/e24e5af787f7015914cbf316063ed5821f370b71/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f0ae758aafc - std::sys_common::backtrace::_print_fmt::h7bc4c6c40e2dea38
                               at /rustc/e24e5af787f7015914cbf316063ed5821f370b71/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7f0ae758aafc - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::ha29c192b6f9a05c7
                               at /rustc/e24e5af787f7015914cbf316063ed5821f370b71/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f0ae75ddc80 - core::fmt::rt::Argument::fmt::hd5d7e2c681722c4a
                               at /rustc/e24e5af787f7015914cbf316063ed5821f370b71/library/core/src/fmt/rt.rs:142:9
   5:     0x7f0ae75ddc80 - core::fmt::write::h44f28bd6729c28a7
                               at /rustc/e24e5af787f7015914cbf316063ed5821f370b71/library/core/src/fmt/mod.rs:1120:17
   6:     0x7f0ae757e91f - std::io::Write::write_fmt::h34e80b21f77f27fe
                               at /rustc/e24e5af787f7015914cbf316063ed5821f370b71/library/std/src/io/mod.rs:1762:15
   7:     0x7f0ae758a8e4 - std::sys_common::backtrace::_print::hf6fce87ec4803f0c
                               at /rustc/e24e5af787f7015914cbf316063ed5821f370b71/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f0ae758a8e4 - std::sys_common::backtrace::print::h2c7cd590dc94a621
                               at /rustc/e24e5af787f7015914cbf316063ed5821f370b71/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f0ae758d577 - std::panicking::default_hook::{{closure}}::ha2265235df34f52e
  10:     0x7f0ae758d2df - std::panicking::default_hook::ha134722f286c6b3a
                               at /rustc/e24e5af787f7015914cbf316063ed5821f370b71/library/std/src/panicking.rs:292:9
  11:     0x7f0aea2f42b0 - std[9e66bc0d43e7428]::panicking::update_hook::<alloc[6053f7fa92048905]::boxed::Box<rustc_driver_impl[6d46853ed3c470a0]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f0ae758dcb8 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h3506115e7630eb0e
                               at /rustc/e24e5af787f7015914cbf316063ed5821f370b71/library/alloc/src/boxed.rs:2021:9
  13:     0x7f0ae758dcb8 - std::panicking::rust_panic_with_hook::h7694bf37e5dc3efe
                               at /rustc/e24e5af787f7015914cbf316063ed5821f370b71/library/std/src/panicking.rs:783:13
  14:     0x7f0ae758d9d9 - std::panicking::begin_panic_handler::{{closure}}::h2dd4c764b0c8af53
                               at /rustc/e24e5af787f7015914cbf316063ed5821f370b71/library/std/src/panicking.rs:649:13
  15:     0x7f0ae758afc6 - std::sys_common::backtrace::__rust_end_short_backtrace::h7c23b4f1d73ba22d
                               at /rustc/e24e5af787f7015914cbf316063ed5821f370b71/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7f0ae758d772 - rust_begin_unwind
                               at /rustc/e24e5af787f7015914cbf316063ed5821f370b71/library/std/src/panicking.rs:645:5
  17:     0x7f0ae75da365 - core::panicking::panic_fmt::hc4f69c74680b17c4
                               at /rustc/e24e5af787f7015914cbf316063ed5821f370b71/library/core/src/panicking.rs:72:14
  18:     0x7f0ae75da403 - core::panicking::panic::hafadf320ec949d41
                               at /rustc/e24e5af787f7015914cbf316063ed5821f370b71/library/core/src/panicking.rs:127:5
  19:     0x7f0addc2b6cf - rustc_codegen_cranelift[5ecdc7bd26b881e3]::inline_asm::codegen_inline_asm_inner
  20:     0x7f0addc031fd - rustc_codegen_cranelift[5ecdc7bd26b881e3]::base::codegen_fn_body
  21:     0x7f0addc17934 - rustc_codegen_cranelift[5ecdc7bd26b881e3]::driver::aot::module_codegen::{closure#0}
  22:     0x7f0addc14c45 - rustc_codegen_cranelift[5ecdc7bd26b881e3]::driver::aot::module_codegen
  23:     0x7f0addc2124c - rustc_codegen_cranelift[5ecdc7bd26b881e3]::driver::aot::run_aot
  24:     0x7f0addc4d59a - <rustc_codegen_cranelift[5ecdc7bd26b881e3]::CraneliftCodegenBackend as rustc_codegen_ssa[701c7bd28a7a1232]::traits::backend::CodegenBackend>::codegen_crate
  25:     0x7f0aebf669d7 - rustc_interface[79d196cce7f623b3]::passes::start_codegen
  26:     0x7f0aebf66399 - <rustc_interface[79d196cce7f623b3]::queries::Queries>::ongoing_codegen
  27:     0x7f0aec6136c7 - rustc_interface[79d196cce7f623b3]::interface::run_compiler::<core[4409ec5cd92597ed]::result::Result<(), rustc_span[433598ff900853dd]::ErrorGuaranteed>, rustc_driver_impl[6d46853ed3c470a0]::run_compiler::{closure#0}>::{closure#0}
  28:     0x7f0aec5a3054 - std[9e66bc0d43e7428]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[79d196cce7f623b3]::util::run_in_thread_with_globals<rustc_interface[79d196cce7f623b3]::util::run_in_thread_pool_with_globals<rustc_interface[79d196cce7f623b3]::interface::run_compiler<core[4409ec5cd92597ed]::result::Result<(), rustc_span[433598ff900853dd]::ErrorGuaranteed>, rustc_driver_impl[6d46853ed3c470a0]::run_compiler::{closure#0}>::{closure#0}, core[4409ec5cd92597ed]::result::Result<(), rustc_span[433598ff900853dd]::ErrorGuaranteed>>::{closure#0}, core[4409ec5cd92597ed]::result::Result<(), rustc_span[433598ff900853dd]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[4409ec5cd92597ed]::result::Result<(), rustc_span[433598ff900853dd]::ErrorGuaranteed>>
  29:     0x7f0aec5a2e7d - <<std[9e66bc0d43e7428]::thread::Builder>::spawn_unchecked_<rustc_interface[79d196cce7f623b3]::util::run_in_thread_with_globals<rustc_interface[79d196cce7f623b3]::util::run_in_thread_pool_with_globals<rustc_interface[79d196cce7f623b3]::interface::run_compiler<core[4409ec5cd92597ed]::result::Result<(), rustc_span[433598ff900853dd]::ErrorGuaranteed>, rustc_driver_impl[6d46853ed3c470a0]::run_compiler::{closure#0}>::{closure#0}, core[4409ec5cd92597ed]::result::Result<(), rustc_span[433598ff900853dd]::ErrorGuaranteed>>::{closure#0}, core[4409ec5cd92597ed]::result::Result<(), rustc_span[433598ff900853dd]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[4409ec5cd92597ed]::result::Result<(), rustc_span[433598ff900853dd]::ErrorGuaranteed>>::{closure#1} as core[4409ec5cd92597ed]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  30:     0x7f0ae7597b75 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::he2fe898dabd7bf63
                               at /rustc/e24e5af787f7015914cbf316063ed5821f370b71/library/alloc/src/boxed.rs:2007:9
  31:     0x7f0ae7597b75 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h2e31e36ca472739b
                               at /rustc/e24e5af787f7015914cbf316063ed5821f370b71/library/alloc/src/boxed.rs:2007:9
  32:     0x7f0ae7597b75 - std::sys::unix::thread::Thread::new::thread_start::h72b7daa856b881db
                               at /rustc/e24e5af787f7015914cbf316063ed5821f370b71/library/std/src/sys/unix/thread.rs:108:17
  33:     0x7f0ae73889eb - <unknown>
  34:     0x7f0ae740c7cc - <unknown>
  35:                0x0 - <unknown>

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

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.76.0-nightly (e24e5af78 2023-11-21) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z codegen-backend=cranelift -Z dump-mir-dir=dir

query stack during panic:
end of query stack
warning: 3 warnings emitted


@bjorn3
Copy link
Member

bjorn3 commented Nov 21, 2023

I didn't know MaybeUninit was allowed as asm operand.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants