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]

[PATCH] 1KB code size saving in var-tracking.o


Hi!

DECL_DEBUG_EXPR is a function call (and not one marked pure), so
invoking it 3 times in a row means 3 function calls.

This patch shrinks var-tracking.o by more than 1KB (~ 1.5%).

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

2010-05-04  Jakub Jelinek  <jakub@redhat.com>

	* var-tracking.c (var_debug_decl): Save DECL_DEBUG_EXPR value
	in a temporary instead of invoking the macro multiple times.
	(track_expr_p): Likewise.

--- gcc/var-tracking.c.jj	2010-04-05 18:48:59.000000000 +0200
+++ gcc/var-tracking.c	2010-05-04 18:14:01.000000000 +0200
@@ -1573,9 +1573,12 @@ static inline tree
 var_debug_decl (tree decl)
 {
   if (decl && DECL_P (decl)
-      && DECL_DEBUG_EXPR_IS_FROM (decl) && DECL_DEBUG_EXPR (decl)
-      && DECL_P (DECL_DEBUG_EXPR (decl)))
-    decl = DECL_DEBUG_EXPR (decl);
+      && DECL_DEBUG_EXPR_IS_FROM (decl))
+    {
+      tree debugdecl = DECL_DEBUG_EXPR (decl);
+      if (debugdecl && DECL_P (debugdecl))
+	decl = debugdecl;
+    }
 
   return decl;
 }
@@ -4497,12 +4500,14 @@ track_expr_p (tree expr, bool need_rtl)
      don't need to track this expression if the ultimate declaration is
      ignored.  */
   realdecl = expr;
-  if (DECL_DEBUG_EXPR_IS_FROM (realdecl) && DECL_DEBUG_EXPR (realdecl))
+  if (DECL_DEBUG_EXPR_IS_FROM (realdecl))
     {
       realdecl = DECL_DEBUG_EXPR (realdecl);
+      if (realdecl == NULL_TREE)
+	realdecl = expr;
       /* ??? We don't yet know how to emit DW_OP_piece for variable
 	 that has been SRA'ed.  */
-      if (!DECL_P (realdecl))
+      else if (!DECL_P (realdecl))
 	return 0;
     }
 

	Jakub


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