+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
--- /dev/null
+/* 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
+}
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. */
}
}
- 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;
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;
}
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)
{
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);
}