On Wed, May 5, 2021 at 7:29 PM Martin Sebor <mse...@gmail.com> wrote: > > On 5/5/21 1:32 AM, Richard Biener wrote: > > On Wed, May 5, 2021 at 4:20 AM Martin Sebor via Gcc-patches > > <gcc-patches@gcc.gnu.org> wrote: > >> > >> Even when explicitly enabled, -Walloca-larger-than doesn't run > >> unless optimization is enabled as well. This prevents diagnosing > >> alloca calls with constant arguments in excess of the limit that > >> could otherwise be flagged even at -O0, making the warning less > >> consistent and less useful than is possible. > >> > >> The attached patch enables -Walloca-larger-than for calls with > >> constant arguments in excess of the limit even at -O0 (variable > >> arguments are only handled with optimization, when VRP runs). > > > > Hmm, but then the pass runs even without -Walloca or -Walloca-larger-than > > or -Wvla[-larger-than]. It performs an IL walk we should avoid in those > > cases. > > > > So the patch is OK but can you please come up with a gate that disables > > the pass when all of the warnings it handles won't fire anyway? > > -W{alloca,vla}-larger-than=PTRDIFF_MAX are enabled by default so > the pass needs to do walk. > > FWIW, it would make sense to me to consolidate all the checking of > calls for arguments with excessive sizes/values into the same pass > and single walk (with code still in separate source files). As it > is, some are done in their own passes (like alloca and sprintf), > and others during expansion (-Wstringop-overflow), and others in > calls.c (-Walloc-size-larger-than). That leads to repetitive code > and inconsistent approaches and inconsistent false positives and > negatives (because some are done at -O0 but others require > optimization).
True - that would be a nice cleanup (and speedup as well). Richard. > Martin > > > > > Thanks, > > Richard. > > > >> Martin >