This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH: AIX vtables
- To: gcc-patches at gcc dot gnu dot org
- Subject: C++ PATCH: AIX vtables
- From: Mark Mitchell <mark at codesourcery dot com>
- Date: Wed, 15 Nov 2000 10:29:16 -0800
- Organization: CodeSourcery, LLC
This patch fixes a problem David Edelsohn ran into on AIX whereby we
weren't emitting as many vtables as we should have.
The problem was that we created a COMDAT vtable, but on AIX there's no
COMDAT, so we made it static. Since it was static and
DECL_ARTIFICIAL, this patch:
2000-03-10 Jason Merrill <jason@casey.cygnus.com>
* semantics.c (expand_stmt): Only leave out rtl for unused
artificials, and set DECL_IGNORED_P on them as well.
* decl.c (wrapup_globals_for_namespace): Likewise.
kicked in. This patch works incorrectly because it sets
TREE_ASM_WRITTEN, and wrapup_globals_for_namespace can be called more
than once. So, if we don't need the vtable the first time around, we
mark it written out; then we find out we really do need it, we think
we've already written it out.
I fixed the bug Jason was originally targetting by moving the
DECL_ARTIFICIAL check into wrapup_global_declarations; there's no need
to emit a DECL_ARTIFICIAL static variable that is never referenced.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
2000-11-15 Mark Mitchell <mark@codesourcery.com>
* toplev.c (wrapup_global_declarations): Don't write out
artificial static variables that aren't needed.
2000-11-15 Mark Mitchell <mark@codesourcery.com>
* decl.c (wrapup_globals_for_namespace): Don't mark things
TREE_ASM_WRITTEN when they're not.
Index: toplev.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/toplev.c,v
retrieving revision 1.395
diff -c -p -r1.395 toplev.c
*** toplev.c 2000/11/10 11:43:42 1.395
--- toplev.c 2000/11/15 18:15:36
*************** wrapup_global_declarations (vec, len)
*** 1951,1957 ****
if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
&& (! TREE_READONLY (decl)
|| TREE_PUBLIC (decl)
! || (!optimize && flag_keep_static_consts)
|| TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
{
reconsider = 1;
--- 1951,1959 ----
if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
&& (! TREE_READONLY (decl)
|| TREE_PUBLIC (decl)
! || (!optimize
! && flag_keep_static_consts
! && !DECL_ARTIFICIAL (decl))
|| TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
{
reconsider = 1;
Index: cp/decl.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/decl.c,v
retrieving revision 1.711
diff -c -p -r1.711 decl.c
*** decl.c 2000/11/11 23:50:19 1.711
--- decl.c 2000/11/15 18:15:46
*************** wrapup_globals_for_namespace (namespace,
*** 1926,1945 ****
/* Process the decls in reverse order--earliest first.
Put them into VEC from back to front, then take out from front. */
-
for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
! {
! /* Pretend we've output an unused static variable. This ensures
! that the toplevel __FUNCTION__ etc won't be emitted, unless
! needed. */
! if (TREE_CODE (decl) == VAR_DECL && DECL_ARTIFICIAL (decl)
! && !TREE_PUBLIC (decl) && !TREE_USED (decl))
! {
! TREE_ASM_WRITTEN (decl) = 1;
! DECL_IGNORED_P (decl) = 1;
! }
! vec[len - i - 1] = decl;
! }
if (last_time)
{
--- 1926,1933 ----
/* Process the decls in reverse order--earliest first.
Put them into VEC from back to front, then take out from front. */
for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
! vec[len - i - 1] = decl;
if (last_time)
{