Summary:
Asm goto is not supported by SLH. Warn if an instance of asm goto is detected
while SLH is enabled.
Test included.
Reviewed By: jyu2
Differential Revision: https://reviews.llvm.org/D79743
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
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();
--- /dev/null
+// RUN: %clang_cc1 -Wno-slh-asm-goto -mspeculative-load-hardening -fsyntax-only -verify %s
+
+void f() {
+ __asm goto("movl %ecx, %edx"); // expected-no-diagnostics
+}
--- /dev/null
+// RUN: %clang_cc1 -mspeculative-load-hardening -fsyntax-only -verify %s
+
+void f() {
+ __asm goto("movl %ecx, %edx"); // expected-warning {{Speculative load hardening does not protect functions with asm goto}}
+}