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] Fix var-tracking MO_VAL_{USE,LOC} ordering


Hi!

On many testcases, some of them in PR41353, I'm seeing vartrack pass
generating notes like:
(note 24 2 23 2 (var_location i1 (expr_list:REG_DEP_TRUE (ashift:SI (mem/c/i:SI (symbol_ref:DI ("i") [flags 0x2] <var_decl 0x7f6d386d8820 i>) [2 i+0 S4 A32])
        (const_int 1 [0x1]))
    (const_int 0 [0x0]))) NOTE_INSN_VAR_LOCATION)
(note 23 24 25 2 (var_location i1 (nil)) NOTE_INSN_VAR_LOCATION)
(i.e. a correct var_location note, immediately followed by one that says the
variable is optimized out (it is not).
This happens if some value (like the (mem/c/i ) in this case) is first used
inside of that var_location.  As VAR_LOCATION is visited first during
for_each_rtx traversal, we get a MO_VAL_LOC note before MO_VAL_USE of the
argument.  I believe MO_VAL_USE are supposed to be ordered before MO_VAL_LOC
on the same insn.

The following patch fixes that, bootstrapped/regtested on x86_64-linux and
i686-linux.

The dwarf2out.c change just fixes an --enable-checking=yes,rtl ICE during
libiberty build on both x86_64 and i686, even without this patch.  Not sure
when this regressed, must have been recently.

Ok for trunk?

2009-09-15  Jakub Jelinek  <jakub@redhat.com>

	PR debug/41353
	* var-tracking.c (add_uses): Traverse PAT_VAR_LOCATION_LOC
	of VAR_LOCATION expressions before adding MO_VAL_LOC note for
	them.
	(count_uses): Likewise, for !cui->store_p.
	* dwarf2out.c (mem_loc_descriptor) <case SUBREG>: Recurse
	instead of assuming it has always a REG inside of it.

--- gcc/var-tracking.c.jj	2009-09-11 11:10:43.000000000 +0200
+++ gcc/var-tracking.c	2009-09-15 16:37:38.000000000 +0200
@@ -4465,7 +4465,14 @@ count_uses (rtx *loc, void *cuip)
 {
   struct count_use_info *cui = (struct count_use_info *) cuip;
   enum micro_operation_type mopt = use_type (loc, cui, NULL);
+  int ret = 0;
 
+  if (mopt == MO_VAL_LOC && !cui->store_p)
+    {
+      /* Ensure MO_VAL_USE uops are added before MO_VAL_LOC uop.  */
+      for_each_rtx (&PAT_VAR_LOCATION_LOC (*loc), count_uses, cui);
+      ret = -1;
+    }
   if (mopt != MO_CLOBBER)
     {
       cselib_val *val;
@@ -4511,7 +4518,7 @@ count_uses (rtx *loc, void *cuip)
 	}
     }
 
-  return 0;
+  return ret;
 }
 
 /* Helper function for finding all uses of REG/MEM in X in CUI's
@@ -4587,7 +4594,14 @@ add_uses (rtx *loc, void *data)
   enum machine_mode mode = VOIDmode;
   struct count_use_info *cui = (struct count_use_info *)data;
   enum micro_operation_type type = use_type (loc, cui, &mode);
+  int ret = 0;
 
+  if (type == MO_VAL_LOC)
+    {
+      /* Ensure MO_VAL_USE uops are added before MO_VAL_LOC uop.  */
+      for_each_rtx (&PAT_VAR_LOCATION_LOC (*loc), add_uses, cui);
+      ret = -1;
+    }
   if (type != MO_CLOBBER)
     {
       basic_block bb = cui->bb;
@@ -4742,7 +4756,7 @@ add_uses (rtx *loc, void *data)
 	log_op_type (mo->u.loc, cui->bb, cui->insn, mo->type, dump_file);
     }
 
-  return 0;
+  return ret;
 }
 
 /* Helper function for finding all uses of REG/MEM in X in insn INSN.  */
--- gcc/dwarf2out.c.jj	2009-09-15 16:21:48.000000000 +0200
+++ gcc/dwarf2out.c	2009-09-15 17:18:49.000000000 +0200
@@ -11068,8 +11068,8 @@ mem_loc_descriptor (rtx rtl, enum machin
       rtl = XEXP (rtl, 0);
       if (GET_MODE_SIZE (GET_MODE (rtl)) > DWARF2_ADDR_SIZE)
 	break;
-
-      /* ... fall through ...  */
+      mem_loc_result = mem_loc_descriptor (rtl, mode, initialized);
+      break;
 
     case REG:
       /* Whenever a register number forms a part of the description of the

	Jakub


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