public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: Jan Hubicka <hubicka@ucw.cz>
To: austern at apple dot com <gcc-bugzilla@gcc.gnu.org>,
	mark@codesourcery.com
Cc: gcc-bugs@gcc.gnu.org
Subject: Re: [Bug c++/14639] New: Incorrect emission of unused compiler-generated destructor at -O2
Date: Sun, 21 Mar 2004 18:26:00 -0000	[thread overview]
Message-ID: <20040321182619.GA28573@atrey.karlin.mff.cuni.cz> (raw)
In-Reply-To: <20040318204634.14639.austern@apple.com>

> Consider the following file:
> class AAA {
> public:
>   virtual ~AAA();
> };
> 
> class BBB {
> public:
>   virtual ~BBB();
> };
> 
> class xyz : public AAA, public BBB {
> public:
>   xyz() : AAA(), BBB() { }
> };
> 
> 
> 
> 
> Class xyz has no key method, so its vtable should be emitted only in translation units where it's used.  
> With "gcc -O0 -c foo.cc" I get what I expect: the compiler doesn't emit _ZTV3xyz, _ZN3xyzD0Ev, or 
> anything else.  With "gcc -O2 -c foo.cc" I get incorrect behavior: the compiler emits xyz's destructor 
> and vtable, thunks, and all of the things in AAA and BBB that are required to support them.
> 
> This is a regression.  In 3.2.2, O0 and O2 both behave correctly.

This can be avoided by disabling following mark_referenced call:

Index: cp/method.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/method.c,v
retrieving revision 1.279
diff -c -3 -p -r1.279 method.c
*** cp/method.c	12 Mar 2004 17:09:01 -0000	1.279
--- cp/method.c	20 Mar 2004 15:27:33 -0000
*************** use_thunk (tree thunk_fndecl, bool emit_
*** 359,365 ****
       this translation unit.  */
    TREE_ADDRESSABLE (function) = 1;
    mark_used (function);
!   mark_referenced (DECL_ASSEMBLER_NAME (function));
    if (!emit_p)
      return;
  
--- 359,365 ----
       this translation unit.  */
    TREE_ADDRESSABLE (function) = 1;
    mark_used (function);
!   /*mark_referenced (DECL_ASSEMBLER_NAME (function));*/
    if (!emit_p)
      return;
  
The problem is that C++ frotnend manages thunks "on the side" and does
not show to backend what DECLs will be used by thunks and what thunks
will be emit.  This is dealt with handling the depenedencies
conservativly.   This line comes from replacing DECL_REFERENCED.* = 1 by
mark_referenced call so I am not quite sure it is still necesary
(testsuite passes without this line).

However we likely need some way to explain backend the hidden
dependencies.  Would it be possible to explain me why exactly the thunk
needs to be output and what DECLs will it reference?
(I know that the thunks are associated to functions and are output at
the same time the function is output and they become needed by
use_thunk, but this all can be overly conservative now)

Honza
> 
> -- 
>            Summary: Incorrect emission of unused compiler-generated
>                     destructor at -O2
>            Product: gcc
>            Version: 3.5.0
>             Status: UNCONFIRMED
>           Severity: normal
>           Priority: P2
>          Component: c++
>         AssignedTo: unassigned at gcc dot gnu dot org
>         ReportedBy: austern at apple dot com
>                 CC: gcc-bugs at gcc dot gnu dot org
>  GCC build triplet: i686-pc-linux-gnu
>   GCC host triplet: i686-pc-linux-gnu
> GCC target triplet: i686-pc-linux-gnu
> 
> 
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14639


  parent reply	other threads:[~2004-03-21 18:26 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-18 20:46 austern at apple dot com
2004-03-19  1:33 ` [Bug c++/14639] [3.4/3.5 Regression] [unit-at-a-time] " pinskia at gcc dot gnu dot org
2004-03-19  2:27 ` mmitchel at gcc dot gnu dot org
2004-03-19  4:02 ` austern at apple dot com
2004-03-19  4:44 ` mark at codesourcery dot com
2004-03-21 18:26 ` hubicka at ucw dot cz
2004-03-21 18:26 ` Jan Hubicka [this message]
2004-03-21 19:25   ` [Bug c++/14639] New: " Mark Mitchell
2004-03-22  9:44     ` Jan Hubicka
2004-03-22 15:31       ` Mark Mitchell
2004-03-23  9:52         ` Jan Hubicka
2004-03-21 19:25 ` [Bug c++/14639] [3.4/3.5 Regression] [unit-at-a-time] " mark at codesourcery dot com
2004-03-21 23:33 ` steven at gcc dot gnu dot org
2004-03-22  9:44 ` jh at suse dot cz
2004-03-22 15:32 ` mark at codesourcery dot com
2004-03-23  9:52 ` jh at suse dot cz
2004-03-23 21:25 ` mark at codesourcery dot com
2004-03-23 21:26 ` mmitchel at gcc dot gnu dot org
2004-03-23 21:26 ` mmitchel at gcc dot gnu dot org
2004-03-24 18:23 ` hubicka at ucw dot cz
2004-03-24 18:44 ` mark at codesourcery dot com
2004-03-24 23:51 ` hubicka at ucw dot cz
2004-03-26  8:23 ` mark at codesourcery dot com
2004-03-26 10:01 ` hubicka at ucw dot cz
2004-03-28 15:42 ` cvs-commit at gcc dot gnu dot org
2004-03-30 13:46 ` [Bug c++/14639] [3.5 " pinskia at gcc dot gnu dot org
2004-06-03 23:27 ` bowdidge at apple dot com
2004-06-03 23:33 ` pinskia at gcc dot gnu dot org
2004-06-03 23:35 ` pinskia at gcc dot gnu dot org
2004-06-03 23:38 ` bowdidge at apple dot com
2004-06-03 23:38 ` mark at codesourcery dot com
2004-06-03 23:45 ` cvs-commit at gcc dot gnu dot org
2004-06-03 23:46 ` pinskia at gcc dot gnu dot org
2004-06-04  0:37 ` bowdidge at apple dot com
2004-06-04  0:38 ` bowdidge at apple dot com
2004-06-04  0:40 ` pinskia at gcc dot gnu dot org
2004-06-04  0:50 ` [Bug c++/14639] [3.5 Regression] [non-unit-at-a-time] " pinskia at gcc dot gnu dot org
2004-06-04  0:58 ` [Bug c++/14639] [3.5 Regression] [non-unit-at-a-time] Incorrect emission of unused compiler-generated destructor bowdidge at apple dot com
2004-06-04  1:09 ` pinskia at gcc dot gnu dot org
2004-06-04  1:50 ` pinskia at gcc dot gnu dot org
2004-06-04  2:12 ` bowdidge at apple dot com
2004-06-04  2:19 ` pinskia at gcc dot gnu dot org
2004-06-04  2:20 ` pinskia at gcc dot gnu dot org
2004-06-04  2:47 ` pinskia at gcc dot gnu dot org
2004-06-04  3:45 ` bowdidge at apple dot com
2004-06-04  4:53 ` bowdidge at apple dot com
2004-06-04  4:58 ` pinskia at gcc dot gnu dot org
2004-06-04 19:13 ` bowdidge at apple dot com
2004-06-04 21:04 ` hubicka at ucw dot cz
2004-06-04 21:11 ` hubicka at ucw dot cz
2004-06-04 21:15 ` bowdidge at apple dot com
2004-06-04 21:16 ` hubicka at ucw dot cz
2004-06-04 21:54 ` bowdidge at apple dot com
2004-06-04 22:59 ` bowdidge at apple dot com
2004-06-05  0:58 ` bowdidge at apple dot com
2004-06-05  1:02 ` bowdidge at apple dot com
2004-06-05  1:19 ` pinskia at gcc dot gnu dot org
2004-06-14 23:56 ` pinskia at gcc dot gnu dot org
2004-06-15  3:43 ` pinskia at gcc dot gnu dot org
2004-06-15 20:52 ` pinskia at gcc dot gnu dot org
2004-06-15 20:52 ` cvs-commit at gcc dot gnu dot org
2004-07-29 18:09 ` pinskia at gcc dot gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040321182619.GA28573@atrey.karlin.mff.cuni.cz \
    --to=hubicka@ucw.cz \
    --cc=gcc-bugs@gcc.gnu.org \
    --cc=gcc-bugzilla@gcc.gnu.org \
    --cc=mark@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).