Closed
Description
Code
The following code segfaults when compiled (rustc asm-avx.rs -C target-cpu=native
)
#![feature(asm)]
use std::alloc;
#[cfg(target_feature = "avx")]
fn main() {
unsafe {
let layout = alloc::Layout::from_size_align_unchecked(32, 32);
let mem = alloc::alloc_zeroed(layout);
asm!(
"vmovdqa ymm0, [{source}]",
source = in(reg) mem,
out("ymm0") _,
);
}
}
Omitting (incorrectly) the register for the inputs and outputs does not cause a segfault.
#![feature(asm)]
use std::alloc;
#[cfg(target_feature = "avx")]
fn main() {
unsafe {
let layout = alloc::Layout::from_size_align_unchecked(32, 32);
let mem = alloc::alloc_zeroed(layout);
asm!(
"vmovdqa ymm0, [{source}]",
source = in(reg) mem,
);
}
}
xmm
registers work fine even when they appear in outputs.
#![feature(asm)]
use std::alloc;
fn main() {
unsafe {
let layout = alloc::Layout::from_size_align_unchecked(16, 16);
let mem = alloc::alloc_zeroed(layout);
asm!(
"movdqa xmm0, [{source}]",
source = in(reg) mem,
out("xmm0") _,
);
}
}
Meta
rustc --version --verbose
:
rustc 1.47.0-nightly (8ad7bc3f4 2020-07-21)
binary: rustc
commit-hash: 8ad7bc3f428300aee6764f6e23527e19eb235e81
commit-date: 2020-07-21
host: x86_64-apple-darwin
release: 1.47.0-nightly
LLVM version: 10.0
Error output
There is no output, rustc
segfaults before emitting any.