-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Segmentation fault during optimization pass with aarch64 simd #84020
Comments
@nagisa filed https://bugs.llvm.org/show_bug.cgi?id=49867 with the reduced LLVM IR from rustc, but I was only able to reproduce the segfault from rust with SIMD intrinsics with 64-length vectors, so I wonder if we have two separate bugs in the optimizer. |
Yeah, those are two distinct issues. The reproduction steps provided in the thread here resulted in a different crash in the first place. I was not able to reproduce this. In order for that to happen the reproducer probably should be made much more self contained – no cargo, no |
Unfortunately I was not able to reproduce it without cargo test. I'm sure there's a way, but anything I wrote that looked like this example but outside of a test function did not crash. Perhaps tests have some subtle difference from say a simple executable that affects codegen (or maybe linking/LTO) in some way? |
Code example extracted from comment [1]. [1]: rust-lang/rust#84020 (comment)
Does this still happen? |
It no longer appears to happen since the LLVM 13 upgrade #87570 |
I attempted to add the following test but couldn't get it to ICE on commit 138fd56 (the one OP reported the ICE on). I copied the compiler flags from rust-lang/glacier#954. Maybe somebody can figure out what I did wrong.
// edition: 2018
// compile-flags: --emit=dep-info,link -C opt-level=3 -C embed-bitcode=no --test -C metadata=1974b6bb1d213572 -C extra-filename=-1974b6bb1d213572 --target aarch64-apple-darwin
#![feature(const_generics, platform_intrinsics, repr_simd)]
#![allow(incomplete_features)]
extern "platform-intrinsic" {
fn simd_eq<T, U>(a: T, b: T) -> U;
fn simd_and<T>(a: T, b: T) -> T;
}
#[derive(Copy, Clone)]
#[repr(simd)]
pub struct F<const N: usize>([f32; N]);
impl<const N: usize> F<N> {
pub fn splat(value: f32) -> Self {
Self([value; N])
}
pub fn eq(self, other: Self) -> I<N> {
unsafe { simd_eq(self, other) }
}
}
#[repr(simd)]
pub struct I<const N: usize>([i32; N]);
impl<const N: usize> core::ops::BitAnd for I<N> {
type Output = Self;
fn bitand(self, other: Self) -> Self {
unsafe { simd_and(self, other) }
}
}
impl<const N: usize> I<N> {
pub fn to_array(self) -> [bool; N] {
let mut array = [false; N];
let mut i = 0;
while i < N {
array[i] = self.0[i] == -1;
i += 1;
}
array
}
}
#[cfg(test)]
mod test {
use super::*;
#[test]
fn bug() {
let a = F::<64>::splat(0.);
let b = F::<64>::splat(0.);
let c = F::<64>::splat(0.);
let m = a.eq(b) & a.eq(c);
assert!(m.to_array()[0]);
}
} |
This lacks a clear reproducer, is mainly a bug in LLVM (not Rust), and apparently no longer happens. I am willing to leave this open for a while longer but it's a clear heisenbug that has questionable value on the tracker. I am leaving this note here for a future triage: if it hasn't gained an MCVE or test, maybe we should just chalk this issue up to the persistent tendency towards entropy in the universe and close it? |
Probably best to file an issue for this and get it fixed /s |
The following code seg faults during optimization. I've produced it on both macOS and Linux.
Discussions:
https://rust-lang.zulipchat.com/#narrow/stream/257879-project-portable-simd/topic/2021-03-29.20Meeting
https://rust-lang.zulipchat.com/#narrow/stream/257879-project-portable-simd/topic/Aarch64.20LLVM.20bug
https://rust-lang.zulipchat.com/#narrow/stream/187780-t-compiler.2Fwg-llvm/topic/Debugging.20segfault.20in.20LLVM
Code
Meta
rustc --version --verbose
:Error output
Backtrace
Backtrace from https://rust-lang.zulipchat.com/#narrow/stream/257879-project-portable-simd/topic/2021-03-29.20Meeting/near/232369790
The text was updated successfully, but these errors were encountered: