summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib
diff options
context:
space:
mode:
authorFlorian Hahn <flo@fhahn.com>2019-11-21 09:18:58 +0000
committerFlorian Hahn <flo@fhahn.com>2019-11-21 09:19:17 +0000
commita70c3f9f45c8db3092db44110a992e9fd8ee776e (patch)
tree433420f2fea6aa9c9175dd8e72af32f5f0cc672b /compiler-rt/lib
parent82921bf2baed96b700f90b090d5dc2530223d9c0 (diff)
downloadbcm5719-llvm-a70c3f9f45c8db3092db44110a992e9fd8ee776e.tar.gz
bcm5719-llvm-a70c3f9f45c8db3092db44110a992e9fd8ee776e.zip
[compiler-rt] Don't check XCR0 when detecting avx512 on Darwin.
Darwin lazily saves the AVX512 context on first use [1]: instead of checking that it already does to figure out if the OS supports AVX512, trust that the kernel will do the right thing and always assume the context save support is available. [1] https://github.com/apple/darwin-xnu/blob/xnu-4903.221.2/osfmk/i386/fpu.c#L174 Reviewers: ab, RKSimon, craig.topper Reviewed By: craig.topper Subscribers: dberris, JDevlieghere, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D70454
Diffstat (limited to 'compiler-rt/lib')
-rw-r--r--compiler-rt/lib/builtins/cpu_model.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/compiler-rt/lib/builtins/cpu_model.c b/compiler-rt/lib/builtins/cpu_model.c
index cdd632a612b..fb619037d39 100644
--- a/compiler-rt/lib/builtins/cpu_model.c
+++ b/compiler-rt/lib/builtins/cpu_model.c
@@ -532,7 +532,15 @@ static void getAvailableFeatures(unsigned ECX, unsigned EDX, unsigned MaxLeaf,
const unsigned AVXBits = (1 << 27) | (1 << 28);
bool HasAVX = ((ECX & AVXBits) == AVXBits) && !getX86XCR0(&EAX, &EDX) &&
((EAX & 0x6) == 0x6);
+#if defined(__APPLE__)
+ // Darwin lazily saves the AVX512 context on first use: trust that the OS will
+ // save the AVX512 context if we use AVX512 instructions, even the bit is not
+ // set right now.
+ bool HasAVX512Save = true;
+#else
+ // AVX512 requires additional context to be saved by the OS.
bool HasAVX512Save = HasAVX && ((EAX & 0xe0) == 0xe0);
+#endif
if (HasAVX)
setFeature(FEATURE_AVX);
OpenPOWER on IntegriCloud