[PATCH] D104667: Improve the diagnostic of DiagnosticInfoStackSize (and warn-stack-size in particular)

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 21 13:58:32 PDT 2021


MaskRay added a comment.

In D104667#2831507 <https://reviews.llvm.org/D104667#2831507>, @nickdesaulniers wrote:

> In D104667#2831505 <https://reviews.llvm.org/D104667#2831505>, @MaskRay wrote:
>
>> In D104667#2831488 <https://reviews.llvm.org/D104667#2831488>, @nickdesaulniers wrote:
>>
>>> GCC trunk: `warning: the frame size of 80 bytes is larger than 0 bytes [-Wframe-larger-than=]`
>>> Clang trunk: `warning: stack frame size of 88 bytes in function 'bar' [-Wframe-larger-than]`
>>>
>>> looks like the frontend doesn't use this particular text at all?
>>
>> This diagnostic is emitted by clang (`clang/lib/CodeGen/CodeGenAction.cpp`).
>>
>> -Wframe-larger-than= also records the module flag metadata "warn-stack-size" which can be useful for LTO.
>>
>>   % fclang -Wframe-larger-than=100 a.c  -o x          
>>   a.c:1:5: warning: stack frame size of 888 bytes in function 'main' [-Wframe-larger-than]
>>   int main(){
>>       ^
>>   1 warning generated.
>>   % fclang -Wframe-larger-than=100 -flto=thin -fuse-ld=lld a.c -o x
>>   ld.lld: warning: stack size limit exceeded (888) in main
>
> Can we try to make the FE match what's printed during LTO? It's odd that they differ, IMO. Also, GCC prints the threshold value, as does our backend; but the frontend still does not.

How about `warning: stack frame size (88) exceeds limit (80) in function 'warn'` for `"warn-stack-size"` (currently a module flag metadata, will soon become a function attribute)?

I can make the clang diagnostic match this style, too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104667



More information about the llvm-commits mailing list