This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[vta] assorted fixes to complete bootstrap-debug on x86_64-linux-gnu
- From: Alexandre Oliva <aoliva at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 15 Oct 2007 15:44:24 -0200
- Subject: [vta] assorted fixes to complete bootstrap-debug on x86_64-linux-gnu
I've just installed a number of patches in the
var-tracking-assignments branch. With this patchset, it passes
compare-debug again, and it builds all target libraries successfully
with and without -g, even if still with some 400+ differences in the
generated code for such libraries.
I've also reverted the patch that enables unconditional coalescing of
all variables and installed the one referenced by URL below instead,
that introduces command-line flags to control this while retaining the
current default. The first patch below then restores the branch
behavior of permitting coalescing of all variables by default.
http://gcc.gnu.org/ml/gcc-patches/2007-10/msg00516.html
Furthermore, I've reverted the patch that performed unused block
collection but that contained an error, as well as a few other patches
that compensated for (papered over?) the error, and installed the one
I posted at http://gcc.gnu.org/ml/gcc-patches/2007-10/msg00608.html
along with the last patch below.
for gcc/ChangeLog.vta
from Alexandre Oliva <aoliva@redhat.com>
* common.opt (ftree-coalesce-inlined-vars): Change default.
* doc/invoke.texi: Document default change. Mention
var-tracking-assignments.
Index: gcc/common.opt
===================================================================
--- gcc/common.opt.orig 2007-10-10 05:11:09.000000000 -0300
+++ gcc/common.opt 2007-10-10 05:11:28.000000000 -0300
@@ -1041,7 +1041,7 @@ Common Report Var(flag_tree_ch) Optimiza
Enable loop header copying on trees
ftree-coalesce-inlined-vars
-Common Report Var(flag_ssa_coalesce_vars,1) Init(1) RejectNegative Optimization
+Common Report Var(flag_ssa_coalesce_vars,1) Init(-1) RejectNegative Optimization
Permit SSA coalescing of inlined variables only
ftree-coalesce-vars
Index: gcc/doc/invoke.texi
===================================================================
--- gcc/doc/invoke.texi.orig 2007-10-10 05:11:23.000000000 -0300
+++ gcc/doc/invoke.texi 2007-10-10 05:11:34.000000000 -0300
@@ -5810,11 +5810,12 @@ Permit the copyrename pass to subject in
into other variables. This may harm debug information of such inlined
variables, but it will keep variables of the main function apart from
each other, such that they are more likely to contain the expected
-values in a debugging session. This option is enabled by default.
+values in a debugging session.
@item -ftree-coalesce-vars
Permit the copyrename pass to subject all variables to SSA coalescing.
-This may severely limit the ability to debug a program. In the negated
+This may severely limit the ability to debug an optimized program
+compiled without @option{-fvar-tracking-assignments}. In the negated
form, this flag prevents SSA coalescing of user variables, including
inlined ones.
for gcc/ChangeLog.vta
from Alexandre Oliva <aoliva@redhat.com>
* fwprop.c (forward_propagate_and_simplify): ...into debug insns.
Index: gcc/fwprop.c
===================================================================
--- gcc/fwprop.c.orig 2007-09-08 20:11:25.000000000 -0300
+++ gcc/fwprop.c 2007-10-10 14:59:35.000000000 -0300
@@ -776,11 +776,11 @@ forward_propagate_and_simplify (struct d
bool set_reg_equal;
enum machine_mode mode;
- if (!use_set)
+ if (!use_set && !DEBUG_INSN_P (use_insn))
return false;
/* Do not propagate into PC, CC0, etc. */
- if (GET_MODE (SET_DEST (use_set)) == VOIDmode)
+ if (use_set && GET_MODE (SET_DEST (use_set)) == VOIDmode)
return false;
/* If def and use are subreg, check if they match. */
@@ -812,7 +812,7 @@ forward_propagate_and_simplify (struct d
if (MEM_P (src) && MEM_READONLY_P (src))
{
rtx x = avoid_constant_pool_reference (src);
- if (x != src)
+ if (use_set && x != src)
{
rtx note = find_reg_note (use_insn, REG_EQUAL, NULL_RTX);
rtx old = note ? XEXP (note, 0) : SET_SRC (use_set);
@@ -830,6 +830,11 @@ forward_propagate_and_simplify (struct d
loc = &SET_DEST (use_set);
set_reg_equal = false;
}
+ else if (!use_set)
+ {
+ loc = &INSN_VAR_LOCATION_LOC (use_insn);
+ set_reg_equal = false;
+ }
else
{
rtx note = find_reg_note (use_insn, REG_EQUAL, NULL_RTX);
for gcc/ChangeLog.vta
from Alexandre Oliva <aoliva@redhat.com>
* global.c (build_insn_chain): Skip debug insns.
Index: gcc/global.c
===================================================================
--- gcc/global.c.orig 2007-10-09 03:31:03.000000000 -0300
+++ gcc/global.c 2007-10-10 22:07:28.000000000 -0300
@@ -1418,7 +1418,7 @@ build_insn_chain (void)
FOR_BB_INSNS_REVERSE (bb, insn)
{
- if (!NOTE_P (insn) && !BARRIER_P (insn))
+ if (!NOTE_P (insn) && !BARRIER_P (insn) && !DEBUG_INSN_P (insn))
{
unsigned int uid = INSN_UID (insn);
struct df_ref **def_rec;
for gcc/ChangeLog.vta
from Alexandre Oliva <aoliva@redhat.com>
* var-tracking.c (dump_variable): Don't crash while dumping
anonymous temporary variables.
Index: gcc/var-tracking.c
===================================================================
--- gcc/var-tracking.c.orig 2007-10-01 22:49:01.000000000 -0300
+++ gcc/var-tracking.c 2007-10-10 23:07:17.000000000 -0300
@@ -2241,8 +2241,11 @@ dump_variable (void **slot, void *data A
int i;
location_chain node;
- fprintf (dump_file, " name: %s\n",
- IDENTIFIER_POINTER (DECL_NAME (var->decl)));
+ if (DECL_NAME (var->decl))
+ fprintf (dump_file, " name: %s\n",
+ IDENTIFIER_POINTER (DECL_NAME (var->decl)));
+ else
+ fprintf (dump_file, " name: D.%u", DECL_UID (var->decl));
for (i = 0; i < var->n_var_parts; i++)
{
fprintf (dump_file, " offset %ld\n",
for gcc/ChangeLog.vta
from Alexandre Oliva <aoliva@redhat.com>
* local-alloc.c: Include target.h.
(adjust_debug_insns_equivs): New.
(update_equiv_regs): Use it. Keep DF info up-to-date.
* emit-rtl.c (next_nondebug_insn): New fn.
(prev_nondebug_insn): New fn.
* rtl.h: Declare them.
* Makefile.in (local-alloc.o): Adjust deps.
Index: gcc/local-alloc.c
===================================================================
--- gcc/local-alloc.c.orig 2007-10-11 20:09:39.000000000 -0300
+++ gcc/local-alloc.c 2007-10-12 03:53:28.000000000 -0300
@@ -81,6 +81,7 @@ along with GCC; see the file COPYING3.
#include "timevar.h"
#include "tree-pass.h"
#include "df.h"
+#include "target.h"
#include "dbgcnt.h"
@@ -785,6 +786,64 @@ memref_used_between_p (rtx memref, rtx s
return 0;
}
+/* Adjust all debug insns that reference REGNO to its equivalent
+ expression. This assumes the debug insns are located between the
+ DEF and the USE, and that the expression in the DEF is still valid
+ at the point of USE. */
+
+static void
+adjust_debug_insns_equivs (unsigned regno)
+{
+ struct df_ref *use;
+ rtx eqv = NULL;
+
+ gcc_assert (num_changes_pending () == 0);
+
+ for (use = DF_REG_USE_CHAIN (regno); use; use = DF_REF_NEXT_REG (use))
+ {
+ rtx insn = DF_REF_INSN (use), *loc, x;
+
+ if (!DEBUG_INSN_P (insn))
+ continue;
+
+ if (!eqv)
+ {
+ eqv = *reg_equiv[regno].src_p;
+ if (MEM_P (eqv))
+ eqv = targetm.delegitimize_address (eqv);
+ }
+
+ loc = DF_REF_LOC (use);
+ x = *loc;
+
+ if (REG_P (x) && REGNO (x) == regno)
+ {
+ gcc_assert (GET_MODE (eqv) == VOIDmode
+ || GET_MODE (eqv) == GET_MODE (x));
+ validate_unshare_change (insn, loc, eqv, true);
+ }
+ else if (GET_CODE (x) == SUBREG && REGNO (SUBREG_REG (x)) == regno)
+ {
+ rtx sreqv;
+
+ gcc_assert (GET_MODE (eqv) == VOIDmode
+ || GET_MODE (eqv) == GET_MODE (SUBREG_REG (x)));
+
+
+ sreqv = simplify_gen_subreg (GET_MODE (x), copy_rtx (eqv),
+ GET_MODE (SUBREG_REG (x)),
+ SUBREG_BYTE (x));
+
+ validate_change (insn, loc, sreqv, true);
+ }
+ else
+ gcc_unreachable ();
+ }
+
+ if (eqv && !apply_change_group ())
+ gcc_unreachable ();
+}
+
/* Find registers that are equivalent to a single value throughout the
compilation (either because they can be referenced in memory or are set once
from a single constant). Lower their priority for a register.
@@ -1146,6 +1205,9 @@ update_equiv_regs (void)
last_link = XEXP (last_link, 1))
;
+ if (MAY_HAVE_DEBUG_INSNS)
+ adjust_debug_insns_equivs (regno);
+
/* Append the REG_DEAD notes from equiv_insn. */
equiv_link = REG_NOTES (equiv_insn);
while (equiv_link)
@@ -1164,6 +1226,7 @@ update_equiv_regs (void)
remove_death (regno, insn);
SET_REG_N_REFS (regno, 0);
REG_FREQ (regno) = 0;
+ df_insn_delete (bb, INSN_UID (equiv_insn));
delete_insn (equiv_insn);
reg_equiv[regno].init_insns
@@ -1174,10 +1237,13 @@ update_equiv_regs (void)
}
/* Move the initialization of the register to just before
INSN. Update the flow information. */
- else if (PREV_INSN (insn) != equiv_insn)
+ else if (prev_nondebug_insn (insn) != equiv_insn)
{
rtx new_insn;
+ if (MAY_HAVE_DEBUG_INSNS)
+ adjust_debug_insns_equivs (regno);
+
new_insn = emit_insn_before (PATTERN (equiv_insn), insn);
REG_NOTES (new_insn) = REG_NOTES (equiv_insn);
REG_NOTES (equiv_insn) = 0;
@@ -1187,6 +1253,8 @@ update_equiv_regs (void)
eliminate_regs_in_insn will die. */
INSN_CODE (new_insn) = INSN_CODE (equiv_insn);
+ df_insn_rescan (new_insn);
+ df_insn_delete (bb, INSN_UID (equiv_insn));
delete_insn (equiv_insn);
XEXP (reg_equiv[regno].init_insns, 0) = new_insn;
Index: gcc/emit-rtl.c
===================================================================
--- gcc/emit-rtl.c.orig 2007-10-11 20:09:39.000000000 -0300
+++ gcc/emit-rtl.c 2007-10-11 20:09:43.000000000 -0300
@@ -2931,6 +2931,38 @@ prev_nonnote_insn (rtx insn)
return insn;
}
+/* Return the next insn after INSN that is not a DEBUG_INSN. This
+ routine does not look inside SEQUENCEs. */
+
+rtx
+next_nondebug_insn (rtx insn)
+{
+ while (insn)
+ {
+ insn = NEXT_INSN (insn);
+ if (insn == 0 || !DEBUG_INSN_P (insn))
+ break;
+ }
+
+ return insn;
+}
+
+/* Return the previous insn before INSN that is not a DEBUG_INSN.
+ This routine does not look inside SEQUENCEs. */
+
+rtx
+prev_nondebug_insn (rtx insn)
+{
+ while (insn)
+ {
+ insn = PREV_INSN (insn);
+ if (insn == 0 || !DEBUG_INSN_P (insn))
+ break;
+ }
+
+ return insn;
+}
+
/* Return the next INSN, CALL_INSN or JUMP_INSN after INSN;
or 0, if there is none. This routine does not look inside
SEQUENCEs. */
Index: gcc/rtl.h
===================================================================
--- gcc/rtl.h.orig 2007-10-11 20:09:39.000000000 -0300
+++ gcc/rtl.h 2007-10-11 20:09:43.000000000 -0300
@@ -1639,6 +1639,8 @@ extern rtx previous_insn (rtx);
extern rtx next_insn (rtx);
extern rtx prev_nonnote_insn (rtx);
extern rtx next_nonnote_insn (rtx);
+extern rtx prev_nondebug_insn (rtx);
+extern rtx next_nondebug_insn (rtx);
extern rtx prev_real_insn (rtx);
extern rtx next_real_insn (rtx);
extern rtx prev_active_insn (rtx);
Index: gcc/Makefile.in
===================================================================
--- gcc/Makefile.in.orig 2007-10-11 20:09:39.000000000 -0300
+++ gcc/Makefile.in 2007-10-11 20:09:43.000000000 -0300
@@ -2700,7 +2700,8 @@ regclass.o : regclass.c $(CONFIG_H) $(SY
local-alloc.o : local-alloc.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
$(RTL_H) $(FLAGS_H) $(REGS_H) hard-reg-set.h insn-config.h $(RECOG_H) \
output.h $(FUNCTION_H) $(INSN_ATTR_H) toplev.h except.h reload.h $(TM_P_H) \
- $(GGC_H) $(INTEGRATE_H) $(TIMEVAR_H) tree-pass.h $(DF_H) $(DBGCNT_H)
+ $(GGC_H) $(INTEGRATE_H) $(TIMEVAR_H) tree-pass.h $(DF_H) $(TARGET_H) \
+ $(DBGCNT_H)
bitmap.o : bitmap.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \
$(FLAGS_H) $(GGC_H) gt-bitmap.h bitmap.h $(OBSTACK_H)
global.o : global.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \
for gcc/ChangeLog.vta
from Alexandre Oliva <aoliva@redhat.com>
* tree-inline.c (processing_debug_stmt_p): Renamed to...
(processing_debug_stmt): ... this. Change type to int.
(remap_decl): Don't remap new decls in debug stmts. Mark error
condition.
(copy_debug_stmt): Check error conditions.
Index: gcc/tree-inline.c
===================================================================
--- gcc/tree-inline.c.orig 2007-10-11 03:01:47.000000000 -0300
+++ gcc/tree-inline.c 2007-10-11 20:07:31.000000000 -0300
@@ -201,7 +201,11 @@ remap_ssa_name (tree name, copy_body_dat
return new;
}
-bool processing_debug_stmt_p = false;
+/* If nonzero, we're remapping the contents of inlined debug
+ statements. If negative, an error has occurred, such as a
+ reference to a variable that isn't available in the inlined
+ context. */
+int processing_debug_stmt = 0;
/* Remap DECL during the copying of the BLOCK tree for the function. */
@@ -218,6 +222,12 @@ remap_decl (tree decl, copy_body_data *i
n = (tree *) pointer_map_contains (id->decl_map, decl);
+ if (!n && processing_debug_stmt)
+ {
+ processing_debug_stmt = -1;
+ return decl;
+ }
+
/* If we didn't already have an equivalent for this declaration,
create one now. */
if (!n)
@@ -264,8 +274,7 @@ remap_decl (tree decl, copy_body_data *i
if (TREE_CODE (map) == SSA_NAME)
set_default_def (t, map);
}
- if (!processing_debug_stmt_p)
- add_referenced_var (t);
+ add_referenced_var (t);
}
return t;
}
@@ -1366,15 +1375,20 @@ copy_debug_stmt (tree stmt, copy_body_da
{
tree t;
- processing_debug_stmt_p = true;
+ processing_debug_stmt = 1;
t = VAR_DEBUG_VALUE_VAR (stmt);
walk_tree (&t, copy_body_r, id, NULL);
VAR_DEBUG_VALUE_SET_VAR (stmt, t);
+ gcc_assert (processing_debug_stmt == 1);
+
walk_tree (&VAR_DEBUG_VALUE_VALUE (stmt), copy_body_r, id, NULL);
- processing_debug_stmt_p = false;
+ if (processing_debug_stmt < 0)
+ VAR_DEBUG_VALUE_VALUE (stmt) = VAR_DEBUG_VALUE_NOVALUE;
+
+ processing_debug_stmt = 0;
update_stmt (stmt);
if (gimple_in_ssa_p (cfun))
--
Alexandre Oliva http://www.lsd.ic.unicamp.br/~oliva/
FSF Latin America Board Member http://www.fsfla.org/
Red Hat Compiler Engineer aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist oliva@{lsd.ic.unicamp.br, gnu.org}