public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* PR 29585: C++ front end not setting TREE_ADDRESSABLE on vtbl entries
@ 2007-03-31 19:50 Diego Novillo
  2007-03-31 20:01 ` Mark Mitchell
  2007-04-05  2:02 ` Mike Stump
  0 siblings, 2 replies; 10+ messages in thread
From: Diego Novillo @ 2007-03-31 19:50 UTC (permalink / raw)
  To: gcc-patches, Mark Mitchell

[-- Attachment #1: Type: text/plain, Size: 1277 bytes --]


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.

[-- Attachment #2: 20070330-29585.diff --]
[-- Type: text/x-patch, Size: 1274 bytes --]

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))));

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

end of thread, other threads:[~2007-04-12  3:50 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-31 19:50 PR 29585: C++ front end not setting TREE_ADDRESSABLE on vtbl entries Diego Novillo
2007-03-31 20:01 ` Mark Mitchell
2007-04-05  2:02 ` Mike Stump
2007-04-11  1:06   ` Mike Stump
2007-04-11  1:13     ` Mark Mitchell
2007-04-11  2:02       ` Mike Stump
2007-04-11  2:18         ` Mark Mitchell
2007-04-12  1:58           ` Mike Stump
2007-04-12  3:50             ` Mark Mitchell
2007-04-11  1:15     ` Eric Christopher

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).