public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/60221] New: gcc -fexceptions generates unnecessary cleanup code
@ 2014-02-16  3:46 redlizard at redlizard dot nl
  2014-02-16  4:55 ` [Bug middle-end/60221] " pinskia at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: redlizard at redlizard dot nl @ 2014-02-16  3:46 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60221

            Bug ID: 60221
           Summary: gcc -fexceptions generates unnecessary cleanup code
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redlizard at redlizard dot nl

> gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/tmp/gcc-4.8.2/libexec/gcc/x86_64-unknown-linux-gnu/4.8.2/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-4.8.2/configure --prefix=/tmp/gcc-4.8.2
--enable-languages=c,c++
Thread model: posix
gcc version 4.8.2 (GCC)


> cat test.c
void bar(void);
void foo(void)
{
  struct { int x; } y;
  bar();
}


When compiled with `gcc -fexceptions -O0 -c test.c`, the above code generates
cleanup code for stack unwinding purposes, referencing __gcc_personality_v0;
this necessitates linking with shared-libgcc.

I am not sure this is really a bug, but versions of gcc older than 4.7 do not
generate cleanup code for this example; neither does gcc 4.8 when the local
variable is replaced by `int y;`. Moreover, according to the gcc documentation,
there are "several situations" (I have been unable to find more a detailed
specification) in which linking with shared-libgcc is necessary, which includes
code throwing or catching exceptions, but should -- as far as I can see --
*not* include c code just passing through exceptions.

Tested on x86_64-unknown-linux-gnu, x86_64-unknown-linux-gnu -m32, and
i386-pc-solaris2.11, using gcc 4.7.1, 4.7.3, and 4.8.2. gcc 4.6.4 and earlier
tested versions are not affected. I have been unable to test gcc 4.7.0.


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

* [Bug middle-end/60221] gcc -fexceptions generates unnecessary cleanup code
  2014-02-16  3:46 [Bug c/60221] New: gcc -fexceptions generates unnecessary cleanup code redlizard at redlizard dot nl
@ 2014-02-16  4:55 ` pinskia at gcc dot gnu.org
  2014-02-17 12:32 ` [Bug middle-end/60221] [4.7/4.8/4.9 Regression] " rguenth at gcc dot gnu.org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2014-02-16  4:55 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60221

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |missed-optimization
          Component|c                           |middle-end

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Still fails as of:
    .ident    "GCC: (GNU) 4.9.0 20131110 (experimental) [trunk revision
204654]"


I thought I saw a dup of this bug.  It is just a missed optimization at -O0
which was introduced by the addition of the CLOBBERing of local non-scalars.


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

* [Bug middle-end/60221] [4.7/4.8/4.9 Regression] gcc -fexceptions generates unnecessary cleanup code
  2014-02-16  3:46 [Bug c/60221] New: gcc -fexceptions generates unnecessary cleanup code redlizard at redlizard dot nl
  2014-02-16  4:55 ` [Bug middle-end/60221] " pinskia at gcc dot gnu.org
@ 2014-02-17 12:32 ` rguenth at gcc dot gnu.org
  2014-02-17 15:41 ` jakub at gcc dot gnu.org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-02-17 12:32 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60221

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |EH
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-02-17
                 CC|                            |hubicka at gcc dot gnu.org,
                   |                            |matz at gcc dot gnu.org
   Target Milestone|---                         |4.7.4
            Summary|gcc -fexceptions generates  |[4.7/4.8/4.9 Regression]
                   |unnecessary cleanup code    |gcc -fexceptions generates
                   |                            |unnecessary cleanup code
     Ever confirmed|0                           |1

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.


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

* [Bug middle-end/60221] [4.7/4.8/4.9 Regression] gcc -fexceptions generates unnecessary cleanup code
  2014-02-16  3:46 [Bug c/60221] New: gcc -fexceptions generates unnecessary cleanup code redlizard at redlizard dot nl
  2014-02-16  4:55 ` [Bug middle-end/60221] " pinskia at gcc dot gnu.org
  2014-02-17 12:32 ` [Bug middle-end/60221] [4.7/4.8/4.9 Regression] " rguenth at gcc dot gnu.org
@ 2014-02-17 15:41 ` jakub at gcc dot gnu.org
  2014-02-18 10:41 ` rguenth at gcc dot gnu.org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-02-17 15:41 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60221

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I'm not aware of a dup, but this has been recently discussed on gcc-patches,
see the
http://gcc.gnu.org/ml/gcc-patches/2014-01/msg01200.html
thread.


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

* [Bug middle-end/60221] [4.7/4.8/4.9 Regression] gcc -fexceptions generates unnecessary cleanup code
  2014-02-16  3:46 [Bug c/60221] New: gcc -fexceptions generates unnecessary cleanup code redlizard at redlizard dot nl
                   ` (2 preceding siblings ...)
  2014-02-17 15:41 ` jakub at gcc dot gnu.org
@ 2014-02-18 10:41 ` rguenth at gcc dot gnu.org
  2014-02-20  9:01 ` rguenth at gcc dot gnu.org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-02-18 10:41 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60221

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
Note that we do run ehcleanup2 at -O0, but we have EH unsplitting and empty
EH removal disabled if not optimizing.

So we could simply do

Index: tree-eh.c
===================================================================
--- tree-eh.c   (revision 207837)
+++ tree-eh.c   (working copy)
@@ -4557,11 +4557,12 @@ execute_cleanup_eh_1 (void)
   remove_unreachable_handlers ();

   /* Watch out for the region tree vanishing due to all unreachable.  */
-  if (cfun->eh->region_tree && optimize)
+  if (cfun->eh->region_tree)
     {
       bool changed = false;

-      changed |= unsplit_all_eh ();
+      if (optimize)
+       changed |= unsplit_all_eh ();
       changed |= cleanup_all_empty_eh ();

       if (changed)

Testing that.


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

* [Bug middle-end/60221] [4.7/4.8/4.9 Regression] gcc -fexceptions generates unnecessary cleanup code
  2014-02-16  3:46 [Bug c/60221] New: gcc -fexceptions generates unnecessary cleanup code redlizard at redlizard dot nl
                   ` (3 preceding siblings ...)
  2014-02-18 10:41 ` rguenth at gcc dot gnu.org
@ 2014-02-20  9:01 ` rguenth at gcc dot gnu.org
  2014-02-20 22:09 ` [Bug middle-end/60221] [4.7/4.8 " redlizard at redlizard dot nl
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-02-20  9:01 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60221

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
Author: rguenth
Date: Thu Feb 20 09:00:23 2014
New Revision: 207937

URL: http://gcc.gnu.org/viewcvs?rev=207937&root=gcc&view=rev
Log:
2014-02-20  Richard Biener  <rguenther@suse.de>

    PR middle-end/60221
    * tree-eh.c (execute_cleanup_eh_1): Also cleanup empty EH
    regions at -O0.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/tree-eh.c


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

* [Bug middle-end/60221] [4.7/4.8 Regression] gcc -fexceptions generates unnecessary cleanup code
  2014-02-16  3:46 [Bug c/60221] New: gcc -fexceptions generates unnecessary cleanup code redlizard at redlizard dot nl
                   ` (4 preceding siblings ...)
  2014-02-20  9:01 ` rguenth at gcc dot gnu.org
@ 2014-02-20 22:09 ` redlizard at redlizard dot nl
  2014-02-21  9:16 ` rguenther at suse dot de
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: redlizard at redlizard dot nl @ 2014-02-20 22:09 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60221

--- Comment #6 from Ruud Koolen <redlizard at redlizard dot nl> ---
This fix solves my original problem. Resolved, as far as I'm concerned.

Will this fix also be applied to 4.7 and 4.8?


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

* [Bug middle-end/60221] [4.7/4.8 Regression] gcc -fexceptions generates unnecessary cleanup code
  2014-02-16  3:46 [Bug c/60221] New: gcc -fexceptions generates unnecessary cleanup code redlizard at redlizard dot nl
                   ` (5 preceding siblings ...)
  2014-02-20 22:09 ` [Bug middle-end/60221] [4.7/4.8 " redlizard at redlizard dot nl
@ 2014-02-21  9:16 ` rguenther at suse dot de
  2014-02-25 10:47 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenther at suse dot de @ 2014-02-21  9:16 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60221

--- Comment #7 from rguenther at suse dot de <rguenther at suse dot de> ---
On Thu, 20 Feb 2014, redlizard at redlizard dot nl wrote:

> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60221
> 
> --- Comment #6 from Ruud Koolen <redlizard at redlizard dot nl> ---
> This fix solves my original problem. Resolved, as far as I'm concerned.
> 
> Will this fix also be applied to 4.7 and 4.8?

After some time and no problems show up, yes.  I expect it to hit
4.8.3 at least, not sure about 4.7.


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

* [Bug middle-end/60221] [4.7/4.8 Regression] gcc -fexceptions generates unnecessary cleanup code
  2014-02-16  3:46 [Bug c/60221] New: gcc -fexceptions generates unnecessary cleanup code redlizard at redlizard dot nl
                   ` (6 preceding siblings ...)
  2014-02-21  9:16 ` rguenther at suse dot de
@ 2014-02-25 10:47 ` rguenth at gcc dot gnu.org
  2014-02-25 10:48 ` [Bug middle-end/60221] [4.7 " rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-02-25 10:47 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60221

--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
Author: rguenth
Date: Tue Feb 25 10:47:21 2014
New Revision: 208118

URL: http://gcc.gnu.org/viewcvs?rev=208118&root=gcc&view=rev
Log:
2014-02-25  Richard Biener  <rguenther@suse.de>

    Backport from mainline
    2014-02-21  Richard Biener  <rguenther@suse.de>

    PR middle-end/60291
    * tree-ssa-live.c (mark_all_vars_used_1): Do not walk
    DECL_INITIAL for globals not in the current function context.

    2014-02-20  Richard Biener  <rguenther@suse.de>

    PR middle-end/60221
    * tree-eh.c (execute_cleanup_eh_1): Also cleanup empty EH
    regions at -O0.

    2014-02-14  Richard Biener  <rguenther@suse.de>

    PR tree-optimization/60183
    * tree-ssa-phiprop.c (propagate_with_phi): Avoid speculating
    loads.
    (tree_ssa_phiprop): Calculate and free post-dominators.

    * gcc.dg/torture/pr60183.c: New testcase.

Added:
    branches/gcc-4_8-branch/gcc/testsuite/gcc.dg/torture/pr60183.c
Modified:
    branches/gcc-4_8-branch/gcc/ChangeLog
    branches/gcc-4_8-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_8-branch/gcc/tree-eh.c
    branches/gcc-4_8-branch/gcc/tree-ssa-live.c
    branches/gcc-4_8-branch/gcc/tree-ssa-phiprop.c


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

* [Bug middle-end/60221] [4.7 Regression] gcc -fexceptions generates unnecessary cleanup code
  2014-02-16  3:46 [Bug c/60221] New: gcc -fexceptions generates unnecessary cleanup code redlizard at redlizard dot nl
                   ` (7 preceding siblings ...)
  2014-02-25 10:47 ` rguenth at gcc dot gnu.org
@ 2014-02-25 10:48 ` rguenth at gcc dot gnu.org
  2014-03-09 19:00 ` pinskia at gcc dot gnu.org
  2014-05-23  8:27 ` rguenth at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-02-25 10:48 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60221

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |4.8.3
            Summary|[4.7/4.8 Regression] gcc    |[4.7 Regression] gcc
                   |-fexceptions generates      |-fexceptions generates
                   |unnecessary cleanup code    |unnecessary cleanup code

--- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> ---
And for 4.8.3.


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

* [Bug middle-end/60221] [4.7 Regression] gcc -fexceptions generates unnecessary cleanup code
  2014-02-16  3:46 [Bug c/60221] New: gcc -fexceptions generates unnecessary cleanup code redlizard at redlizard dot nl
                   ` (8 preceding siblings ...)
  2014-02-25 10:48 ` [Bug middle-end/60221] [4.7 " rguenth at gcc dot gnu.org
@ 2014-03-09 19:00 ` pinskia at gcc dot gnu.org
  2014-05-23  8:27 ` rguenth at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2014-03-09 19:00 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60221

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |zosrothko at orange dot fr

--- Comment #10 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 60475 has been marked as a duplicate of this bug. ***


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

* [Bug middle-end/60221] [4.7 Regression] gcc -fexceptions generates unnecessary cleanup code
  2014-02-16  3:46 [Bug c/60221] New: gcc -fexceptions generates unnecessary cleanup code redlizard at redlizard dot nl
                   ` (9 preceding siblings ...)
  2014-03-09 19:00 ` pinskia at gcc dot gnu.org
@ 2014-05-23  8:27 ` rguenth at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-05-23  8:27 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|4.7.4                       |4.8.3

--- Comment #11 from Richard Biener <rguenth at gcc dot gnu.org> ---
Won't fix for 4.7.4.


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

end of thread, other threads:[~2014-05-23  8:27 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-16  3:46 [Bug c/60221] New: gcc -fexceptions generates unnecessary cleanup code redlizard at redlizard dot nl
2014-02-16  4:55 ` [Bug middle-end/60221] " pinskia at gcc dot gnu.org
2014-02-17 12:32 ` [Bug middle-end/60221] [4.7/4.8/4.9 Regression] " rguenth at gcc dot gnu.org
2014-02-17 15:41 ` jakub at gcc dot gnu.org
2014-02-18 10:41 ` rguenth at gcc dot gnu.org
2014-02-20  9:01 ` rguenth at gcc dot gnu.org
2014-02-20 22:09 ` [Bug middle-end/60221] [4.7/4.8 " redlizard at redlizard dot nl
2014-02-21  9:16 ` rguenther at suse dot de
2014-02-25 10:47 ` rguenth at gcc dot gnu.org
2014-02-25 10:48 ` [Bug middle-end/60221] [4.7 " rguenth at gcc dot gnu.org
2014-03-09 19:00 ` pinskia at gcc dot gnu.org
2014-05-23  8:27 ` rguenth 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).