public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/100425] New: missing -Walloca-larger-than with -O0
@ 2021-05-04 22:14 msebor at gcc dot gnu.org
  2021-05-10 20:03 ` [Bug middle-end/100425] " cvs-commit at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-05-04 22:14 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100425

            Bug ID: 100425
           Summary: missing -Walloca-larger-than with -O0
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

The gimple-ssa-warn-alloca.c pass only both with and without optimization and
-Walloca triggers when it's enabled but the more useful -Walloca-larger-than
fails to diagnose the excessive constant allocations because at -O0 the pass
only runs when -Walloca is enabled and not when -Walloca-larger-than.  The pass
should run for both warning options even at -O0 and only diagnose the subset it
can reliably detect.

$ cat z.c && gcc -S -Wall -fdump-tree-lower=/dev/stdout
-Walloca-larger-than=100 z.c 
void f (void*);

void g (void)
{
  f (__builtin_alloca (1234));
}

#pragma GCC diagnostic error "-Walloca"

void h (void)
{
  f (__builtin_alloca (1234));
}


;; Function g (g, funcdef_no=0, decl_uid=1945, cgraph_uid=1, symbol_order=0)

void g ()
{
  _1 = __builtin_alloca (1234);
  f (_1);
  return;
}



;; Function h (h, funcdef_no=1, decl_uid=1948, cgraph_uid=2, symbol_order=1)

void h ()
{
  _1 = __builtin_alloca (1234);
  f (_1);
  return;
}


z.c: In function ‘h’:
z.c:12:3: error: use of ‘alloca’ [-Werror=alloca]
   12 |   f (__builtin_alloca (1234));
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug middle-end/100425] missing -Walloca-larger-than with -O0
  2021-05-04 22:14 [Bug middle-end/100425] New: missing -Walloca-larger-than with -O0 msebor at gcc dot gnu.org
@ 2021-05-10 20:03 ` cvs-commit at gcc dot gnu.org
  2021-05-10 20:05 ` msebor at gcc dot gnu.org
  2021-05-10 20:06 ` msebor at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-05-10 20:03 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100425

--- Comment #1 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Martin Sebor <msebor@gcc.gnu.org>:

https://gcc.gnu.org/g:f974b54b8a0c330e9dd2b43ebc940100d601df0f

commit r12-690-gf974b54b8a0c330e9dd2b43ebc940100d601df0f
Author: Martin Sebor <msebor@redhat.com>
Date:   Mon May 10 14:00:04 2021 -0600

    Avoid -Walloca-larger-than and -Wvla-larger-than false postives and
negatives.

    Resolves:
    PR middle-end/100425 - missing -Walloca-larger-than with -O0
    PR middle-end/100510 - bogus -Wvla-large-than with -Walloca

    gcc/ChangeLog:

            PR middle-end/100425
            PR middle-end/100510
            * gimple-ssa-warn-alloca.c (pass_walloca::firast_time_p): Rename...
            (pass_walloca::xlimit_certain_p): ...to this.
            (pass_walloca::gate): Execute for any kind of handled warning.
            (pass_walloca::execute): Avoid issuing "maybe" and "unbounded"
            warnings when xlimit_certain_p is set.

    gcc/testsuite/ChangeLog:

            PR middle-end/100425
            PR middle-end/100510
            * c-c++-common/Walloca-larger-than.C: New test.
            * gcc.dg/Walloca-larger-than-4.c: New test.
            * gcc.dg/Wvla-larger-than-5.c: New test.
            * gcc.dg/pr79972.c: Remove unexpected warning directive.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug middle-end/100425] missing -Walloca-larger-than with -O0
  2021-05-04 22:14 [Bug middle-end/100425] New: missing -Walloca-larger-than with -O0 msebor at gcc dot gnu.org
  2021-05-10 20:03 ` [Bug middle-end/100425] " cvs-commit at gcc dot gnu.org
@ 2021-05-10 20:05 ` msebor at gcc dot gnu.org
  2021-05-10 20:06 ` msebor at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-05-10 20:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100425

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |msebor at gcc dot gnu.org
             Status|UNCONFIRMED                 |RESOLVED
           Keywords|                            |patch
         Resolution|---                         |FIXED

--- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> ---
Patch (https://gcc.gnu.org/pipermail/gcc-patches/2021-May/569571.html)
committed in r12-690.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug middle-end/100425] missing -Walloca-larger-than with -O0
  2021-05-04 22:14 [Bug middle-end/100425] New: missing -Walloca-larger-than with -O0 msebor at gcc dot gnu.org
  2021-05-10 20:03 ` [Bug middle-end/100425] " cvs-commit at gcc dot gnu.org
  2021-05-10 20:05 ` msebor at gcc dot gnu.org
@ 2021-05-10 20:06 ` msebor at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-05-10 20:06 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100425

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |12.0

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-05-10 20:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-04 22:14 [Bug middle-end/100425] New: missing -Walloca-larger-than with -O0 msebor at gcc dot gnu.org
2021-05-10 20:03 ` [Bug middle-end/100425] " cvs-commit at gcc dot gnu.org
2021-05-10 20:05 ` msebor at gcc dot gnu.org
2021-05-10 20:06 ` msebor at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).