diff mbox

Do not free binfos linking vtables

Message ID 20150307203545.GA34616@kam.mff.cuni.cz
State New
Headers show

Commit Message

Jan Hubicka March 7, 2015, 8:35 p.m. UTC
Hi,
extra sanity checking I added while debugging PR 65316 noticed that the
type inheritance graph builder gets confused when one merges unit compiled
with -g -fno-devirtualize and unit compiled with -fdevirtualize.
In the first case there may be a base type lost.

Bootstrapped/regtested x86_64-linux, comitted.
	PR ipa/65316
	* tree.c (free_lang_data_in_type): Be sure to keep BINFO_VTABLE
	when outputting debug.
diff mbox

Patch

Index: tree.c
===================================================================
--- tree.c	(revision 221223)
+++ tree.c	(working copy)
@@ -5081,9 +5081,15 @@  free_lang_data_in_type (tree type)
       if (TYPE_BINFO (type))
 	{
 	  free_lang_data_in_binfo (TYPE_BINFO (type));
+	  /* We need to preserve link to bases and virtual table for all
+	     polymorphic types to make devirtualization machinery working.
+	     Debug output cares only about bases, but output also
+	     virtual table pointers so merging of -fdevirtualize and
+	     -fno-devirtualize units is easier.  */
 	  if ((!BINFO_VTABLE (TYPE_BINFO (type))
 	       || !flag_devirtualize)
-	      && (!BINFO_N_BASE_BINFOS (TYPE_BINFO (type))
+	      && ((!BINFO_N_BASE_BINFOS (TYPE_BINFO (type))
+		   && !BINFO_VTABLE (TYPE_BINFO (type)))
 		  || debug_info_level != DINFO_LEVEL_NONE))
 	    TYPE_BINFO (type) = NULL;
 	}