public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Fix ipa-inline-transform ICE
@ 2012-12-19 10:32 Jan Hubicka
  0 siblings, 0 replies; 2+ messages in thread
From: Jan Hubicka @ 2012-12-19 10:32 UTC (permalink / raw)
  To: gcc-patches

Hi,
the ipa-inline-transform ICE is caused by fact that devirt_benefit in
ipa-inline-analysis is able to determine devirtualiation oppurtunity of call to
b3, while the ipa-prop responsible for updating function body after inlining is
not.  This is because the later is missing code turning known constant into
binfo.

Bootstrapped/regtested x86_64-linux, will commit this shortly.

Honza
	
	PR tree-optimization/55683
	* g++.dg/ipa/devirt-9.C: New testcase.

	* ipa-prop.c (try_make_edge_direct_virtual_call): Look into constants for binfo.
Index: testsuite/g++.dg/ipa/devirt-9.C
===================================================================
*** testsuite/g++.dg/ipa/devirt-9.C	(revision 0)
--- testsuite/g++.dg/ipa/devirt-9.C	(revision 0)
***************
*** 0 ****
--- 1,30 ----
+ /* { dg-do compile } */
+ /* { dg-options "-O2 -fdump-ia-inline"  } */
+ double foo ();
+ struct B
+ {
+   bool b1 () { return b3 (); }
+   void b2 ();
+   virtual bool b3 ();
+ };
+ struct C
+ {
+   C () {}
+   bool
+   c1 (float x, float y)
+   {
+     if (x != c3 || y != c4)
+       c2.b2 ();
+     return c2.b1 ();
+   }
+   B c2;
+   float c3, c4;
+ };
+ 
+ void
+ bar ()
+ {
+   static C c;
+   c.c1 (60, (int) foo ());
+ }
+ /* { dg-final { scan-ipa-dump "Discovered a virtual call to a known target"  "inline"  } } */
Index: ipa-prop.c
===================================================================
*** ipa-prop.c	(revision 194584)
--- ipa-prop.c	(working copy)
*************** try_make_edge_direct_virtual_call (struc
*** 2223,2231 ****
  
    binfo = ipa_value_from_jfunc (new_root_info, jfunc);
  
!   if (!binfo || TREE_CODE (binfo) != TREE_BINFO)
      return NULL;
  
    binfo = get_binfo_at_offset (binfo, ie->indirect_info->offset,
  			       ie->indirect_info->otr_type);
    if (binfo)
--- 2223,2238 ----
  
    binfo = ipa_value_from_jfunc (new_root_info, jfunc);
  
!   if (!binfo)
      return NULL;
  
+   if (TREE_CODE (binfo) != TREE_BINFO)
+     {
+       binfo = gimple_extract_devirt_binfo_from_cst (binfo);
+       if (!binfo)
+         return NULL;
+     }
+ 
    binfo = get_binfo_at_offset (binfo, ie->indirect_info->offset,
  			       ie->indirect_info->otr_type);
    if (binfo)

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

* Fix ipa-inline-transform ICE
@ 2015-01-18 17:51 Jan Hubicka
  0 siblings, 0 replies; 2+ messages in thread
From: Jan Hubicka @ 2015-01-18 17:51 UTC (permalink / raw)
  To: gcc-patches

Hi,
the testcase shows a case where try_make_edge_direct_virtual_call disagrees with
ipa_get_indirect_edge_target_1 making ipa-inline-transform to ICE on mismatch.

Bootstrapped/regtested x86_64-linux, comitted.

Honza

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 219821)
+++ ChangeLog	(working copy)
@@ -1,3 +1,10 @@
+2015-01-18  Jan Hubicka  <hubicka@ucw.cz>
+
+	PR ipa/64378
+	* ipa-prop.c (try_make_edge_direct_virtual_call): Clear speculative
+	flag correctly.
+	* ipa-cp.c (ipa_get_indirect_edge_target_1): Handle speculation.
+
 2015-01-18  Sandra Loosemore  <sandra@codesourcery.com>
 
 	* doc/invoke.texi ([-funroll-loops], [-funroll-all-loops]):
Index: testsuite/ChangeLog
===================================================================
--- testsuite/ChangeLog	(revision 219821)
+++ testsuite/ChangeLog	(working copy)
@@ -1,3 +1,8 @@
+2015-01-18  Jan Hubicka  <hubicka@ucw.cz>
+
+	PR ipa/64378
+	* g++.dg/torture/pr64378.C: New testcase.
+
 2015-01-18  Paul Thomas  <pault@gcc.gnu.org>
 
 	PR fortran/57959
Index: testsuite/g++.dg/torture/pr64378.C
===================================================================
--- testsuite/g++.dg/torture/pr64378.C	(revision 0)
+++ testsuite/g++.dg/torture/pr64378.C	(revision 0)
@@ -0,0 +1,24 @@
+// { dg-do compile }
+// { dg-options "-fno-ipa-cp" }
+struct data {
+  data(int) {}
+};
+
+struct top {
+  virtual int topf() {}
+};
+
+struct child1: top {
+    void childf()
+    {
+        data d(topf());
+    }
+};
+
+void test(top *t)
+{
+    child1 *c = static_cast<child1 *>(t);
+    c->childf();
+    child1 d;
+    test(&d);
+}
Index: ipa-prop.c
===================================================================
--- ipa-prop.c	(revision 219821)
+++ ipa-prop.c	(working copy)
@@ -2985,7 +2985,7 @@ try_make_edge_direct_virtual_call (struc
 		  || !possible_polymorphic_call_target_p
 		       (ie, cgraph_node::get (t)))
 		{
-		  /* Do not speculate builtin_unreachable, it is stpid!  */
+		  /* Do not speculate builtin_unreachable, it is stupid!  */
 		  if (!ie->indirect_info->vptr_changed)
 		    target = ipa_impossible_devirt_target (ie, target);
 		}
@@ -3013,6 +3013,7 @@ try_make_edge_direct_virtual_call (struc
      ctx, &final);
   if (final && targets.length () <= 1)
     {
+      speculative = false;
       if (targets.length () == 1)
 	target = targets[0]->decl;
       else
Index: ipa-cp.c
===================================================================
--- ipa-cp.c	(revision 219821)
+++ ipa-cp.c	(working copy)
@@ -1975,8 +1975,13 @@ ipa_get_indirect_edge_target_1 (struct c
 	}
     }
   else if (t)
-    context = ipa_polymorphic_call_context (t, ie->indirect_info->otr_type,
-					    anc_offset);
+    {
+      context = ipa_polymorphic_call_context (t, ie->indirect_info->otr_type,
+					      anc_offset);
+      if (ie->indirect_info->vptr_changed)
+	context.possible_dynamic_type_change (ie->in_polymorphic_cdtor,
+					      ie->indirect_info->otr_type);
+    }
   else
     return NULL_TREE;
 

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

end of thread, other threads:[~2015-01-18 17:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-19 10:32 Fix ipa-inline-transform ICE Jan Hubicka
2015-01-18 17:51 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).