[Bug c++/14639] [3.4/3.5 Regression] [unit-at-a-time] Incorrect emission of unused compiler-generated destructor at -O2
hubicka at ucw dot cz
gcc-bugzilla@gcc.gnu.org
Sun Mar 21 18:26:00 GMT 2004
------- Additional Comments From hubicka at ucw dot cz 2004-03-21 18:26 -------
Subject: Re: New: Incorrect emission of unused compiler-generated destructor at -O2
> 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
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14639
More information about the Gcc-bugs
mailing list