zbrid updated this revision to Diff 263819.
zbrid added a comment.

Update to fix failing test


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/CodeGen/CGStmt.cpp
  clang/test/Sema/asm-goto-slh.cpp


Index: clang/test/Sema/asm-goto-slh.cpp
===================================================================
--- /dev/null
+++ clang/test/Sema/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 support use of GCC asm goto. asm goto detected with SLH}}
+}
Index: clang/lib/CodeGen/CGStmt.cpp
===================================================================
--- clang/lib/CodeGen/CGStmt.cpp
+++ clang/lib/CodeGen/CGStmt.cpp
@@ -2300,6 +2300,10 @@
                          /* IsAlignStack */ false, AsmDialect);
   std::vector<llvm::Value*> RegResults;
   if (IsGCCAsmGoto) {
+    const auto LO = getLangOpts();
+    if (LO.SpeculativeLoadHardening)
+      CGM.getDiags().Report(S.getAsmLoc(),
+                            diag::warn_slh_does_not_support_gcc_asm_goto);
     llvm::CallBrInst *Result =
         Builder.CreateCallBr(IA, Fallthrough, Transfer, Args);
     EmitBlock(Fallthrough);
Index: clang/include/clang/Basic/DiagnosticCommonKinds.td
===================================================================
--- clang/include/clang/Basic/DiagnosticCommonKinds.td
+++ clang/include/clang/Basic/DiagnosticCommonKinds.td
@@ -243,6 +243,10 @@
   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_gcc_asm_goto : Warning<
+    "speculative load hardening does not support use of GCC asm goto. asm goto 
"
+        "detected with SLH">, InGroup<DiagGroup<"slh-asm-goto">>;
 }
 
 // Sema && Serialization


Index: clang/test/Sema/asm-goto-slh.cpp
===================================================================
--- /dev/null
+++ clang/test/Sema/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 support use of GCC asm goto. asm goto detected with SLH}}
+}
Index: clang/lib/CodeGen/CGStmt.cpp
===================================================================
--- clang/lib/CodeGen/CGStmt.cpp
+++ clang/lib/CodeGen/CGStmt.cpp
@@ -2300,6 +2300,10 @@
                          /* IsAlignStack */ false, AsmDialect);
   std::vector<llvm::Value*> RegResults;
   if (IsGCCAsmGoto) {
+    const auto LO = getLangOpts();
+    if (LO.SpeculativeLoadHardening)
+      CGM.getDiags().Report(S.getAsmLoc(),
+                            diag::warn_slh_does_not_support_gcc_asm_goto);
     llvm::CallBrInst *Result =
         Builder.CreateCallBr(IA, Fallthrough, Transfer, Args);
     EmitBlock(Fallthrough);
Index: clang/include/clang/Basic/DiagnosticCommonKinds.td
===================================================================
--- clang/include/clang/Basic/DiagnosticCommonKinds.td
+++ clang/include/clang/Basic/DiagnosticCommonKinds.td
@@ -243,6 +243,10 @@
   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_gcc_asm_goto : Warning<
+    "speculative load hardening does not support use of GCC asm goto. asm goto "
+        "detected with SLH">, InGroup<DiagGroup<"slh-asm-goto">>;
 }
 
 // Sema && Serialization
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to