[PATCH] Save some memory during var-tracking

Jakub Jelinek jakub@redhat.com
Fri Mar 26 18:34:00 GMT 2010


Hi!

Most of the var location notes are for one part variable with offset 0,
I think it is wasteful to surround it in an extra EXPR_LIST in that case.
Only dwarf2out.c consumes it, so it is easy to handle there, and DEBUG_INSNs
also not using the extra EXPR_LIST around the location is a precedent too.

Bootstrapped/regtested on x86_64-linux and i686-linux.  Ok for trunk?

2010-03-26  Jakub Jelinek  <jakub@redhat.com>

	* var-tracking.c (emit_note_insn_var_location): For one part
	notes with offset 0, don't add EXPR_LIST around the location.
	* dwarf2out.c (loc_descriptor, dw_loc_list_1,
	add_location_or_const_value_attribute): Adjust for that change.

--- gcc/var-tracking.c.jj	2010-03-25 00:26:24.000000000 +0100
+++ gcc/var-tracking.c	2010-03-26 14:51:19.000000000 +0100
@@ -7099,8 +7099,12 @@ emit_note_insn_var_location (void **varp
 				    (int) initialized);
   else if (n_var_parts == 1)
     {
-      rtx expr_list
-	= gen_rtx_EXPR_LIST (VOIDmode, loc[0], GEN_INT (offsets[0]));
+      rtx expr_list;
+
+      if (offsets[0] || GET_CODE (loc[0]) == PARALLEL)
+	expr_list = gen_rtx_EXPR_LIST (VOIDmode, loc[0], GEN_INT (offsets[0]));
+      else
+	expr_list = loc[0];
 
       note_vl = gen_rtx_VAR_LOCATION (VOIDmode, decl, expr_list,
 				      (int) initialized);
--- gcc/dwarf2out.c.jj	2010-03-25 00:26:24.000000000 +0100
+++ gcc/dwarf2out.c	2010-03-26 14:54:05.000000000 +0100
@@ -13720,10 +13720,12 @@ loc_descriptor (rtx rtl, enum machine_mo
 
     case VAR_LOCATION:
       /* Single part.  */
-      if (GET_CODE (XEXP (rtl, 1)) != PARALLEL)
+      if (GET_CODE (PAT_VAR_LOCATION_LOC (rtl)) != PARALLEL)
 	{
-	  loc_result = loc_descriptor (XEXP (XEXP (rtl, 1), 0), mode,
-				       initialized);
+	  rtx loc = PAT_VAR_LOCATION_LOC (rtl);
+	  if (GET_CODE (loc) == EXPR_LIST)
+	    loc = XEXP (loc, 0);
+	  loc_result = loc_descriptor (loc, mode, initialized);
 	  break;
 	}
 
@@ -13975,9 +13977,11 @@ dw_loc_list_1 (tree loc, rtx varloc, int
     {
       gcc_assert (GET_CODE (varloc) == VAR_LOCATION);
       /* Single part.  */
-      if (GET_CODE (XEXP (varloc, 1)) != PARALLEL)
+      if (GET_CODE (PAT_VAR_LOCATION_LOC (varloc)) != PARALLEL)
 	{
-	  varloc = XEXP (XEXP (varloc, 1), 0);
+	  varloc = PAT_VAR_LOCATION_LOC (varloc);
+	  if (GET_CODE (varloc) == EXPR_LIST)
+	    varloc = XEXP (varloc, 0);
 	  mode = GET_MODE (varloc);
 	  if (MEM_P (varloc))
 	    {
@@ -15880,7 +15884,7 @@ add_location_or_const_value_attribute (d
 
       node = loc_list->first;
       rtl = NOTE_VAR_LOCATION_LOC (node->var_loc_note);
-      if (GET_CODE (rtl) != PARALLEL)
+      if (GET_CODE (rtl) == EXPR_LIST)
 	rtl = XEXP (rtl, 0);
       if ((CONSTANT_P (rtl) || GET_CODE (rtl) == CONST_STRING)
 	  && add_const_value_attribute (die, rtl))

	Jakub



More information about the Gcc-patches mailing list