With this implementation "-Wstack-usage" acts as an alias to
|101 ↗||(On Diff #346482)|
Since GCC supports the negative option -Wno-stack-usage, I think it is best to add the negative option Wno-frame-larger-than in the td file and alias it too, to avoid this C code in here.
Thanks for reviewing @bruno doesn't look like the failure is related to my change:
"No space left on device"
Unless I am looking at the wrong thing.
Does this mean:
This function has no "stack frame" in the usual sense of the word, because it's just
movl %edi, %eax imull %edi, %eax ret
So am I correct to infer that the -Wstack-usage= option includes the size of the return address in its computations? So the stack usage of this function would be computed as "8 bytes" because the callq instruction pushes 8 bytes on the stack?
Looking at how the value for this flag is obtained, which is an alias of "-Wframe-larger-than", I see that it is all objects placed on the stack by each function plus any space reserved for arguments of callsites in the function.
There is no precise definition of what is included as it depends on the target as well as what is stored on the stack or not.
I guess in simplest terms, for each function this will report how much stack space is used by that function.
When a function stores the return address on the stack, that will be included in that functions stack usage.
ping @Quuxplusone this is being used as a diagnostic flag that aliases "-Wframe-larger-than", I think if we want to add more user-facing documentation to clarify things we should revisit what the "-Wframe-larger-than=" tracks as well. Currently there isn't too much info on that flag either.
Does adding this alias unblock some applications?
In GCC -Wstack-usage= is more powerful. It can check warning: stack usage might be unbounded.
Having this alias could give false impression that we have implemented the powerful detection usage.
If we don't actually implement the -Wstack-usage= functionality, I'd hope that applications consciously and gracefully degrade to -Wframe-larger-than=, instead of using the half-functional -Wstack-usage.
Do your applications parse the diagnostic to take some actions? Note that clang diagnostic format is different from GCC's.
If you need any adaptation, can you just change the -Wstack-usage= option to -Wframe-larger-than= (the former is stronger but Clang doesn't implement the full functionality)?
This was discussed in llvm-dev mailing list, and originally we had a change that was closer to what GCC was reporting however there was no consensus on what was needed. The purpose of this change is to bring parity in terms of available options with GCC. @lebedev.ri could you chime in on what your specific use for this flag is?