[PATCH] D86105: [darwin] Disable the -Wpsabi warning
Alex Lorenz via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 4 14:57:42 PST 2020
arphaman updated this revision to Diff 302977.
arphaman added a comment.
Address Ahmed's comments.
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,15 @@
const llvm::StringMap<bool> &CallerMap,
const llvm::StringMap<bool> &CalleeMap,
QualType Ty, StringRef Feature,
- bool IsArgument) {
+ bool IsArgument, bool EnableWarning) {
bool CallerHasFeat = CallerMap.lookup(Feature);
bool CalleeHasFeat = CalleeMap.lookup(Feature);
- if (!CallerHasFeat && !CalleeHasFeat)
+ if (!CallerHasFeat && !CalleeHasFeat) {
+ if (!EnableWarning)
+ 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)
@@ -2530,14 +2533,20 @@
const llvm::StringMap<bool> &CallerMap,
const llvm::StringMap<bool> &CalleeMap, QualType Ty,
bool IsArgument) {
+ // Note: Darwin x86_64 targets a baseline CPU which doesn't enable
+ // AVX/AVX512, so it allows passing wide vectors in SSE: don't warn.
+ // Darwin users who do enable AVX/AVX512 are responsible for ensuring safe
+ // usage of wide vector types.
+ // However, x86_64h does enable AVX by default in all functions.
+ bool EnableWarning = !Ctx.getTargetInfo().getTriple().isOSDarwin();
uint64_t Size = Ctx.getTypeSize(Ty);
if (Size > 256)
return checkAVXParamFeature(Diag, CallLoc, CallerMap, CalleeMap, Ty,
- "avx512f", IsArgument);
+ "avx512f", IsArgument, EnableWarning);
if (Size > 128)
return checkAVXParamFeature(Diag, CallLoc, CallerMap, CalleeMap, Ty, "avx",
- IsArgument);
+ IsArgument, EnableWarning);
return false;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86105.302977.patch
Type: text/x-patch
Size: 4953 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201104/2e5e4e99/attachment.bin>
More information about the cfe-commits
mailing list