[PATCH] For -O0 avoid putting user vars with methods in its type into registers (PR debug/39485)

Jakub Jelinek jakub@redhat.com
Wed Mar 18 15:20:00 GMT 2009


Hi!

On the gdb testcase g++ 4.4 regresses from 4.3, as it puts a register
variable into a register even at -O0, which makes it impossible to call
methods on it from the debugger.  The following patch just disregards
the register keyword in that case in use_register_for_decl.  Vars with types
without methods will still be put into registers sometimes.

Bootstrapped/regtested on x86_64-linux, ok for trunk?

2009-03-18  Jakub Jelinek  <jakub@redhat.com>

	PR debug/39485
	* function.c (use_register_for_decl): When not optimizing, disregard
	register keyword for variables with types containing methods.

--- gcc/function.c.jj	2009-03-17 16:32:43.000000000 +0100
+++ gcc/function.c	2009-03-18 09:46:46.000000000 +0100
@@ -1942,7 +1942,28 @@ use_register_for_decl (const_tree decl)
   if (DECL_IGNORED_P (decl))
     return true;
 
-  return (optimize || DECL_REGISTER (decl));
+  if (optimize)
+    return true;
+
+  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 (TREE_TYPE (decl)))
+	return false;
+      break;
+    default:
+      break;
+    }
+
+  return true;
 }
 
 /* Return true if TYPE should be passed by invisible reference.  */

	Jakub



More information about the Gcc-patches mailing list