public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* ipa-prop WRT type variants
@ 2014-06-28 18:31 Jan Hubicka
  0 siblings, 0 replies; only message in thread
From: Jan Hubicka @ 2014-06-28 18:31 UTC (permalink / raw)
  To: gcc-patches

Hi,
this patch does similar change to ipa-prop as I did to ipa-devirt; it makes sure that
all the types in jump functions are main variants that reduces diversity in LTO streaming
and makes us less likely to hit incomplete types.

It also makes sure that the type change detection works on main variant because pointer
equality is used there for types.

Bootstrapped/regtested x86_64-linux, comitted.

	* ipa-prop.c (ipa_set_jf_known_type): Record always the main variant
	of the type.
	(ipa_set_ancestor_jf) Likewise.
	(check_stmt_for_type_change): Check that we work on main variant.
	(detect_type_change): Look into main variant.
	(compute_known_type_jump_func): Check that main variant has BINFO.
Index: ipa-prop.c
===================================================================
--- ipa-prop.c	(revision 212098)
+++ ipa-prop.c	(working copy)
@@ -438,6 +438,11 @@ static void
 ipa_set_jf_known_type (struct ipa_jump_func *jfunc, HOST_WIDE_INT offset,
 		       tree base_type, tree component_type)
 {
+  /* Recording and propagating main variants increases change that types
+     will match.  */
+  base_type = TYPE_MAIN_VARIANT (base_type);
+  component_type = TYPE_MAIN_VARIANT (component_type);
+
   gcc_assert (TREE_CODE (component_type) == RECORD_TYPE
 	      && TYPE_BINFO (component_type));
   if (!flag_devirtualize)
@@ -529,6 +534,8 @@ ipa_set_ancestor_jf (struct ipa_jump_fun
 {
   if (!flag_devirtualize)
     type_preserved = false;
+  if (type)
+    type = TYPE_MAIN_VARIANT (type);
   gcc_assert (!type_preserved
 	      || (TREE_CODE (type) == RECORD_TYPE
 		  && TYPE_BINFO (type)
@@ -712,7 +720,9 @@ check_stmt_for_type_change (ao_ref *ao A
   if (stmt_may_be_vtbl_ptr_store (stmt))
     {
       tree type;
+
       type = extr_type_from_vtbl_ptr_store (stmt, tci);
+      gcc_assert (!type || TYPE_MAIN_VARIANT (type) == type);
       if (tci->type_maybe_changed
 	  && type != tci->known_current_type)
 	tci->multiple_types_encountered = true;
@@ -749,10 +759,12 @@ detect_type_change (tree arg, tree base,
       /* Be sure expected_type is polymorphic.  */
       || !comp_type
       || TREE_CODE (comp_type) != RECORD_TYPE
-      || !TYPE_BINFO (comp_type)
-      || !BINFO_VTABLE (TYPE_BINFO (comp_type)))
+      || !TYPE_BINFO (TYPE_MAIN_VARIANT (comp_type))
+      || !BINFO_VTABLE (TYPE_BINFO (TYPE_MAIN_VARIANT (comp_type))))
     return true;
 
+  comp_type = TYPE_MAIN_VARIANT (comp_type);
+
   /* C++ methods are not allowed to change THIS pointer unless they
      are constructors or destructors.  */
   if (TREE_CODE	(base) == MEM_REF
@@ -1408,8 +1420,8 @@ compute_known_type_jump_func (tree op, s
       /* Be sure expected_type is polymorphic.  */
       || !expected_type
       || TREE_CODE (expected_type) != RECORD_TYPE
-      || !TYPE_BINFO (expected_type)
-      || !BINFO_VTABLE (TYPE_BINFO (expected_type)))
+      || !TYPE_BINFO (TYPE_MAIN_VARIANT (expected_type))
+      || !BINFO_VTABLE (TYPE_BINFO (TYPE_MAIN_VARIANT (expected_type))))
     return;
 
   op = TREE_OPERAND (op, 0);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-06-28 18:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-28 18:31 ipa-prop WRT type variants Jan Hubicka

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