forked from OSchip/llvm-project
[clang][asm goto][slh] Warn if asm goto + SLH
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
This commit is contained in:
parent
ad953a1ae1
commit
60ee885990
|
@ -246,6 +246,11 @@ let CategoryName = "Inline Assembly Issue" in {
|
||||||
def warn_stack_clash_protection_inline_asm : Warning<
|
def warn_stack_clash_protection_inline_asm : Warning<
|
||||||
"Unable to protect inline asm that clobbers stack pointer against stack clash">,
|
"Unable to protect inline asm that clobbers stack pointer against stack clash">,
|
||||||
InGroup<DiagGroup<"stack-protector">>;
|
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
|
// Sema && Serialization
|
||||||
|
|
|
@ -729,6 +729,9 @@ StmtResult Parser::ParseAsmStatement(bool &msAsm) {
|
||||||
if (parseGNUAsmQualifierListOpt(GAQ))
|
if (parseGNUAsmQualifierListOpt(GAQ))
|
||||||
return StmtError();
|
return StmtError();
|
||||||
|
|
||||||
|
if (GAQ.isGoto() && getLangOpts().SpeculativeLoadHardening)
|
||||||
|
Diag(Loc, diag::warn_slh_does_not_support_asm_goto);
|
||||||
|
|
||||||
BalancedDelimiterTracker T(*this, tok::l_paren);
|
BalancedDelimiterTracker T(*this, tok::l_paren);
|
||||||
T.consumeOpen();
|
T.consumeOpen();
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
// RUN: %clang_cc1 -Wno-slh-asm-goto -mspeculative-load-hardening -fsyntax-only -verify %s
|
||||||
|
|
||||||
|
void f() {
|
||||||
|
__asm goto("movl %ecx, %edx"); // expected-no-diagnostics
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
// 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}}
|
||||||
|
}
|
Loading…
Reference in New Issue