Skip to content

Commit 5a43fdd

Browse files
committed
[X86] Remove what little support we had for MPX
-Deprecate -mmpx and -mno-mpx command line options -Remove CPUID detection of mpx for -march=native -Remove MPX from all CPUs -Remove MPX preprocessor define I've left the "mpx" string in the backend so we don't fail on old IR, but its not connected to anything. gcc has also deprecated these command line options. https://www.phoronix.com/scan.php?page=news_item&px=GCC-Patch-To-Drop-MPX Differential Revision: https://reviews.llvm.org/D66669 llvm-svn: 370393
1 parent 093ebf9 commit 5a43fdd

File tree

14 files changed

+39
-64
lines changed

14 files changed

+39
-64
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ Deprecated Compiler Flags
7070
The following options are deprecated and ignored. They will be removed in
7171
future versions of Clang.
7272

73+
- -mmpx used to enable the __MPX__ preprocessor define for the Intel MPX
74+
instructions. There were no MPX intrinsics.
75+
- -mno-mpx used to disable -mmpx and is the default behavior.
76+
7377
- ...
7478

7579
Modified Compiler Flags

clang/include/clang/Driver/Options.td

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,10 @@ def clang_ignored_legacy_options_Group : OptionGroup<"<clang legacy flags>">,
211211
def : Flag<["-"], "fslp-vectorize-aggressive">, Group<clang_ignored_legacy_options_Group>;
212212
def : Flag<["-"], "fno-slp-vectorize-aggressive">, Group<clang_ignored_legacy_options_Group>;
213213

214+
// Retired with clang-10.0. Previously controlled X86 MPX ISA.
215+
def mmpx : Flag<["-"], "mmpx">, Group<clang_ignored_legacy_options_Group>;
216+
def mno_mpx : Flag<["-"], "mno-mpx">, Group<clang_ignored_legacy_options_Group>;
217+
214218
// Group that ignores all gcc optimizations that won't be implemented
215219
def clang_ignored_gcc_optimization_f_Group : OptionGroup<
216220
"<clang_ignored_gcc_optimization_f_Group>">, Group<f_Group>, Flags<[Ignored]>;
@@ -3000,8 +3004,6 @@ def mmovdiri : Flag<["-"], "mmovdiri">, Group<m_x86_Features_Group>;
30003004
def mno_movdiri : Flag<["-"], "mno-movdiri">, Group<m_x86_Features_Group>;
30013005
def mmovdir64b : Flag<["-"], "mmovdir64b">, Group<m_x86_Features_Group>;
30023006
def mno_movdir64b : Flag<["-"], "mno-movdir64b">, Group<m_x86_Features_Group>;
3003-
def mmpx : Flag<["-"], "mmpx">, Group<m_x86_Features_Group>;
3004-
def mno_mpx : Flag<["-"], "mno-mpx">, Group<m_x86_Features_Group>;
30053007
def mmwaitx : Flag<["-"], "mmwaitx">, Group<m_x86_Features_Group>;
30063008
def mno_mwaitx : Flag<["-"], "mno-mwaitx">, Group<m_x86_Features_Group>;
30073009
def mpku : Flag<["-"], "mpku">, Group<m_x86_Features_Group>;

clang/lib/Basic/Targets/X86.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ bool X86TargetInfo::initFeatureMap(
198198
SkylakeCommon:
199199
setFeatureEnabledImpl(Features, "xsavec", true);
200200
setFeatureEnabledImpl(Features, "xsaves", true);
201-
setFeatureEnabledImpl(Features, "mpx", true);
202201
setFeatureEnabledImpl(Features, "clflushopt", true);
203202
setFeatureEnabledImpl(Features, "aes", true);
204203
LLVM_FALLTHROUGH;
@@ -277,7 +276,6 @@ bool X86TargetInfo::initFeatureMap(
277276
setFeatureEnabledImpl(Features, "xsavec", true);
278277
setFeatureEnabledImpl(Features, "xsaves", true);
279278
setFeatureEnabledImpl(Features, "clflushopt", true);
280-
setFeatureEnabledImpl(Features, "mpx", true);
281279
setFeatureEnabledImpl(Features, "fsgsbase", true);
282280
setFeatureEnabledImpl(Features, "aes", true);
283281
LLVM_FALLTHROUGH;
@@ -798,8 +796,6 @@ bool X86TargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
798796
HasAVX512VP2INTERSECT = true;
799797
} else if (Feature == "+sha") {
800798
HasSHA = true;
801-
} else if (Feature == "+mpx") {
802-
HasMPX = true;
803799
} else if (Feature == "+shstk") {
804800
HasSHSTK = true;
805801
} else if (Feature == "+movbe") {
@@ -1220,8 +1216,6 @@ void X86TargetInfo::getTargetDefines(const LangOptions &Opts,
12201216
Builder.defineMacro("__CLWB__");
12211217
if (HasWBNOINVD)
12221218
Builder.defineMacro("__WBNOINVD__");
1223-
if (HasMPX)
1224-
Builder.defineMacro("__MPX__");
12251219
if (HasSHSTK)
12261220
Builder.defineMacro("__SHSTK__");
12271221
if (HasSGX)
@@ -1378,7 +1372,6 @@ bool X86TargetInfo::isValidFeatureName(StringRef Name) const {
13781372
.Case("movbe", true)
13791373
.Case("movdiri", true)
13801374
.Case("movdir64b", true)
1381-
.Case("mpx", true)
13821375
.Case("mwaitx", true)
13831376
.Case("pclmul", true)
13841377
.Case("pconfig", true)
@@ -1462,7 +1455,6 @@ bool X86TargetInfo::hasFeature(StringRef Feature) const {
14621455
.Case("movbe", HasMOVBE)
14631456
.Case("movdiri", HasMOVDIRI)
14641457
.Case("movdir64b", HasMOVDIR64B)
1465-
.Case("mpx", HasMPX)
14661458
.Case("mwaitx", HasMWAITX)
14671459
.Case("pclmul", HasPCLMUL)
14681460
.Case("pconfig", HasPCONFIG)

clang/lib/Basic/Targets/X86.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ class LLVM_LIBRARY_VISIBILITY X86TargetInfo : public TargetInfo {
8080
bool HasAVX512IFMA = false;
8181
bool HasAVX512VP2INTERSECT = false;
8282
bool HasSHA = false;
83-
bool HasMPX = false;
8483
bool HasSHSTK = false;
8584
bool HasSGX = false;
8685
bool HasCX8 = false;

clang/test/Driver/x86-target-features.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@
7272

7373
// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mmpx %s -### -o %t.o 2>&1 | FileCheck -check-prefix=MPX %s
7474
// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-mpx %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-MPX %s
75-
// MPX: "-target-feature" "+mpx"
76-
// NO-MPX: "-target-feature" "-mpx"
75+
// MPX: the flag '-mmpx' has been deprecated and will be ignored
76+
// NO-MPX: the flag '-mno-mpx' has been deprecated and will be ignored
7777

7878
// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mshstk %s -### -o %t.o 2>&1 | FileCheck -check-prefix=CETSS %s
7979
// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-shstk %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-CETSS %s

clang/test/Preprocessor/predefined-arch-macros.c

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,6 @@
682682
// CHECK_SKL_M32: #define __LZCNT__ 1
683683
// CHECK_SKL_M32: #define __MMX__ 1
684684
// CHECK_SKL_M32: #define __MOVBE__ 1
685-
// CHECK_SKL_M32: #define __MPX__ 1
686685
// CHECK_SKL_M32: #define __PCLMUL__ 1
687686
// CHECK_SKL_M32: #define __POPCNT__ 1
688687
// CHECK_SKL_M32: #define __PRFCHW__ 1
@@ -717,7 +716,6 @@
717716
// CHECK_SKL_M64: #define __LZCNT__ 1
718717
// CHECK_SKL_M64: #define __MMX__ 1
719718
// CHECK_SKL_M64: #define __MOVBE__ 1
720-
// CHECK_SKL_M64: #define __MPX__ 1
721719
// CHECK_SKL_M64: #define __PCLMUL__ 1
722720
// CHECK_SKL_M64: #define __POPCNT__ 1
723721
// CHECK_SKL_M64: #define __PRFCHW__ 1
@@ -912,7 +910,6 @@
912910
// CHECK_SKX_M32: #define __LZCNT__ 1
913911
// CHECK_SKX_M32: #define __MMX__ 1
914912
// CHECK_SKX_M32: #define __MOVBE__ 1
915-
// CHECK_SKX_M32: #define __MPX__ 1
916913
// CHECK_SKX_M32: #define __PCLMUL__ 1
917914
// CHECK_SKX_M32: #define __PKU__ 1
918915
// CHECK_SKX_M32: #define __POPCNT__ 1
@@ -958,7 +955,6 @@
958955
// CHECK_SKX_M64: #define __LZCNT__ 1
959956
// CHECK_SKX_M64: #define __MMX__ 1
960957
// CHECK_SKX_M64: #define __MOVBE__ 1
961-
// CHECK_SKX_M64: #define __MPX__ 1
962958
// CHECK_SKX_M64: #define __PCLMUL__ 1
963959
// CHECK_SKX_M64: #define __PKU__ 1
964960
// CHECK_SKX_M64: #define __POPCNT__ 1
@@ -1008,7 +1004,6 @@
10081004
// CHECK_CLX_M32: #define __LZCNT__ 1
10091005
// CHECK_CLX_M32: #define __MMX__ 1
10101006
// CHECK_CLX_M32: #define __MOVBE__ 1
1011-
// CHECK_CLX_M32: #define __MPX__ 1
10121007
// CHECK_CLX_M32: #define __PCLMUL__ 1
10131008
// CHECK_CLX_M32: #define __PKU__ 1
10141009
// CHECK_CLX_M32: #define __POPCNT__ 1
@@ -1055,7 +1050,6 @@
10551050
// CHECK_CLX_M64: #define __LZCNT__ 1
10561051
// CHECK_CLX_M64: #define __MMX__ 1
10571052
// CHECK_CLX_M64: #define __MOVBE__ 1
1058-
// CHECK_CLX_M64: #define __MPX__ 1
10591053
// CHECK_CLX_M64: #define __PCLMUL__ 1
10601054
// CHECK_CLX_M64: #define __PKU__ 1
10611055
// CHECK_CLX_M64: #define __POPCNT__ 1
@@ -1106,7 +1100,6 @@
11061100
// CHECK_CPX_M32: #define __LZCNT__ 1
11071101
// CHECK_CPX_M32: #define __MMX__ 1
11081102
// CHECK_CPX_M32: #define __MOVBE__ 1
1109-
// CHECK_CPX_M32: #define __MPX__ 1
11101103
// CHECK_CPX_M32: #define __PCLMUL__ 1
11111104
// CHECK_CPX_M32: #define __PKU__ 1
11121105
// CHECK_CPX_M32: #define __POPCNT__ 1
@@ -1154,7 +1147,6 @@
11541147
// CHECK_CPX_M64: #define __LZCNT__ 1
11551148
// CHECK_CPX_M64: #define __MMX__ 1
11561149
// CHECK_CPX_M64: #define __MOVBE__ 1
1157-
// CHECK_CPX_M64: #define __MPX__ 1
11581150
// CHECK_CPX_M64: #define __PCLMUL__ 1
11591151
// CHECK_CPX_M64: #define __PKU__ 1
11601152
// CHECK_CPX_M64: #define __POPCNT__ 1
@@ -1205,7 +1197,6 @@
12051197
// CHECK_CNL_M32: #define __LZCNT__ 1
12061198
// CHECK_CNL_M32: #define __MMX__ 1
12071199
// CHECK_CNL_M32: #define __MOVBE__ 1
1208-
// CHECK_CNL_M32: #define __MPX__ 1
12091200
// CHECK_CNL_M32: #define __PCLMUL__ 1
12101201
// CHECK_CNL_M32: #define __PKU__ 1
12111202
// CHECK_CNL_M32: #define __POPCNT__ 1
@@ -1254,7 +1245,6 @@
12541245
// CHECK_CNL_M64: #define __LZCNT__ 1
12551246
// CHECK_CNL_M64: #define __MMX__ 1
12561247
// CHECK_CNL_M64: #define __MOVBE__ 1
1257-
// CHECK_CNL_M64: #define __MPX__ 1
12581248
// CHECK_CNL_M64: #define __PCLMUL__ 1
12591249
// CHECK_CNL_M64: #define __PKU__ 1
12601250
// CHECK_CNL_M64: #define __POPCNT__ 1
@@ -1309,7 +1299,6 @@
13091299
// CHECK_ICL_M32: #define __LZCNT__ 1
13101300
// CHECK_ICL_M32: #define __MMX__ 1
13111301
// CHECK_ICL_M32: #define __MOVBE__ 1
1312-
// CHECK_ICL_M32: #define __MPX__ 1
13131302
// CHECK_ICL_M32: #define __PCLMUL__ 1
13141303
// CHECK_ICL_M32: #define __PKU__ 1
13151304
// CHECK_ICL_M32: #define __POPCNT__ 1
@@ -1367,7 +1356,6 @@
13671356
// CHECK_ICL_M64: #define __LZCNT__ 1
13681357
// CHECK_ICL_M64: #define __MMX__ 1
13691358
// CHECK_ICL_M64: #define __MOVBE__ 1
1370-
// CHECK_ICL_M64: #define __MPX__ 1
13711359
// CHECK_ICL_M64: #define __PCLMUL__ 1
13721360
// CHECK_ICL_M64: #define __PKU__ 1
13731361
// CHECK_ICL_M64: #define __POPCNT__ 1
@@ -1426,7 +1414,6 @@
14261414
// CHECK_ICX_M32: #define __LZCNT__ 1
14271415
// CHECK_ICX_M32: #define __MMX__ 1
14281416
// CHECK_ICX_M32: #define __MOVBE__ 1
1429-
// CHECK_ICX_M32: #define __MPX__ 1
14301417
// CHECK_ICX_M32: #define __PCLMUL__ 1
14311418
// CHECK_ICX_M32: #define __PCONFIG__ 1
14321419
// CHECK_ICX_M32: #define __PKU__ 1
@@ -1485,7 +1472,6 @@
14851472
// CHECK_ICX_M64: #define __LZCNT__ 1
14861473
// CHECK_ICX_M64: #define __MMX__ 1
14871474
// CHECK_ICX_M64: #define __MOVBE__ 1
1488-
// CHECK_ICX_M64: #define __MPX__ 1
14891475
// CHECK_ICX_M64: #define __PCLMUL__ 1
14901476
// CHECK_ICX_M64: #define __PCONFIG__ 1
14911477
// CHECK_ICX_M64: #define __PKU__ 1
@@ -1548,7 +1534,6 @@
15481534
// CHECK_TGL_M32: #define __MOVBE__ 1
15491535
// CHECK_TGL_M32: #define __MOVDIR64B__ 1
15501536
// CHECK_TGL_M32: #define __MOVDIRI__ 1
1551-
// CHECK_TGL_M32: #define __MPX__ 1
15521537
// CHECK_TGL_M32: #define __PCLMUL__ 1
15531538
// CHECK_TGL_M32-NOT: #define __PCONFIG__ 1
15541539
// CHECK_TGL_M32: #define __PKU__ 1
@@ -1611,7 +1596,6 @@
16111596
// CHECK_TGL_M64: #define __MOVBE__ 1
16121597
// CHECK_TGL_M64: #define __MOVDIR64B__ 1
16131598
// CHECK_TGL_M64: #define __MOVDIRI__ 1
1614-
// CHECK_TGL_M64: #define __MPX__ 1
16151599
// CHECK_TGL_M64: #define __PCLMUL__ 1
16161600
// CHECK_TGL_M64-NOT: #define __PCONFIG__ 1
16171601
// CHECK_TGL_M64: #define __PKU__ 1
@@ -1688,7 +1672,6 @@
16881672
// CHECK_GLM_M32: #define __FXSR__ 1
16891673
// CHECK_GLM_M32: #define __MMX__ 1
16901674
// CHECK_GLM_M32: #define __MOVBE__ 1
1691-
// CHECK_GLM_M32: #define __MPX__ 1
16921675
// CHECK_GLM_M32: #define __PCLMUL__ 1
16931676
// CHECK_GLM_M32: #define __POPCNT__ 1
16941677
// CHECK_GLM_M32: #define __PRFCHW__ 1
@@ -1722,7 +1705,6 @@
17221705
// CHECK_GLM_M64: #define __FXSR__ 1
17231706
// CHECK_GLM_M64: #define __MMX__ 1
17241707
// CHECK_GLM_M64: #define __MOVBE__ 1
1725-
// CHECK_GLM_M64: #define __MPX__ 1
17261708
// CHECK_GLM_M64: #define __PCLMUL__ 1
17271709
// CHECK_GLM_M64: #define __POPCNT__ 1
17281710
// CHECK_GLM_M64: #define __PRFCHW__ 1
@@ -1754,7 +1736,6 @@
17541736
// CHECK_GLMP_M32: #define __FXSR__ 1
17551737
// CHECK_GLMP_M32: #define __MMX__ 1
17561738
// CHECK_GLMP_M32: #define __MOVBE__ 1
1757-
// CHECK_GLMP_M32: #define __MPX__ 1
17581739
// CHECK_GLMP_M32: #define __PCLMUL__ 1
17591740
// CHECK_GLMP_M32: #define __POPCNT__ 1
17601741
// CHECK_GLMP_M32: #define __PRFCHW__ 1
@@ -1791,7 +1772,6 @@
17911772
// CHECK_GLMP_M64: #define __FXSR__ 1
17921773
// CHECK_GLMP_M64: #define __MMX__ 1
17931774
// CHECK_GLMP_M64: #define __MOVBE__ 1
1794-
// CHECK_GLMP_M64: #define __MPX__ 1
17951775
// CHECK_GLMP_M64: #define __PCLMUL__ 1
17961776
// CHECK_GLMP_M64: #define __POPCNT__ 1
17971777
// CHECK_GLMP_M64: #define __PRFCHW__ 1
@@ -1830,7 +1810,6 @@
18301810
// CHECK_TRM_M32: #define __MOVBE__ 1
18311811
// CHECK_TRM_M32: #define __MOVDIR64B__ 1
18321812
// CHECK_TRM_M32: #define __MOVDIRI__ 1
1833-
// CHECK_TRM_M32: #define __MPX__ 1
18341813
// CHECK_TRM_M32: #define __PCLMUL__ 1
18351814
// CHECK_TRM_M32: #define __POPCNT__ 1
18361815
// CHECK_TRM_M32: #define __PRFCHW__ 1
@@ -1872,7 +1851,6 @@
18721851
// CHECK_TRM_M64: #define __MOVBE__ 1
18731852
// CHECK_TRM_M64: #define __MOVDIR64B__ 1
18741853
// CHECK_TRM_M64: #define __MOVDIRI__ 1
1875-
// CHECK_TRM_M64: #define __MPX__ 1
18761854
// CHECK_TRM_M64: #define __PCLMUL__ 1
18771855
// CHECK_TRM_M64: #define __POPCNT__ 1
18781856
// CHECK_TRM_M64: #define __PRFCHW__ 1

llvm/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ Changes to the AVR Target
9898

9999
During this release ...
100100

101+
* Deprecated the mpx feature flag for the Intel MPX instructions. There were no
102+
intrinsics for this feature. This change only this effects the results
103+
returned by getHostCPUFeatures on CPUs that implement the MPX instructions.
104+
101105
Changes to the WebAssembly Target
102106
---------------------------------
103107

llvm/lib/Support/Host.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1378,7 +1378,6 @@ bool sys::getHostCPUFeatures(StringMap<bool> &Features) {
13781378
Features["bmi2"] = HasLeaf7 && ((EBX >> 8) & 1);
13791379
Features["invpcid"] = HasLeaf7 && ((EBX >> 10) & 1);
13801380
Features["rtm"] = HasLeaf7 && ((EBX >> 11) & 1);
1381-
Features["mpx"] = HasLeaf7 && ((EBX >> 14) & 1);
13821381
// AVX512 is only supported if the OS supports the context save for it.
13831382
Features["avx512f"] = HasLeaf7 && ((EBX >> 16) & 1) && HasAVX512Save;
13841383
Features["avx512dq"] = HasLeaf7 && ((EBX >> 17) & 1) && HasAVX512Save;

llvm/lib/Target/X86/X86.td

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,11 @@ def FeatureCLDEMOTE : SubtargetFeature<"cldemote", "HasCLDEMOTE", "true",
241241
"Enable Cache Demote">;
242242
def FeaturePTWRITE : SubtargetFeature<"ptwrite", "HasPTWRITE", "true",
243243
"Support ptwrite instruction">;
244-
def FeatureMPX : SubtargetFeature<"mpx", "HasMPX", "true",
245-
"Support MPX instructions">;
244+
// FIXME: This feature is deprecated in 10.0 and should not be used for
245+
// anything, but removing it would break IR files that may contain it in a
246+
// target-feature attribute.
247+
def FeatureDeprecatedMPX : SubtargetFeature<"mpx", "DeprecatedHasMPX", "false",
248+
"Deprecated. Support MPX instructions">;
246249
def FeatureLEAForSP : SubtargetFeature<"lea-sp", "UseLeaForSP", "true",
247250
"Use LEA for adjusting the stack pointer">;
248251
def FeatureSlowDivide32 : SubtargetFeature<"idivl-to-divb",
@@ -580,7 +583,6 @@ def ProcessorFeatures {
580583

581584
// Skylake
582585
list<SubtargetFeature> SKLAdditionalFeatures = [FeatureAES,
583-
FeatureMPX,
584586
FeatureXSAVEC,
585587
FeatureXSAVES,
586588
FeatureCLFLUSHOPT,
@@ -719,7 +721,6 @@ def ProcessorFeatures {
719721

720722
// Goldmont
721723
list<SubtargetFeature> GLMAdditionalFeatures = [FeatureAES,
722-
FeatureMPX,
723724
FeatureSHA,
724725
FeatureRDSEED,
725726
FeatureXSAVE,

llvm/lib/Target/X86/X86InstrInfo.td

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,6 @@ def HasMOVDIR64B : Predicate<"Subtarget->hasMOVDIR64B()">;
940940
def HasPTWRITE : Predicate<"Subtarget->hasPTWRITE()">;
941941
def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
942942
def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
943-
def HasMPX : Predicate<"Subtarget->hasMPX()">;
944943
def HasSHSTK : Predicate<"Subtarget->hasSHSTK()">;
945944
def HasCLFLUSHOPT : Predicate<"Subtarget->hasCLFLUSHOPT()">;
946945
def HasCLWB : Predicate<"Subtarget->hasCLWB()">;

0 commit comments

Comments
 (0)