diff mbox

Fix GC issue triggered by arithmetic overflow checking

Message ID 15117688.tMJrzIrphz@polaris
State New
Headers show

Commit Message

Eric Botcazou Oct. 11, 2016, 8:05 a.m. UTC
> I think only the calls in build_common_tree_nodes -- those are the ones
> built early and that survive GC.  The patch is ok if it passes testing
> with that.

Here's what I have installed, after bootstrap/regtesting on x86-64/Linux and 
SPARC/Solaris (with the upcoming overflow checking support).  I'll try and dig 
deeper into the var-tracking instability.


2016-10-11  Eric Botcazou  <ebotcazou@adacore.com>

	* tree.h (build_complex_type): Add second parameter with default.
	* tree.c (build_complex_type): Add NAMED second parameter and adjust
	recursive call.  Create a TYPE_DECL only if NAMED is true.
	(build_common_tree_nodes): Pass true in calls to build_complex_type.

Comments

Eric Botcazou Oct. 16, 2016, 6:56 p.m. UTC | #1
> 2016-10-11  Eric Botcazou  <ebotcazou@adacore.com>
> 
> 	* tree.h (build_complex_type): Add second parameter with default.
> 	* tree.c (build_complex_type): Add NAMED second parameter and adjust
> 	recursive call.  Create a TYPE_DECL only if NAMED is true.
> 	(build_common_tree_nodes): Pass true in calls to build_complex_type.

May I backport it to the 6 branch?  It fixes the bootstrap comparison failure 
on x86-64/Solaris reported under PR bootstrap/77995 (x86-64 has patterns for 
unsigned arithmetic overflow checking on the 6 branch too).
Richard Biener Oct. 17, 2016, 8:40 a.m. UTC | #2
On Sun, Oct 16, 2016 at 8:56 PM, Eric Botcazou <ebotcazou@adacore.com> wrote:
>> 2016-10-11  Eric Botcazou  <ebotcazou@adacore.com>
>>
>>       * tree.h (build_complex_type): Add second parameter with default.
>>       * tree.c (build_complex_type): Add NAMED second parameter and adjust
>>       recursive call.  Create a TYPE_DECL only if NAMED is true.
>>       (build_common_tree_nodes): Pass true in calls to build_complex_type.
>
> May I backport it to the 6 branch?  It fixes the bootstrap comparison failure
> on x86-64/Solaris reported under PR bootstrap/77995 (x86-64 has patterns for
> unsigned arithmetic overflow checking on the 6 branch too).

Yes.

Thanks,
Richard.

> --
> Eric Botcazou
diff mbox

Patch

Index: tree.c
===================================================================
--- tree.c	(revision 240962)
+++ tree.c	(working copy)
@@ -8752,10 +8752,15 @@  build_offset_type (tree basetype, tree t
   return t;
 }
 
-/* Create a complex type whose components are COMPONENT_TYPE.  */
+/* Create a complex type whose components are COMPONENT_TYPE.
+
+   If NAMED is true, the type is given a TYPE_NAME.  We do not always
+   do so because this creates a DECL node and thus make the DECL_UIDs
+   dependent on the type canonicalization hashtable, which is GC-ed,
+   so the DECL_UIDs would not be stable wrt garbage collection.  */
 
 tree
-build_complex_type (tree component_type)
+build_complex_type (tree component_type, bool named)
 {
   tree t;
   inchash::hash hstate;
@@ -8782,11 +8787,11 @@  build_complex_type (tree component_type)
 	SET_TYPE_STRUCTURAL_EQUALITY (t);
       else if (TYPE_CANONICAL (component_type) != component_type)
 	TYPE_CANONICAL (t)
-	  = build_complex_type (TYPE_CANONICAL (component_type));
+	  = build_complex_type (TYPE_CANONICAL (component_type), named);
     }
 
   /* We need to create a name, since complex is a fundamental type.  */
-  if (! TYPE_NAME (t))
+  if (!TYPE_NAME (t) && named)
     {
       const char *name;
       if (component_type == char_type_node)
@@ -10372,10 +10377,11 @@  build_common_tree_nodes (bool signed_cha
   SET_TYPE_MODE (dfloat128_type_node, TDmode);
   dfloat128_ptr_type_node = build_pointer_type (dfloat128_type_node);
 
-  complex_integer_type_node = build_complex_type (integer_type_node);
-  complex_float_type_node = build_complex_type (float_type_node);
-  complex_double_type_node = build_complex_type (double_type_node);
-  complex_long_double_type_node = build_complex_type (long_double_type_node);
+  complex_integer_type_node = build_complex_type (integer_type_node, true);
+  complex_float_type_node = build_complex_type (float_type_node, true);
+  complex_double_type_node = build_complex_type (double_type_node, true);
+  complex_long_double_type_node = build_complex_type (long_double_type_node,
+						      true);
 
   for (i = 0; i < NUM_FLOATN_NX_TYPES; i++)
     {
Index: tree.h
===================================================================
--- tree.h	(revision 240962)
+++ tree.h	(working copy)
@@ -4042,7 +4042,7 @@  extern tree build_varargs_function_type_
 extern tree build_method_type_directly (tree, tree, tree);
 extern tree build_method_type (tree, tree);
 extern tree build_offset_type (tree, tree);
-extern tree build_complex_type (tree);
+extern tree build_complex_type (tree, bool named = false);
 extern tree array_type_nelts (const_tree);
 
 extern tree value_member (tree, tree);