[PATCH] D79733: [clang][SLH] Add __has_feature(speculative_load_hardening)
Zola Bridges via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon May 11 11:50:46 PDT 2020
zbrid created this revision.
zbrid added reviewers: craig.topper, echristo.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
zbrid marked an inline comment as done.
zbrid added inline comments.
zbrid marked an inline comment as done.
================
Comment at: clang/lib/Driver/ToolChains/Clang.cpp:5357
- if (Args.hasFlag(options::OPT_mspeculative_load_hardening, options::OPT_mno_speculative_load_hardening,
- false))
+ if (Args.hasFlag(options::OPT_mspeculative_load_hardening,
+ options::OPT_mno_speculative_load_hardening, false))
----------------
This is a style fix only.
================
Comment at: clang/lib/Driver/ToolChains/Clang.cpp:5357
- if (Args.hasFlag(options::OPT_mspeculative_load_hardening, options::OPT_mno_speculative_load_hardening,
- false))
+ if (Args.hasFlag(options::OPT_mspeculative_load_hardening,
+ options::OPT_mno_speculative_load_hardening, false))
----------------
zbrid wrote:
> This is a style fix only.
Err, I mean the change in this line is only a style fix. The rest of the patch is the functional change.
SLH doesn't support asm goto and is unlikely to ever support it. Users of asm
goto need a way to choose whether to use asm goto or fallback to an SLH
compatible code path when SLH is enabled. This feature flag will give users
this ability.
Tested via unit test
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D79733
Files:
clang/include/clang/Basic/Features.def
clang/include/clang/Basic/LangOptions.def
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
Index: clang/lib/Frontend/CompilerInvocation.cpp
===================================================================
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3372,6 +3372,8 @@
}
Opts.BranchTargetEnforcement = Args.hasArg(OPT_mbranch_target_enforce);
+ Opts.SpeculativeLoadHardeningEnabled =
+ Args.hasArg(OPT_mspeculative_load_hardening);
}
static bool isStrictlyPreprocessorAction(frontend::ActionKind Action) {
Index: clang/lib/Driver/ToolChains/Clang.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5354,8 +5354,8 @@
Args.AddLastArg(CmdArgs, options::OPT_pthread);
- if (Args.hasFlag(options::OPT_mspeculative_load_hardening, options::OPT_mno_speculative_load_hardening,
- false))
+ if (Args.hasFlag(options::OPT_mspeculative_load_hardening,
+ options::OPT_mno_speculative_load_hardening, false))
CmdArgs.push_back(Args.MakeArgString("-mspeculative-load-hardening"));
RenderSSPOptions(TC, Args, CmdArgs, KernelOrKext);
Index: clang/include/clang/Basic/LangOptions.def
===================================================================
--- clang/include/clang/Basic/LangOptions.def
+++ clang/include/clang/Basic/LangOptions.def
@@ -366,6 +366,9 @@
"Key used for return address signing")
LANGOPT(BranchTargetEnforcement, 1, 0, "Branch-target enforcement enabled")
+BENIGN_LANGOPT(SpeculativeLoadHardeningEnabled, 1, 0,
+ "Speculative load hardening enabled")
+
#undef LANGOPT
#undef COMPATIBLE_LANGOPT
#undef BENIGN_LANGOPT
Index: clang/include/clang/Basic/Features.def
===================================================================
--- clang/include/clang/Basic/Features.def
+++ clang/include/clang/Basic/Features.def
@@ -36,6 +36,7 @@
#define EXTENSION(Name, Predicate)
#endif
+FEATURE(speculative_load_hardening, LangOpts.SpeculativeLoadHardeningEnabled)
FEATURE(address_sanitizer,
LangOpts.Sanitize.hasOneOf(SanitizerKind::Address |
SanitizerKind::KernelAddress))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79733.263226.patch
Type: text/x-patch
Size: 2199 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200511/95bb9a6f/attachment.bin>
More information about the cfe-commits
mailing list