This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PR 29585: C++ front end not setting TREE_ADDRESSABLE on vtbl entries
- From: Diego Novillo <dnovillo at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org, Mark Mitchell <mark at codesourcery dot com>
- Date: Sat, 31 Mar 2007 14:03:12 -0400
- Subject: PR 29585: C++ front end not setting TREE_ADDRESSABLE on vtbl entries
As discussed in http://gcc.gnu.org/ml/gcc/2007-03/msg01153.html, the C++
front end is building ADDR_EXPRs for vtbl entries but is not setting
TREE_ADDRESSABLE consistently.
This is causing the setup routines in alias analysis to ignore these
variables. But during analysis, we add them to points-to and alias
sets. Since the variables had been initially ignored, they don't get
marked for renaming, causing an ICE during conversion to SSA.
The approach I tried initially is to make the aliaser very strict in
asserting the addressability of every symbol added to an alias set.
This uncovers various inconsistencies in C, C++ and Java FEs. So, the
idea is to make everything consistent by forcing build1() to set
TREE_ADDRESSABLE every time it's asked to build ADDR_EXPR. This caused
some controversy, so I will not attempt that on 4.2.
The minimal fix that I found for 4.2 is along the lines of what Mark and
Jason suggested. I did have to try a variation of Mark's suggestion of
building a NOP_EXPR in dfs_accumulate_vtbl_inits, because that was
causing ICEs elsewhere in other functions not expecting a NOP_EXPR.
Bootstrapped on i686, x86_64, ppc64 and ia64.
OK for 4.2? For 4.3 I will use the sane approach of forcing
TREE_ADDRESSABLE for every ADDR_EXPR built.
2007-03-30 Diego Novillo <dnovillo@redhat.com>
Mark Mitchell <mark@codesourcery.com>
PR 29585
* class.c (dfs_accumulate_vtbl_inits): Use build_address
to build the vtbl entry.
testsuite/ChangeLog
PR 29585
* g++.dg/tree-ssa/pr29585.C: New test.
Index: testsuite/g++.dg/tree-ssa/pr29585.C
===================================================================
--- testsuite/g++.dg/tree-ssa/pr29585.C (revision 0)
+++ testsuite/g++.dg/tree-ssa/pr29585.C (revision 0)
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+class ios_base{};
+struct basic_ostream : virtual ios_base{};
+namespace
+{
+ struct Nullostream : basic_ostream{};
+}
+class In
+{
+ In ();
+ Nullostream nullout;
+};
+In::In (){}
Index: cp/class.c
===================================================================
--- cp/class.c (revision 123332)
+++ cp/class.c (working copy)
@@ -7101,7 +7101,7 @@ dfs_accumulate_vtbl_inits (tree binfo,
/* Figure out the position to which the VPTR should point. */
vtbl = TREE_PURPOSE (l);
- vtbl = build1 (ADDR_EXPR, vtbl_ptr_type_node, vtbl);
+ vtbl = build_address (vtbl);
index = size_binop (PLUS_EXPR,
size_int (non_fn_entries),
size_int (list_length (TREE_VALUE (l))));