[PATCH] D86105: [darwin] Disable the -Wpsabi warning

Alex Lorenz via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 17 17:39:08 PDT 2020


arphaman updated this revision to Diff 286181.
arphaman added a comment.

add missing test fix


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86105/new/

https://reviews.llvm.org/D86105

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/target-avx-abi-diag.c
  clang/test/CodeGen/target-builtin-error-3.c


Index: clang/test/CodeGen/target-builtin-error-3.c
===================================================================
--- clang/test/CodeGen/target-builtin-error-3.c
+++ clang/test/CodeGen/target-builtin-error-3.c
@@ -24,6 +24,5 @@
 }
 void avx_test( uint16_t *destData, float16 argbF)
 {
-  // expected-warning at +1{{AVX vector argument of type 'float16' (vector of 16 'float' values) without 'avx512f' enabled changes the ABI}}
   ((half16U *)destData)[0] = convert_half(argbF);
 }
Index: clang/test/CodeGen/target-avx-abi-diag.c
===================================================================
--- clang/test/CodeGen/target-avx-abi-diag.c
+++ clang/test/CodeGen/target-avx-abi-diag.c
@@ -1,6 +1,9 @@
-// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -verify=no256,no512 -o - -S
-// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -target-feature +avx -verify=no512 -o - -S
+// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -verify=no256,no512,no256-err,no512-err -o - -S
+// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -target-feature +avx -verify=no512,no512-err -o - -S
 // RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -target-feature +avx512f -verify=both -o - -S
+
+// RUN: %clang_cc1 %s -triple=x86_64-apple-macos -verify=no256-err,no512-err -o - -S
+// RUN: %clang_cc1 %s -triple=x86_64-apple-macos -target-feature +avx -verify=no512-err -o - -S
 // REQUIRES: x86-registered-target
 
 // both-no-diagnostics
@@ -31,12 +34,12 @@
 // If only 1 side has an attribute, error.
 void call_errors(void) {
   avx256Type t1;
-  takesAvx256(t1); // no256-error {{AVX vector argument of type 'avx256Type' (vector of 16 'short' values) without 'avx' enabled changes the ABI}}
+  takesAvx256(t1); // no256-err-error {{AVX vector argument of type 'avx256Type' (vector of 16 'short' values) without 'avx' enabled changes the ABI}}
   avx512fType t2;
-  takesAvx512(t2); // no512-error {{AVX vector argument of type 'avx512fType' (vector of 32 'short' values) without 'avx512f' enabled changes the ABI}}
+  takesAvx512(t2); // no512-err-error {{AVX vector argument of type 'avx512fType' (vector of 32 'short' values) without 'avx512f' enabled changes the ABI}}
 
-  variadic_err(1, t1); // no256-error {{AVX vector argument of type 'avx256Type' (vector of 16 'short' values) without 'avx' enabled changes the ABI}}
-  variadic_err(3, t2); // no512-error {{AVX vector argument of type 'avx512fType' (vector of 32 'short' values) without 'avx512f' enabled changes the ABI}}
+  variadic_err(1, t1); // no256-err-error {{AVX vector argument of type 'avx256Type' (vector of 16 'short' values) without 'avx' enabled changes the ABI}}
+  variadic_err(3, t2); // no512-err-error {{AVX vector argument of type 'avx512fType' (vector of 32 'short' values) without 'avx512f' enabled changes the ABI}}
 }
 
 // These two don't diagnose anything, since these are valid calls.
Index: clang/lib/CodeGen/TargetInfo.cpp
===================================================================
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -2508,12 +2508,17 @@
                                  const llvm::StringMap<bool> &CallerMap,
                                  const llvm::StringMap<bool> &CalleeMap,
                                  QualType Ty, StringRef Feature,
-                                 bool IsArgument) {
+                                 bool IsArgument, const llvm::Triple &TT) {
   bool CallerHasFeat = CallerMap.lookup(Feature);
   bool CalleeHasFeat = CalleeMap.lookup(Feature);
-  if (!CallerHasFeat && !CalleeHasFeat)
+  if (!CallerHasFeat && !CalleeHasFeat) {
+    // Darwin doesn't enable AVX/AVX512 by default to support Rosetta 2, so it's
+    // user's responsibility to use AVX/AVX512 safely.
+    if (TT.isOSDarwin())
+      return false;
     return Diag.Report(CallLoc, diag::warn_avx_calling_convention)
            << IsArgument << Ty << Feature;
+  }
 
   // Mixing calling conventions here is very clearly an error.
   if (!CallerHasFeat || !CalleeHasFeat)
@@ -2531,13 +2536,14 @@
                           const llvm::StringMap<bool> &CalleeMap, QualType Ty,
                           bool IsArgument) {
   uint64_t Size = Ctx.getTypeSize(Ty);
+  const llvm::Triple &TT = Ctx.getTargetInfo().getTriple();
   if (Size > 256)
     return checkAVXParamFeature(Diag, CallLoc, CallerMap, CalleeMap, Ty,
-                                "avx512f", IsArgument);
+                                "avx512f", IsArgument, TT);
 
   if (Size > 128)
     return checkAVXParamFeature(Diag, CallLoc, CallerMap, CalleeMap, Ty, "avx",
-                                IsArgument);
+                                IsArgument, TT);
 
   return false;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86105.286181.patch
Type: text/x-patch
Size: 4675 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200818/eb50a239/attachment.bin>


More information about the cfe-commits mailing list