[PATCH] D156962: [Driver] Mark m_x86_Features_Group options as TargetSpecific
Fangrui Song via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 2 20:11:36 PDT 2023
MaskRay created this revision.
MaskRay added reviewers: pengfei, skan, RKSimon.
Herald added a subscriber: kristof.beyls.
Herald added a project: All.
MaskRay requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
so that they lead to an error when compiled for non-x86 targets.
Follow-up to D151590 <https://reviews.llvm.org/D151590>.
% aarch64-linux-gnu-gcc -c -mavx a.c
aarch64-linux-gnu-gcc: error: unrecognized command-line option ‘-mavx’
% clang --target=aarch64-unknown-linux-gnu -c -mavx a.c # without this patch
clang: warning: argument unused during compilation: '-mavx' [-Wunused-command-line-argument]
...
% clang --target=aarch64-unknown-linux-gnu -c -mavx a.c # with this patch
clang: error: unsupported option '-mavx' for target 'aarch64-unknown-linux-gnu'
As a workaround for https://github.com/llvm/llvm-project/issues/63270, we don't
report an error for -msse4.2.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D156962
Files:
clang/include/clang/Driver/Options.td
clang/test/Driver/x86-target-features.c
Index: clang/test/Driver/x86-target-features.c
===================================================================
--- clang/test/Driver/x86-target-features.c
+++ clang/test/Driver/x86-target-features.c
@@ -374,6 +374,13 @@
// CRC32: "-target-feature" "+crc32"
// NO-CRC32: "-target-feature" "-crc32"
+// RUN: %clang -### --target=aarch64 -mcrc32 -msse4.1 -msse4.2 -mno-sgx %s 2>&1 | FileCheck --check-prefix=NONX86 %s
+// NONX86: error: unsupported option '-mcrc32' for target 'aarch64'
+// NONX86-NEXT: error: unsupported option '-msse4.1' for target 'aarch64'
+/// TODO: This warning is a workaround for https://github.com/llvm/llvm-project/issues/63270
+// NONX86-NEXT: warning: argument unused during compilation: '-msse4.2' [-Wunused-command-line-argument]
+// NONX86-NEXT: error: unsupported option '-mno-sgx' for target 'aarch64'
+
// RUN: %clang --target=i386 -march=i386 -mharden-sls=return %s -### -o %t.o 2>&1 | FileCheck -check-prefixes=SLS-RET,NO-SLS %s
// RUN: %clang --target=i386 -march=i386 -mharden-sls=indirect-jmp %s -### -o %t.o 2>&1 | FileCheck -check-prefixes=SLS-IJMP,NO-SLS %s
// RUN: %clang --target=i386 -march=i386 -mharden-sls=none -mharden-sls=all %s -### -o %t.o 2>&1 | FileCheck -check-prefixes=SLS-IJMP,SLS-RET %s
Index: clang/include/clang/Driver/Options.td
===================================================================
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4887,6 +4887,7 @@
} // let Flags = [TargetSpecific]
// X86 feature flags
+let Flags = [TargetSpecific] in {
def mx87 : Flag<["-"], "mx87">, Group<m_x86_Features_Group>;
def mno_x87 : Flag<["-"], "mno-x87">, Group<m_x86_Features_Group>;
def m80387 : Flag<["-"], "m80387">, Alias<mx87>;
@@ -4920,7 +4921,11 @@
def mno_ssse3 : Flag<["-"], "mno-ssse3">, Group<m_x86_Features_Group>;
def msse4_1 : Flag<["-"], "msse4.1">, Group<m_x86_Features_Group>;
def mno_sse4_1 : Flag<["-"], "mno-sse4.1">, Group<m_x86_Features_Group>;
+} // let Flags = [TargetSpecific]
+// TODO: Make -msse4.2 TargetSpecific after
+// https://github.com/llvm/llvm-project/issues/63270 is fixed.
def msse4_2 : Flag<["-"], "msse4.2">, Group<m_x86_Features_Group>;
+let Flags = [TargetSpecific] in {
def mno_sse4_2 : Flag<["-"], "mno-sse4.2">, Group<m_x86_Features_Group>;
def msse4 : Flag<["-"], "msse4">, Alias<msse4_2>;
// -mno-sse4 turns off sse4.1 which has the effect of turning off everything
@@ -5101,6 +5106,7 @@
def mno_retpoline_external_thunk : Flag<["-"], "mno-retpoline-external-thunk">, Group<m_x86_Features_Group>;
def mvzeroupper : Flag<["-"], "mvzeroupper">, Group<m_x86_Features_Group>;
def mno_vzeroupper : Flag<["-"], "mno-vzeroupper">, Group<m_x86_Features_Group>;
+} // let Flags = [TargetSpecific]
// These are legacy user-facing driver-level option spellings. They are always
// aliases for options that are spelled using the more common Unix / GNU flag
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156962.546676.patch
Type: text/x-patch
Size: 2926 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230803/463fde6c/attachment.bin>
More information about the cfe-commits
mailing list