diff options
-rw-r--r-- | include/clang/Driver/Options.td | 4 | ||||
-rw-r--r-- | lib/Basic/Targets/X86.cpp | 6 | ||||
-rw-r--r-- | lib/Basic/Targets/X86.h | 2 | ||||
-rw-r--r-- | test/Driver/x86-target-features.c | 9 |
4 files changed, 21 insertions, 0 deletions
diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td index 74e13f7026b9..ad72aef3fc94 100644 --- a/include/clang/Driver/Options.td +++ b/include/clang/Driver/Options.td @@ -2583,6 +2583,10 @@ def mshstk : Flag<["-"], "mshstk">, Group<m_x86_Features_Group>; def mno_shstk : Flag<["-"], "mno-shstk">, Group<m_x86_Features_Group>; def mibt : Flag<["-"], "mibt">, Group<m_x86_Features_Group>; def mno_ibt : Flag<["-"], "mno-ibt">, Group<m_x86_Features_Group>; +def mretpoline : Flag<["-"], "mretpoline">, Group<m_x86_Features_Group>; +def mno_retpoline : Flag<["-"], "mno-retpoline">, Group<m_x86_Features_Group>; +def mretpoline_external_thunk : Flag<["-"], "mretpoline-external-thunk">, Group<m_x86_Features_Group>; +def mno_retpoline_external_thunk : Flag<["-"], "mno-retpoline-external-thunk">, Group<m_x86_Features_Group>; // 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 diff --git a/lib/Basic/Targets/X86.cpp b/lib/Basic/Targets/X86.cpp index 0febb98d4684..58c6ddc8ff66 100644 --- a/lib/Basic/Targets/X86.cpp +++ b/lib/Basic/Targets/X86.cpp @@ -763,6 +763,10 @@ bool X86TargetInfo::handleTargetFeatures(std::vector<std::string> &Features, HasPREFETCHWT1 = true; } else if (Feature == "+clzero") { HasCLZERO = true; + } else if (Feature == "+retpoline") { + HasRetpoline = true; + } else if (Feature == "+retpoline-external-thunk") { + HasRetpolineExternalThunk = true; } X86SSEEnum Level = llvm::StringSwitch<X86SSEEnum>(Feature) @@ -1305,6 +1309,8 @@ bool X86TargetInfo::hasFeature(StringRef Feature) const { .Case("prfchw", HasPRFCHW) .Case("rdrnd", HasRDRND) .Case("rdseed", HasRDSEED) + .Case("retpoline", HasRetpoline) + .Case("retpoline-external-thunk", HasRetpolineExternalThunk) .Case("rtm", HasRTM) .Case("sgx", HasSGX) .Case("sha", HasSHA) diff --git a/lib/Basic/Targets/X86.h b/lib/Basic/Targets/X86.h index cbd6a2d24fb5..590531c17854 100644 --- a/lib/Basic/Targets/X86.h +++ b/lib/Basic/Targets/X86.h @@ -96,6 +96,8 @@ class LLVM_LIBRARY_VISIBILITY X86TargetInfo : public TargetInfo { bool HasCLWB = false; bool HasMOVBE = false; bool HasPREFETCHWT1 = false; + bool HasRetpoline = false; + bool HasRetpolineExternalThunk = false; /// \brief Enumeration of all of the X86 CPUs supported by Clang. /// diff --git a/test/Driver/x86-target-features.c b/test/Driver/x86-target-features.c index 1289823d1dbe..36b15a7a350c 100644 --- a/test/Driver/x86-target-features.c +++ b/test/Driver/x86-target-features.c @@ -125,3 +125,12 @@ // VBMI2: "-target-feature" "+avx512vbmi2" // NO-VBMI2: "-target-feature" "-avx512vbmi2" +// RUN: %clang -target i386-linux-gnu -mretpoline %s -### -o %t.o 2>&1 | FileCheck -check-prefix=RETPOLINE %s +// RUN: %clang -target i386-linux-gnu -mno-retpoline %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-RETPOLINE %s +// RETPOLINE: "-target-feature" "+retpoline" +// NO-RETPOLINE: "-target-feature" "-retpoline" + +// RUN: %clang -target i386-linux-gnu -mretpoline -mretpoline-external-thunk %s -### -o %t.o 2>&1 | FileCheck -check-prefix=RETPOLINE-EXTERNAL-THUNK %s +// RUN: %clang -target i386-linux-gnu -mretpoline -mno-retpoline-external-thunk %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-RETPOLINE-EXTERNAL-THUNK %s +// RETPOLINE-EXTERNAL-THUNK: "-target-feature" "+retpoline-external-thunk" +// NO-RETPOLINE-EXTERNAL-THUNK: "-target-feature" "-retpoline-external-thunk" |