This is an archive of the discontinued LLVM Phabricator instance.

[builtins] Build with -Wbuiltin-declaration-mismatch if supported
ClosedPublic

Authored by arichardson on Jun 26 2023, 1:48 PM.

Details

Summary

GCC is able to check that the signatures of the builtins are as expected
and this shows some incorrect signatures on ld80 platforms (i.e. x86).
The *tf* functions should take 128-bit arguments but until the latest fixes
they used 80-bit long double.

Diff Detail

Event Timeline

arichardson created this revision.Jun 26 2023, 1:48 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 26 2023, 1:48 PM
Herald added subscribers: Enna1, pengfei. · View Herald Transcript
arichardson requested review of this revision.Jun 26 2023, 1:48 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 26 2023, 1:48 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript

Do you have an example how this is useful for lib/builtins functions? I think GCC -Wbuiltin-declaration-mismatch is enabled by default and applies to C standard functions (e.g., printf), but I cannot get it to warn on libgcc_s.so.1 functions, e.g.

% cat a.c
float __extendhfdf2(float a) { return a; }
% gcc -c a.c -Wbuiltin-declaration-mismatch  # no warning

Do you have an example how this is useful for lib/builtins functions? I think GCC -Wbuiltin-declaration-mismatch is enabled by default and applies to C standard functions (e.g., printf), but I cannot get it to warn on libgcc_s.so.1 functions, e.g.

% cat a.c
float __extendhfdf2(float a) { return a; }
% gcc -c a.c -Wbuiltin-declaration-mismatch  # no warning

I only see one error right now:

compiler-rt/lib/builtins/divtc3.c:20:26: error: conflicting types for built-in function ‘__divtc3’; expected ‘_Complex _Float128(_Float128,  _Float128,  _Float128,  _Float128)’ [-Werror=builtin-declaration-mismatch]
   20 | COMPILER_RT_ABI Lcomplex __divtc3(long double __a, long double __b,
      |                          ^~~~~~~~

So, yes this is of limited usefulness, but it did catch one incorrect declaration.

compnerd accepted this revision.Jul 25 2023, 8:00 AM

I don't see any harm in adding the additional flag, the overall complexity is pretty simple and is more a patterned extension.

This revision is now accepted and ready to land.Jul 25 2023, 8:00 AM