This was the most surprising check of TYPE_METHODS. When not optimizing we use the non-nullness of TYPE_METHODS to figure out if we want to place a non BLKmode structure into a register. On the grounds that one can't call a member function with a register-located object.

That seems overly enthusiastic -- if we're not optimizing, who cares?

(When we zap TYHPE_METHODS we currently set it to error_mark_node, if it was non-null, so that this above check will work).

I'd appreciate comment.

nathan

--
Nathan Sidwell
2017-07-14  Nathan Sidwell  <nat...@acm.org>

        gcc/
        * function.c (use_register_for_decl): Always ignore register for
        class types when not optimizing.

Index: gcc/function.c
===================================================================
--- gcc/function.c      (revision 250160)
+++ gcc/function.c      (working copy)
@@ -2218,20 +2218,11 @@ use_register_for_decl (const_tree decl)
   if (!DECL_REGISTER (decl))
     return false;
 
-  switch (TREE_CODE (TREE_TYPE (decl)))
-    {
-    case RECORD_TYPE:
-    case UNION_TYPE:
-    case QUAL_UNION_TYPE:
-      /* When not optimizing, disregard register keyword for variables with
-        types containing methods, otherwise the methods won't be callable
-        from the debugger.  */
-      if (TYPE_METHODS (TYPE_MAIN_VARIANT (TREE_TYPE (decl))))
-       return false;
-      break;
-    default:
-      break;
-    }
+  /* When not optimizing, disregard register keyword for types that
+     could have methods, otherwise the methods won't be callable from
+     the debugger.  */
+  if (RECORD_OR_UNION_TYPE_P (TREE_TYPE (decl)))
+    return false;
 
   return true;
 }

Reply via email to