From 12665f28129a7aefc635dc36d6fe0ad26583dd8a Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Fri, 26 Jun 2020 00:14:58 -0700 Subject: [PATCH] [X86] Make XSAVEC/XSAVEOPT/XSAVES properly depend on XSAVE in both the frontend and the backend. These features implicitly enabled XSAVE in the frontend, but not the backend. Disabling XSAVE in the frontend disabled XSAVEOPT, but not the other 2. Nothing happened in the backend. --- clang/lib/Basic/Targets/X86.cpp | 2 +- clang/test/Preprocessor/x86_target_features.c | 4 +++- llvm/lib/Target/X86/X86.td | 9 ++++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp index 184090f..22ed922 100644 --- a/clang/lib/Basic/Targets/X86.cpp +++ b/clang/lib/Basic/Targets/X86.cpp @@ -712,7 +712,7 @@ void X86TargetInfo::setFeatureEnabledImpl(llvm::StringMap &Features, setSSELevel(Features, SSE41, Enabled); } else if (Name == "xsave") { if (!Enabled) - Features["xsaveopt"] = false; + Features["xsaveopt"] = Features["xsavec"] = Features["xsaves"] = false; } else if (Name == "xsaveopt" || Name == "xsavec" || Name == "xsaves") { if (Enabled) Features["xsave"] = true; diff --git a/clang/test/Preprocessor/x86_target_features.c b/clang/test/Preprocessor/x86_target_features.c index 6f3c0cf..dc7c810 100644 --- a/clang/test/Preprocessor/x86_target_features.c +++ b/clang/test/Preprocessor/x86_target_features.c @@ -417,9 +417,11 @@ // XSAVES: #define __XSAVES__ 1 // XSAVES: #define __XSAVE__ 1 -// RUN: %clang -target i386-unknown-unknown -march=atom -mxsaveopt -mno-xsave -x c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=NOXSAVE %s +// RUN: %clang -target i386-unknown-unknown -march=atom -mxsaveopt -mxsavec -mxsaves -mno-xsave -x c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=NOXSAVE %s +// NOXSAVE-NOT: #define __XSAVEC__ 1 // NOXSAVE-NOT: #define __XSAVEOPT__ 1 +// NOXSAVE-NOT: #define __XSAVES__ 1 // NOXSAVE-NOT: #define __XSAVE__ 1 // RUN: %clang -target i386-unknown-unknown -march=atom -mclflushopt -x c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=CLFLUSHOPT %s diff --git a/llvm/lib/Target/X86/X86.td b/llvm/lib/Target/X86/X86.td index 3e85d4a..d68fb97 100644 --- a/llvm/lib/Target/X86/X86.td +++ b/llvm/lib/Target/X86/X86.td @@ -52,13 +52,16 @@ def FeatureXSAVE : SubtargetFeature<"xsave", "HasXSAVE", "true", "Support xsave instructions">; def FeatureXSAVEOPT: SubtargetFeature<"xsaveopt", "HasXSAVEOPT", "true", - "Support xsaveopt instructions">; + "Support xsaveopt instructions", + [FeatureXSAVE]>; def FeatureXSAVEC : SubtargetFeature<"xsavec", "HasXSAVEC", "true", - "Support xsavec instructions">; + "Support xsavec instructions", + [FeatureXSAVE]>; def FeatureXSAVES : SubtargetFeature<"xsaves", "HasXSAVES", "true", - "Support xsaves instructions">; + "Support xsaves instructions", + [FeatureXSAVE]>; def FeatureSSE1 : SubtargetFeature<"sse", "X86SSELevel", "SSE1", "Enable SSE instructions">; -- 2.7.4