Building the MIPS MSA module for non-fp64 targets fails with an LLVM
error. This commit blacklists PSP targets from MSA support in order to
fix building libcore.
* Manually preserve rbx across cpuid instruction
This fixes an issue observed when using __cpuid and __cpuid_count with
Address Sanitizer enabled: the generated code uses the rbx register to
access ASAN tracking information without reloading it after cpuid,
resulting in a segfault since the rbx register is overwritten by cpuid
(https://crbug.com/1072045).
This seems like a compiler backend bug, and indeed there is a
long-standing LLVM bug report about a very similar issue:
https://bugs.llvm.org/show_bug.cgi?id=17907
To work around this issue, we can manually preserve the rbx register
contents in the inline assembly. This is the approach taken by LLVM's
own host cpuid detection code (lib/Host/Support.cpp). The original rbx
value is stashed in rsi, which is then swapped with rbx to restore the
original value as well as keep the output ebx value from the CPUID
instruction to be used as an output of the inline assembly.
The rbx clobber is also removed; this seems ineffective, and it
conflicts with the ebx output of the inline assembly (ebx is a
subregister of rbx): "Note that clobbering named registers that are also
present in output constraints is not legal."
(https://llvm.org/docs/LangRef.html#clobber-constraints)
* Add link to LLVM bug in cpuid workaround comment
error[E0432]: unresolved import `self::arm::check_for`
--> src/libstd/../stdarch/crates/std_detect/src/detect/os/freebsd/mod.rs:11:17
|
11 | pub use self::arm::check_for;
| ^^^^^^^^^^^^^^^^^^^^ no `check_for` in `std_detect::detect::os::arm`
error[E0425]: cannot find value `detect_features` in module `self::os`
--> src/libstd/../stdarch/crates/std_detect/src/detect/mod.rs:121:37
|
121 | cache::test(x as u32, self::os::detect_features)
| ^^^^^^^^^^^^^^^ not found in `self::os`
|
help: possible candidate is found in another module, you can import it into scope
|
20 | use crate::std_detect::detect::os::arm::detect_features;
* re-stabilize the AVX-512 features that were stabilized in Rust 1.27.0
https://github.com/rust-lang/stdarch/pull/739 added per-feature
stabilization of runtime CPU feature detection. In so doing, it
de-stabilized some detection features that had been stable since Rust
1.27.0, breaking some published crates (on nightly). This commit
re-stabilizes the subset of AVX-512 detection features that were
included in 1.27.0 (that is, the pre-Ice-Lake subset). Other instruction
sets (MMX in particular) remain de-stabilized, pending a decision about
whether should ever stabilize them.
See https://github.com/rust-lang/rust/issues/68905.
* add a comment explaining feature detection stability
* adjust stabilizations to match most recent proposal
https://github.com/rust-lang/rust/issues/68905#issuecomment-595376319
* Fix race condition in feature cache on 32 platforms
If we observe that the second word is initialized, we can't really
assume that the first is initialized as well. So check each word
separately.
* Use stronger atomic ordering
Better SeqCst than sorry!
* Use two caches on x64 for simplicity
These are needed for rustc to be able to correctly handle stability of constness of intrinsics. Without either `rustc_const_unstable` or `rustc_const_stable` an intrinsic is not const evaluable at all.
When building on aarch64, the following warning occurs.
```
warning: unused import: `mem::transmute`
--> crates/core_arch/src/arm/neon.rs:3:38
|
3 | use crate::{core_arch::simd_llvm::*, mem::transmute};
| ^^^^^^^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
```