This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix PR81007


On Thu, 8 Jun 2017, Richard Biener wrote:

> On Thu, 8 Jun 2017, Richard Biener wrote:
> 
> > 
> > Folding during gimplification can invoke the devirt machinery which
> > doesn't deal with errorneous state.  Thus avoid ICEing by not folding
> > from gimplification in case we've seen errors.
> > 
> > Similarly do not build cgraph edges in those cases as that invokes
> > the devirt machinery as well (we stop compilation after lowering anyway
> > in case errors were reported).
> > 
> > The patch also fixes ordering of passes.
> > 
> > Bootstrap and regtest running on x86_64-unknown-linux-gnu.
> 
> Bah.  The cgraphbuild.c hunks cause
> 
> FAIL: g++.dg/gomp/linear-2.C  -std=gnu++11  (test for errors, line 111)
> FAIL: g++.dg/gomp/linear-2.C  -std=gnu++11  (test for errors, line 111)
> FAIL: g++.dg/gomp/linear-2.C  -std=gnu++11  (test for errors, line 63)
> FAIL: g++.dg/gomp/linear-2.C  -std=gnu++11  (test for errors, line 82)
> FAIL: g++.dg/gomp/linear-2.C  -std=gnu++11  (test for errors, line 90)
> FAIL: g++.dg/gomp/linear-2.C  -std=gnu++11  (test for errors, line 90)
> ...
> 
> looks like the code processing queued cgraph nodes enqueues
> further nodes by looking at callees and thus omp lowering
> doesn't register split out functions with the cgraph?
> 
> No time to dig in right now.
> 
> But relying on the folding machinery not to ICE looks fragile to me.
> Eventually, given the ICE is reached by cgraph edge building, we
> have to plug that hole anyways.

So I'm testing the following instead.

Richard.

2017-06-08  Richard Biener  <rguenther@suse.de>

	PR middle-end/81007
	* ipa-polymorphic-call.c
	(ipa_polymorphic_call_context::restrict_to_inner_class):
	Skip FIELD_DECLs with error_mark_node type.
	* passes.def (all_lowering_passes): Run pass_build_cgraph_edges
	last again.

	* g++.dg/pr81007.C: New testcase.

Index: gcc/ipa-polymorphic-call.c
===================================================================
--- gcc/ipa-polymorphic-call.c	(revision 249003)
+++ gcc/ipa-polymorphic-call.c	(working copy)
@@ -267,7 +267,8 @@ ipa_polymorphic_call_context::restrict_t
 	{
 	  for (fld = TYPE_FIELDS (type); fld; fld = DECL_CHAIN (fld))
 	    {
-	      if (TREE_CODE (fld) != FIELD_DECL)
+	      if (TREE_CODE (fld) != FIELD_DECL
+		  || TREE_TYPE (fld) == error_mark_node)
 		continue;
 
 	      pos = int_bit_position (fld);
Index: gcc/passes.def
===================================================================
--- gcc/passes.def	(revision 249003)
+++ gcc/passes.def	(working copy)
@@ -42,9 +42,9 @@ along with GCC; see the file COPYING3.
   NEXT_PASS (pass_build_cfg);
   NEXT_PASS (pass_warn_function_return);
   NEXT_PASS (pass_expand_omp);
-  NEXT_PASS (pass_build_cgraph_edges);
   NEXT_PASS (pass_sprintf_length, false);
   NEXT_PASS (pass_walloca, /*strict_mode_p=*/true);
+  NEXT_PASS (pass_build_cgraph_edges);
   TERMINATE_PASS_LIST (all_lowering_passes)
 
   /* Interprocedural optimization passes.  */
Index: gcc/testsuite/g++.dg/pr81007.C
===================================================================
--- gcc/testsuite/g++.dg/pr81007.C	(nonexistent)
+++ gcc/testsuite/g++.dg/pr81007.C	(working copy)
@@ -0,0 +1,15 @@
+// { dg-do compile }
+// { dg-options "-O2" }
+
+struct A
+{
+  A p; // { dg-error "incomplete" }
+  virtual void foo();
+};
+
+struct B : A {};
+
+void bar(B& b)
+{
+  b.foo();
+}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]