Skip to content

Commit 67b06b4

Browse files
jroelofstru
authored andcommitted
[clang][AArch64] Point the nofp ABI check diagnostics at the callee (llvm#103392)
... whereever we have the Decl for it, and even when we don't keep the SourceLocation of it aimed at the call site. Fixes: llvm#102983 (cherry picked from commit 019ef52)
1 parent ca3f3f6 commit 67b06b4

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

clang/lib/CodeGen/Targets/AArch64.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -840,12 +840,13 @@ static bool isStreamingCompatible(const FunctionDecl *F) {
840840
static void diagnoseIfNeedsFPReg(DiagnosticsEngine &Diags,
841841
const StringRef ABIName,
842842
const AArch64ABIInfo &ABIInfo,
843-
const QualType &Ty, const NamedDecl *D) {
843+
const QualType &Ty, const NamedDecl *D,
844+
SourceLocation loc) {
844845
const Type *HABase = nullptr;
845846
uint64_t HAMembers = 0;
846847
if (Ty->isFloatingType() || Ty->isVectorType() ||
847848
ABIInfo.isHomogeneousAggregate(Ty, HABase, HAMembers)) {
848-
Diags.Report(D->getLocation(), diag::err_target_unsupported_type_for_abi)
849+
Diags.Report(loc, diag::err_target_unsupported_type_for_abi)
849850
<< D->getDeclName() << Ty << ABIName;
850851
}
851852
}
@@ -860,10 +861,11 @@ void AArch64TargetCodeGenInfo::checkFunctionABI(
860861

861862
if (!TI.hasFeature("fp") && !ABIInfo.isSoftFloat()) {
862863
diagnoseIfNeedsFPReg(CGM.getDiags(), TI.getABI(), ABIInfo,
863-
FuncDecl->getReturnType(), FuncDecl);
864+
FuncDecl->getReturnType(), FuncDecl,
865+
FuncDecl->getLocation());
864866
for (ParmVarDecl *PVD : FuncDecl->parameters()) {
865867
diagnoseIfNeedsFPReg(CGM.getDiags(), TI.getABI(), ABIInfo, PVD->getType(),
866-
PVD);
868+
PVD, FuncDecl->getLocation());
867869
}
868870
}
869871
}
@@ -908,11 +910,11 @@ void AArch64TargetCodeGenInfo::checkFunctionCallABISoftFloat(
908910
return;
909911

910912
diagnoseIfNeedsFPReg(CGM.getDiags(), TI.getABI(), ABIInfo, ReturnType,
911-
Caller);
913+
Callee ? Callee : Caller, CallLoc);
912914

913915
for (const CallArg &Arg : Args)
914916
diagnoseIfNeedsFPReg(CGM.getDiags(), TI.getABI(), ABIInfo, Arg.getType(),
915-
Caller);
917+
Callee ? Callee : Caller, CallLoc);
916918
}
917919

918920
void AArch64TargetCodeGenInfo::checkFunctionCallABI(CodeGenModule &CGM,

clang/test/CodeGen/aarch64-soft-float-abi-errors.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,15 @@ inline void test_float_arg_inline(float a) {}
6969
inline void test_float_arg_inline_used(float a) {}
7070
// nofp-hard-opt-error@-1 {{'a' requires 'float' type support, but ABI 'aapcs' does not support it}}
7171
void use_inline() { test_float_arg_inline_used(1.0f); }
72-
// nofp-hard-error@-1 {{'use_inline' requires 'float' type support, but ABI 'aapcs' does not support it}}
72+
// nofp-hard-error@-1 {{'test_float_arg_inline_used' requires 'float' type support, but ABI 'aapcs' does not support it}}
7373

7474
// The always_inline attribute causes an inline function to always be
7575
// code-genned, even at -O0, so we always emit the error.
7676
__attribute((always_inline))
7777
inline void test_float_arg_always_inline_used(float a) {}
7878
// nofp-hard-error@-1 {{'a' requires 'float' type support, but ABI 'aapcs' does not support it}}
7979
void use_always_inline() { test_float_arg_always_inline_used(1.0f); }
80-
// nofp-hard-error@-1 {{'use_always_inline' requires 'float' type support, but ABI 'aapcs' does not support it}}
80+
// nofp-hard-error@-1 {{'test_float_arg_always_inline_used' requires 'float' type support, but ABI 'aapcs' does not support it}}
8181

8282
// Floating-point expressions, global variables and local variables do not
8383
// affect the ABI, so are allowed. GCC does reject some uses of floating point
@@ -103,9 +103,9 @@ int test_var_double(int a) {
103103
extern void extern_float_arg(float);
104104
extern float extern_float_ret(void);
105105
void call_extern_float_arg() { extern_float_arg(1.0f); }
106-
// nofp-hard-error@-1 {{'call_extern_float_arg' requires 'float' type support, but ABI 'aapcs' does not support it}}
106+
// nofp-hard-error@-1 {{'extern_float_arg' requires 'float' type support, but ABI 'aapcs' does not support it}}
107107
void call_extern_float_ret() { extern_float_ret(); }
108-
// nofp-hard-error@-1 {{'call_extern_float_ret' requires 'float' type support, but ABI 'aapcs' does not support it}}
108+
// nofp-hard-error@-1 {{'extern_float_ret' requires 'float' type support, but ABI 'aapcs' does not support it}}
109109

110110
// Definitions of variadic functions, and calls to them which only use integer
111111
// argument registers, are both fine.
@@ -115,7 +115,7 @@ void call_variadic_int() { variadic(0, 1); }
115115
// Calls to variadic functions with floating-point arguments are an error,
116116
// since this would require floating-point registers.
117117
void call_variadic_double() { variadic(0, 1.0); }
118-
// nofp-hard-error@-1 {{'call_variadic_double' requires 'double' type support, but ABI 'aapcs' does not support it}}
118+
// nofp-hard-error@-1 {{'variadic' requires 'double' type support, but ABI 'aapcs' does not support it}}
119119

120120
// Calls through function pointers are also diagnosed.
121121
void (*fptr)(float);

0 commit comments

Comments
 (0)