Skip to content

Commit 6528fe1

Browse files
authored
Merge pull request #1661 from hyp/eng/hippoavx-bastille-in-minsk
[darwin] Disable the -Wpsabi warning
2 parents c3dee48 + b670fc0 commit 6528fe1

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

clang/lib/CodeGen/TargetInfo.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2502,12 +2502,17 @@ static bool checkAVXParamFeature(DiagnosticsEngine &Diag,
25022502
const llvm::StringMap<bool> &CallerMap,
25032503
const llvm::StringMap<bool> &CalleeMap,
25042504
QualType Ty, StringRef Feature,
2505-
bool IsArgument) {
2505+
bool IsArgument, const llvm::Triple &TT) {
25062506
bool CallerHasFeat = CallerMap.lookup(Feature);
25072507
bool CalleeHasFeat = CalleeMap.lookup(Feature);
2508-
if (!CallerHasFeat && !CalleeHasFeat)
2508+
if (!CallerHasFeat && !CalleeHasFeat) {
2509+
// Darwin doesn't enable AVX/AVX512 by default to support Rosetta 2, so it's
2510+
// user's responsibility to use AVX/AVX512 safely.
2511+
if (TT.isOSDarwin())
2512+
return false;
25092513
return Diag.Report(CallLoc, diag::warn_avx_calling_convention)
25102514
<< IsArgument << Ty << Feature;
2515+
}
25112516

25122517
// Mixing calling conventions here is very clearly an error.
25132518
if (!CallerHasFeat || !CalleeHasFeat)
@@ -2525,13 +2530,14 @@ static bool checkAVXParam(DiagnosticsEngine &Diag, ASTContext &Ctx,
25252530
const llvm::StringMap<bool> &CalleeMap, QualType Ty,
25262531
bool IsArgument) {
25272532
uint64_t Size = Ctx.getTypeSize(Ty);
2533+
const llvm::Triple &TT = Ctx.getTargetInfo().getTriple();
25282534
if (Size > 256)
25292535
return checkAVXParamFeature(Diag, CallLoc, CallerMap, CalleeMap, Ty,
2530-
"avx512f", IsArgument);
2536+
"avx512f", IsArgument, TT);
25312537

25322538
if (Size > 128)
25332539
return checkAVXParamFeature(Diag, CallLoc, CallerMap, CalleeMap, Ty, "avx",
2534-
IsArgument);
2540+
IsArgument, TT);
25352541

25362542
return false;
25372543
}

clang/test/CodeGen/target-avx-abi-diag.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -verify=no256,no512 -o - -S
2-
// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -target-feature +avx -verify=no512 -o - -S
1+
// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -verify=no256,no512,no256-err,no512-err -o - -S
2+
// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -target-feature +avx -verify=no512,no512-err -o - -S
33
// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -target-feature +avx512f -verify=both -o - -S
4+
5+
// RUN: %clang_cc1 %s -triple=x86_64-apple-macos -verify=no256-err,no512-err -o - -S
6+
// RUN: %clang_cc1 %s -triple=x86_64-apple-macos -target-feature +avx -verify=no512-err -o - -S
47
// REQUIRES: x86-registered-target
58

69
// both-no-diagnostics
@@ -31,12 +34,12 @@ void call_warn(void) {
3134
// If only 1 side has an attribute, error.
3235
void call_errors(void) {
3336
avx256Type t1;
34-
takesAvx256(t1); // no256-error {{AVX vector argument of type 'avx256Type' (vector of 16 'short' values) without 'avx' enabled changes the ABI}}
37+
takesAvx256(t1); // no256-err-error {{AVX vector argument of type 'avx256Type' (vector of 16 'short' values) without 'avx' enabled changes the ABI}}
3538
avx512fType t2;
36-
takesAvx512(t2); // no512-error {{AVX vector argument of type 'avx512fType' (vector of 32 'short' values) without 'avx512f' enabled changes the ABI}}
39+
takesAvx512(t2); // no512-err-error {{AVX vector argument of type 'avx512fType' (vector of 32 'short' values) without 'avx512f' enabled changes the ABI}}
3740

38-
variadic_err(1, t1); // no256-error {{AVX vector argument of type 'avx256Type' (vector of 16 'short' values) without 'avx' enabled changes the ABI}}
39-
variadic_err(3, t2); // no512-error {{AVX vector argument of type 'avx512fType' (vector of 32 'short' values) without 'avx512f' enabled changes the ABI}}
41+
variadic_err(1, t1); // no256-err-error {{AVX vector argument of type 'avx256Type' (vector of 16 'short' values) without 'avx' enabled changes the ABI}}
42+
variadic_err(3, t2); // no512-err-error {{AVX vector argument of type 'avx512fType' (vector of 32 'short' values) without 'avx512f' enabled changes the ABI}}
4043
}
4144

4245
// These two don't diagnose anything, since these are valid calls.

clang/test/CodeGen/target-builtin-error-3.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,5 @@ static inline half16 __attribute__((__overloadable__)) convert_half( float16 a )
2424
}
2525
void avx_test( uint16_t *destData, float16 argbF)
2626
{
27-
// expected-warning@+1{{AVX vector argument of type 'float16' (vector of 16 'float' values) without 'avx512f' enabled changes the ABI}}
2827
((half16U *)destData)[0] = convert_half(argbF);
2928
}

0 commit comments

Comments
 (0)