[PATCH] D79743: [clang][asm goto][slh] Warn if asm goto + SLH
Zola Bridges via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon May 18 16:17:29 PDT 2020
zbrid updated this revision to Diff 264740.
zbrid marked an inline comment as done.
zbrid added a comment.
Update to emit the warning in the parser
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D79743/new/
https://reviews.llvm.org/D79743
Files:
clang/include/clang/Basic/DiagnosticCommonKinds.td
clang/lib/Parse/ParseStmtAsm.cpp
clang/test/Parser/asm-goto-slh.cpp
Index: clang/test/Parser/asm-goto-slh.cpp
===================================================================
--- /dev/null
+++ clang/test/Parser/asm-goto-slh.cpp
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 %s -mspeculative-load-hardening -triple x86_64-pc-linux-gnu -emit-llvm -S
+
+void f() {
+ __asm goto("movl %ecx, %edx"); // expected-warning {{Speculative load hardening does not protect functions with asm goto}}
+}
Index: clang/lib/Parse/ParseStmtAsm.cpp
===================================================================
--- clang/lib/Parse/ParseStmtAsm.cpp
+++ clang/lib/Parse/ParseStmtAsm.cpp
@@ -729,6 +729,9 @@
if (parseGNUAsmQualifierListOpt(GAQ))
return StmtError();
+ if (GAQ.isGoto() && getLangOpts().SpeculativeLoadHardening)
+ Diag(Loc, diag::warn_slh_does_not_support_asm_goto);
+
BalancedDelimiterTracker T(*this, tok::l_paren);
T.consumeOpen();
Index: clang/include/clang/Basic/DiagnosticCommonKinds.td
===================================================================
--- clang/include/clang/Basic/DiagnosticCommonKinds.td
+++ clang/include/clang/Basic/DiagnosticCommonKinds.td
@@ -243,6 +243,9 @@
def warn_stack_clash_protection_inline_asm : Warning<
"Unable to protect inline asm that clobbers stack pointer against stack clash">,
InGroup<DiagGroup<"stack-protector">>;
+
+ def warn_slh_does_not_support_asm_goto : Warning<
+ "Speculative load hardening does not protect functions with asm goto">, InGroup<DiagGroup<"slh-asm-goto">>;
}
// Sema && Serialization
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79743.264740.patch
Type: text/x-patch
Size: 1525 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200518/17216efa/attachment-0001.bin>
More information about the cfe-commits
mailing list