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: [PR 79905] ICE with vector_type


On 04/04/2017 09:00 AM, Richard Biener wrote:

tree
add_builtin_type (const char *name, tree type)
{
  tree   id = get_identifier (name);
  tree decl = build_decl (BUILTINS_LOCATION, TYPE_DECL, id, type);
  return lang_hooks.decls.pushdecl (decl);
}

this seems to miss setting TYPE_NAME (type) = decl - oh, that may be
what set_underlying_type does via the langhook.

Correct, via the langhook. I wonder if the smacking of the incoming-type's TYPE_NAME is so that the global tree node references the now-named builtin type. If we were to make a clone here, (things like) VS4SI_type_node would remain an unnamed type. And I guess debug would be unhappy?

At this point I'd rather restrict fiddling in this fragile area in
rs6000.c only ;)

me too.

Does removing the TYPE_NAME setting fix things?

no, those TYPE_NAME assignments are redundant -- set_underlying_type has already initialized it.

The attached PoC fixes 79905 (no idea what ppc test it might break)

nathan

--
Nathan Sidwell
Index: config/rs6000/rs6000.c
===================================================================
--- config/rs6000/rs6000.c	(revision 246647)
+++ config/rs6000/rs6000.c	(working copy)
@@ -17459,9 +17459,23 @@ rs6000_init_builtins (void)
   tdecl = add_builtin_type ("__vector unsigned int", unsigned_V4SI_type_node);
   TYPE_NAME (unsigned_V4SI_type_node) = tdecl;
 
-  tdecl = add_builtin_type ("__vector signed int", V4SI_type_node);
-  TYPE_NAME (V4SI_type_node) = tdecl;
+  { // Ugly POC hack
+    TYPE_NAME (V4SI_type_node) = error_mark_node; // placeholder
+    tdecl = add_builtin_type ("__vector signed int", V4SI_type_node);
+    TYPE_NAME (V4SI_type_node) = NULL_TREE; // restore
 
+    // Ew, change the underlying type
+    DECL_ORIGINAL_TYPE (tdecl) = V4SI_type_node;
+    tree clone = build_variant_type_copy (V4SI_type_node);
+    TYPE_STUB_DECL (clone) = TYPE_STUB_DECL (V4SI_type_node);
+    TYPE_NAME (clone) = tdecl;
+
+    TREE_USED (clone) = 1;
+    TREE_TYPE (tdecl) = clone;
+
+    V4SI_type_node = TREE_TYPE (tdecl);
+  }
+  
   tdecl = add_builtin_type ("__vector __bool int", bool_V4SI_type_node);
   TYPE_NAME (bool_V4SI_type_node) = tdecl;
 

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