OSDN Git Service

PR debug/43058
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 18 Mar 2010 20:15:05 +0000 (20:15 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 18 Mar 2010 20:15:05 +0000 (20:15 +0000)
* var-tracking.c (non_suitable_const): New function.
(add_uses): For DEBUG_INSNs with constants, don't record any
value, instead just the constant value itself.
(compute_bb_dataflow) <case MO_VAL_LOC>: If PAT_VAR_LOCATION_LOC
is not VAR_LOC_UNKNOWN_P, set var to the constant.
(emit_notes_in_bb): Likewise.
(emit_note_insn_var_location): For onepart variables if
cur_loc is a VOIDmode constant, use DECL_MODE.

* gcc.dg/pr43058.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@157547 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr43058.c [new file with mode: 0644]
gcc/var-tracking.c

index 9b5211c..26d70d1 100644 (file)
@@ -1,3 +1,15 @@
+2010-03-18  Jakub Jelinek  <jakub@redhat.com>
+
+       PR debug/43058
+       * var-tracking.c (non_suitable_const): New function.
+       (add_uses): For DEBUG_INSNs with constants, don't record any
+       value, instead just the constant value itself.
+       (compute_bb_dataflow) <case MO_VAL_LOC>: If PAT_VAR_LOCATION_LOC
+       is not VAR_LOC_UNKNOWN_P, set var to the constant.
+       (emit_notes_in_bb): Likewise.
+       (emit_note_insn_var_location): For onepart variables if
+       cur_loc is a VOIDmode constant, use DECL_MODE.
+
 2010-03-18  Martin Jambor  <mjambor@suse.cz>
 
        PR middle-end/42450
index 8d678f9..62554cd 100644 (file)
@@ -1,3 +1,8 @@
+2010-03-18  Jakub Jelinek  <jakub@redhat.com>
+
+       PR debug/43058
+       * gcc.dg/pr43058.c: New test.
+
 2010-03-18  Martin Jambor  <mjambor@suse.cz>
 
        PR middle-end/42450
diff --git a/gcc/testsuite/gcc.dg/pr43058.c b/gcc/testsuite/gcc.dg/pr43058.c
new file mode 100644 (file)
index 0000000..50d8a63
--- /dev/null
@@ -0,0 +1,20 @@
+/* PR debug/43058 */
+/* { dg-do compile } */
+/* { dg-options "-g -O2" } */
+
+extern void *f1 (void *, void *, void *);
+extern void *f2 (const char *, int, int, int, void *(*) ());
+extern void *f3 (const char *);
+extern void *f4 (void *s);
+extern void *f5 (void *);
+
+void test (void)
+{
+#define X1 f1 (f2 ("a", 1, 0, 0, f5), \
+              f4 (({ const char *a = "b"; f3 (a); })), \
+              ({ const char *a = "c"; f3 (a); }));
+#define X2 X1 X1 X1 X1 X1 X1 X1 X1 X1 X1
+#define X3 X2 X2 X2 X2 X2 X2 X2 X2 X2 X2
+#define X4 X3 X3 X3 X3 X3 X3 X3 X3 X3 X3
+  X4 X4
+}
index 362a881..8b4f2f3 100644 (file)
@@ -4738,6 +4738,33 @@ preserve_value (cselib_val *val)
   VEC_safe_push (rtx, heap, preserved_values, val->val_rtx);
 }
 
+/* Helper function for MO_VAL_LOC handling.  Return non-zero if
+   any rtxes not suitable for CONST use not replaced by VALUEs
+   are discovered.  */
+
+static int
+non_suitable_const (rtx *x, void *data ATTRIBUTE_UNUSED)
+{
+  if (*x == NULL_RTX)
+    return 0;
+
+  switch (GET_CODE (*x))
+    {
+    case REG:
+    case DEBUG_EXPR:
+    case PC:
+    case SCRATCH:
+    case CC0:
+    case ASM_INPUT:
+    case ASM_OPERANDS:
+      return 1;
+    case MEM:
+      return !MEM_READONLY_P (*x);
+    default:
+      return 0;
+    }
+}
+
 /* Add uses (register and memory references) LOC which will be tracked
    to VTI (bb)->mos.  INSN is instruction which the LOC is part of.  */
 
@@ -4794,8 +4821,12 @@ add_uses (rtx *ploc, void *data)
                }
            }
 
-         if (!VAR_LOC_UNKNOWN_P (vloc)
-             && (val = find_use_val (vloc, GET_MODE (oloc), cui)))
+         if (CONSTANT_P (vloc)
+             && (GET_CODE (vloc) != CONST
+                 || for_each_rtx (&vloc, non_suitable_const, NULL)))
+           /* For constants don't look up any value.  */;
+         else if (!VAR_LOC_UNKNOWN_P (vloc)
+                  && (val = find_use_val (vloc, GET_MODE (oloc), cui)))
            {
              enum machine_mode mode2;
              enum micro_operation_type type2;
@@ -5508,6 +5539,11 @@ compute_bb_dataflow (basic_block bb)
                                     VAR_INIT_STATUS_INITIALIZED, NULL_RTX,
                                     INSERT);
                }
+             else if (!VAR_LOC_UNKNOWN_P (PAT_VAR_LOCATION_LOC (vloc)))
+               set_variable_part (out, PAT_VAR_LOCATION_LOC (vloc),
+                                  dv_from_decl (var), 0,
+                                  VAR_INIT_STATUS_INITIALIZED, NULL_RTX,
+                                  INSERT);
            }
            break;
 
@@ -6902,6 +6938,8 @@ emit_note_insn_var_location (void **varp, void *data)
        }
       loc[n_var_parts] = loc2;
       mode = GET_MODE (var->var_part[i].cur_loc);
+      if (mode == VOIDmode && dv_onepart_p (var->dv))
+       mode = DECL_MODE (decl);
       for (lc = var->var_part[i].loc_chain; lc; lc = lc->next)
        if (var->var_part[i].cur_loc == lc->loc)
          {
@@ -7423,6 +7461,11 @@ emit_notes_in_bb (basic_block bb, dataflow_set *set)
                                     VAR_INIT_STATUS_INITIALIZED, NULL_RTX,
                                     INSERT);
                }
+             else if (!VAR_LOC_UNKNOWN_P (PAT_VAR_LOCATION_LOC (vloc)))
+               set_variable_part (set, PAT_VAR_LOCATION_LOC (vloc),
+                                  dv_from_decl (var), 0,
+                                  VAR_INIT_STATUS_INITIALIZED, NULL_RTX,
+                                  INSERT);
 
              emit_notes_for_changes (insn, EMIT_NOTE_AFTER_INSN, set->vars);
            }