Hi,
I'm currently debugging a problem in lra, and got a bit lost in the 20k+
lines dump file.
I observed that:
- the lra dump file is one of the biggest ones
- lra itself consists of a looping of sub-passes.
So, I've:
- written a dump infrastructure addition that can be used within a pass
to mark the end of the current (sub)dump file and start a next
subdump file.
- used that infrastructure to instrument lra to dump info from
different subpasses into separate files.
Using this patch I managed to split the reload dump file into smaller bits:
...
$ wc -l *.reload.*
3 no-scevccp-outer-10.c.276r.reload
0 no-scevccp-outer-10.c.276r.reload.001.lra_start
3 no-scevccp-outer-10.c.276r.reload.002.remove_scratches
2335 no-scevccp-outer-10.c.276r.reload.003.lra_constraints
1781 no-scevccp-outer-10.c.276r.reload.004.lra_create_live_ranges
460 no-scevccp-outer-10.c.276r.reload.005.lra_inheritance
920 no-scevccp-outer-10.c.276r.reload.006.lra_create_live_ranges
563 no-scevccp-outer-10.c.276r.reload.007.lra_assign
184 no-scevccp-outer-10.c.276r.reload.008.lra_undo_inheritance
830 no-scevccp-outer-10.c.276r.reload.009.lra_create_live_ranges
3 no-scevccp-outer-10.c.276r.reload.010.lra_coalesce
165 no-scevccp-outer-10.c.276r.reload.011.lra_constraints
844 no-scevccp-outer-10.c.276r.reload.012.lra_create_live_ranges
110 no-scevccp-outer-10.c.276r.reload.013.lra_inheritance
879 no-scevccp-outer-10.c.276r.reload.014.lra_create_live_ranges
22 no-scevccp-outer-10.c.276r.reload.015.lra_assign
74 no-scevccp-outer-10.c.276r.reload.016.lra_undo_inheritance
19 no-scevccp-outer-10.c.276r.reload.017.lra_constraints
845 no-scevccp-outer-10.c.276r.reload.018.lra_create_live_ranges
80 no-scevccp-outer-10.c.276r.reload.019.lra_remat
27 no-scevccp-outer-10.c.276r.reload.020.lra_spill
866 no-scevccp-outer-10.c.276r.reload.021.lra_constraints
830 no-scevccp-outer-10.c.276r.reload.022.lra_create_live_ranges
0 no-scevccp-outer-10.c.276r.reload.023.lra_inheritance
830 no-scevccp-outer-10.c.276r.reload.024.lra_create_live_ranges
53 no-scevccp-outer-10.c.276r.reload.025.lra_assign
5 no-scevccp-outer-10.c.276r.reload.026.lra_constraints
370 no-scevccp-outer-10.c.276r.reload.027.lra_finishing
4137 no-scevccp-outer-10.c.276r.reload.028.lra_end
0 no-scevccp-outer-10.c.276r.reload.029.lra_start
27 no-scevccp-outer-10.c.276r.reload.030.remove_scratches
553 no-scevccp-outer-10.c.276r.reload.031.lra_constraints
188 no-scevccp-outer-10.c.276r.reload.032.lra_create_live_ranges
8 no-scevccp-outer-10.c.276r.reload.033.lra_inheritance
188 no-scevccp-outer-10.c.276r.reload.034.lra_create_live_ranges
21 no-scevccp-outer-10.c.276r.reload.035.lra_assign
3 no-scevccp-outer-10.c.276r.reload.036.lra_undo_inheritance
5 no-scevccp-outer-10.c.276r.reload.037.lra_constraints
99 no-scevccp-outer-10.c.276r.reload.038.lra_finishing
515 no-scevccp-outer-10.c.276r.reload.039.lra_end
...
Notes:
- dump info from different functions is not put together
- this is on by default atm. We probably want to enable this only
using a switch fsplit-dump or some such.
- the lra_end dump files ends with ";; Function ...", which should be in
the next lra_start dump file. Once we enable this using a switch we
can probably do better.
Any comments?
Thanks,
- Tom
Add dump_bump
2017-12-07 Tom de Vries <t...@codesourcery.com>
* dumpfile.c (DUMP_FILE_INFO): Add inits for bump and bump_name fields.
(get_dump_file_name): Handle bump and bump_name fields.
(gcc::dump_manager::dump_bump, dump_bump): New function.
* dumpfile.h (struct dump_file_info): Add bump and bump_name fields.
(dump_bump): Declare.
* lra-assigns.c (lra_assign): Use lra_dump_bump.
* lra-coalesce.c (lra_coalesce): Same.
* lra-constraints.c (lra_constraints, lra_inheritance)
(lra_undo_inheritance): Same.
* lra-int.h (lra_dump_bump): Declare.
* lra-lives.c (lra_create_live_ranges): Use lra_dump_bump.
* lra-remat.c (lra_remat): Same.
* lra-spills.c (lra_spill): Same.
* lra.c (lra_dump_bump): New function.
(remove_scratches, lra): Use lra_dump_bump.
---
gcc/dumpfile.c | 47 ++++++++++++++++++++++++++++++++++++++++++++---
gcc/dumpfile.h | 6 ++++++
gcc/lra-assigns.c | 1 +
gcc/lra-coalesce.c | 1 +
gcc/lra-constraints.c | 3 +++
gcc/lra-int.h | 1 +
gcc/lra-lives.c | 1 +
gcc/lra-remat.c | 1 +
gcc/lra-spills.c | 1 +
gcc/lra.c | 12 ++++++++++++
10 files changed, 71 insertions(+), 3 deletions(-)
diff --git a/gcc/dumpfile.c b/gcc/dumpfile.c
index 658500b..47715c4 100644
--- a/gcc/dumpfile.c
+++ b/gcc/dumpfile.c
@@ -51,7 +51,7 @@ dump_flags_t dump_flags;
#define DUMP_FILE_INFO(suffix, swtch, dkind, num) \
{suffix, swtch, NULL, NULL, NULL, NULL, NULL, dkind, 0, 0, 0, 0, 0, num, \
- false, false}
+ 0, NULL, false, false}
/* Table of tree dump switches. This must be consistent with the
TREE_DUMP_INDEX enumeration in dumpfile.h. */
@@ -287,7 +287,14 @@ char *
gcc::dump_manager::
get_dump_file_name (struct dump_file_info *dfi) const
{
- char dump_id[10];
+ char dump_id[1 /* '.' */
+ + 7 /* '%03d' */
+ + 1 /* '[tir]' */
+ + 1 /* '\0' */];
+
+ char bump_id[1 /* '.' */
+ + 7 /* '%03d' */
+ + 1 /* '\0' */];
gcc_assert (dfi);
@@ -305,11 +312,24 @@ get_dump_file_name (struct dump_file_info *dfi) const
/* (null), LANG, TREE, RTL, IPA. */
char suffix = " ltri"[dfi->dkind];
+ if (dfi->bump > 0)
+ {
+ if (snprintf (bump_id, sizeof (bump_id), ".%03d", dfi->bump) < 0)
+ bump_id[0] = '\0';
+ }
+
if (snprintf (dump_id, sizeof (dump_id), ".%03d%c", dfi->num, suffix) < 0)
dump_id[0] = '\0';
}
- return concat (dump_base_name, dump_id, dfi->suffix, NULL);
+ if (dfi->bump_name)
+ return concat (dump_base_name, dump_id, dfi->suffix, bump_id, "." ,
+ dfi->bump_name, NULL);
+
+ if (dfi->bump > 0)
+ return concat (dump_base_name, dump_id, dfi->suffix, bump_id, NULL);
+
+ return concat (dump_base_name, dump_id, dfi->suffix, NULL);
}
/* For a given DFI, open an alternate dump filename (which could also
@@ -529,6 +549,21 @@ dump_start (int phase, dump_flags_t *flag_ptr)
return count;
}
+FILE *
+gcc::dump_manager::dump_bump (int phase, const char *bump_name)
+{
+ struct dump_file_info *dfi;
+ if (phase == TDI_none || !dump_phase_enabled_p (phase))
+ return 0;
+
+ dfi = get_dump_file_info (phase);
+ dump_finish (phase);
+ dfi->bump++;
+ dfi->bump_name = bump_name;
+ dump_start (phase, NULL);
+ return dfi->pstream;
+}
+
/* Finish a tree dump for PHASE and close associated dump streams. Also
reset the globals DUMP_FILE, ALT_DUMP_FILE, and DUMP_FLAGS. */
@@ -571,6 +606,12 @@ dump_begin (int phase, dump_flags_t *flag_ptr)
}
FILE *
+dump_bump (int phase, const char *bump_name)
+{
+ return g->get_dumps ()->dump_bump (phase, bump_name);
+}
+
+FILE *
gcc::dump_manager::
dump_begin (int phase, dump_flags_t *flag_ptr)
{
diff --git a/gcc/dumpfile.h b/gcc/dumpfile.h
index 1b4d7e7..4b2013d 100644
--- a/gcc/dumpfile.h
+++ b/gcc/dumpfile.h
@@ -149,6 +149,8 @@ struct dump_file_info
int alt_state;
/* Dump file number. */
int num;
+ int bump;
+ const char *bump_name;
/* Fields "suffix", "swtch", "glob" can be const strings,
or can be dynamically allocated, needing free. */
bool owns_strings;
@@ -159,6 +161,7 @@ struct dump_file_info
/* In dumpfile.c */
extern FILE *dump_begin (int, dump_flags_t *);
+extern FILE *dump_bump (int, const char * = NULL);
extern void dump_end (int, FILE *);
extern int opt_info_switch_p (const char *);
extern const char *dump_flag_name (int);
@@ -244,6 +247,9 @@ public:
int
dump_start (int phase, dump_flags_t *flag_ptr);
+ FILE *
+ dump_bump (int phase, const char *);
+
/* Finish a tree dump for PHASE and close associated dump streams. Also
reset the globals DUMP_FILE, ALT_DUMP_FILE, and DUMP_FLAGS. */
void
diff --git a/gcc/lra-assigns.c b/gcc/lra-assigns.c
index 5a65c7c..cd418e6 100644
--- a/gcc/lra-assigns.c
+++ b/gcc/lra-assigns.c
@@ -1624,6 +1624,7 @@ lra_assign (void)
bool no_spills_p;
int max_regno = max_reg_num ();
+ lra_dump_bump ("lra_assign");
timevar_push (TV_LRA_ASSIGN);
lra_assignment_iter++;
if (lra_dump_file != NULL)
diff --git a/gcc/lra-coalesce.c b/gcc/lra-coalesce.c
index 7af10d8..2bc4923 100644
--- a/gcc/lra-coalesce.c
+++ b/gcc/lra-coalesce.c
@@ -231,6 +231,7 @@ lra_coalesce (void)
timevar_push (TV_LRA_COALESCE);
+ lra_dump_bump ("lra_coalesce");
if (lra_dump_file != NULL)
fprintf (lra_dump_file,
"\n********** Pseudos coalescing #%d: **********\n\n",
diff --git a/gcc/lra-constraints.c b/gcc/lra-constraints.c
index 3758409..813760b 100644
--- a/gcc/lra-constraints.c
+++ b/gcc/lra-constraints.c
@@ -4645,6 +4645,7 @@ lra_constraints (bool first_p)
bitmap_iterator bi;
lra_constraint_iter++;
+ lra_dump_bump ("lra_constraints");
if (lra_dump_file != NULL)
fprintf (lra_dump_file, "\n********** Local #%d: **********\n\n",
lra_constraint_iter);
@@ -6440,6 +6441,7 @@ lra_inheritance (void)
basic_block bb, start_bb;
edge e;
+ lra_dump_bump ("lra_inheritance");
lra_inheritance_iter++;
if (lra_inheritance_iter > LRA_MAX_INHERITANCE_PASSES)
return;
@@ -6894,6 +6896,7 @@ lra_undo_inheritance (void)
lra_undo_inheritance_iter++;
if (lra_undo_inheritance_iter > LRA_MAX_INHERITANCE_PASSES)
return false;
+ lra_dump_bump ("lra_undo_inheritance");
if (lra_dump_file != NULL)
fprintf (lra_dump_file,
"\n********** Undoing inheritance #%d: **********\n\n",
diff --git a/gcc/lra-int.h b/gcc/lra-int.h
index 4050717..97d97e4 100644
--- a/gcc/lra-int.h
+++ b/gcc/lra-int.h
@@ -523,4 +523,5 @@ lra_assign_reg_val (int from, int to)
lra_reg_info[to].offset = lra_reg_info[from].offset;
}
+extern void lra_dump_bump (const char * = NULL);
#endif /* GCC_LRA_INT_H */
diff --git a/gcc/lra-lives.c b/gcc/lra-lives.c
index df7e253..c553375 100644
--- a/gcc/lra-lives.c
+++ b/gcc/lra-lives.c
@@ -1366,6 +1366,7 @@ lra_create_live_ranges_1 (bool all_p, bool dead_insn_p)
void
lra_create_live_ranges (bool all_p, bool dead_insn_p)
{
+ lra_dump_bump ("lra_create_live_ranges");
if (! lra_create_live_ranges_1 (all_p, dead_insn_p))
return;
if (lra_dump_file != NULL)
diff --git a/gcc/lra-remat.c b/gcc/lra-remat.c
index 768a6c9..b31a402 100644
--- a/gcc/lra-remat.c
+++ b/gcc/lra-remat.c
@@ -1306,6 +1306,7 @@ lra_remat (void)
lra_rematerialization_iter++;
if (lra_rematerialization_iter > LRA_MAX_REMATERIALIZATION_PASSES)
return false;
+ lra_dump_bump ("lra_remat");
if (lra_dump_file != NULL)
fprintf (lra_dump_file,
"\n******** Rematerialization #%d: ********\n\n",
diff --git a/gcc/lra-spills.c b/gcc/lra-spills.c
index 9abcda4..12c0a5f 100644
--- a/gcc/lra-spills.c
+++ b/gcc/lra-spills.c
@@ -548,6 +548,7 @@ lra_spill (void)
int i, n, curr_regno;
int *pseudo_regnos;
+ lra_dump_bump ("lra_spill");
regs_num = max_reg_num ();
spill_hard_reg = XNEWVEC (rtx, regs_num);
pseudo_regnos = XNEWVEC (int, regs_num);
diff --git a/gcc/lra.c b/gcc/lra.c
index 0d76eac..789d610 100644
--- a/gcc/lra.c
+++ b/gcc/lra.c
@@ -121,6 +121,13 @@ along with GCC; see the file COPYING3. If not see
#include "lra.h"
#include "lra-int.h"
#include "print-rtl.h"
+#include "tree-pass.h"
+
+void
+lra_dump_bump (const char *bump_name)
+{
+ lra_dump_file = dump_bump (current_pass->static_pass_number, bump_name);
+}
/* Dump bitmap SET with TITLE and BB INDEX. */
void
@@ -2028,6 +2035,8 @@ remove_scratches (void)
lra_insn_recog_data_t id;
struct lra_static_insn_data *static_id;
+ lra_dump_bump ("remove_scratches");
+
scratches.create (get_max_uid ());
bitmap_initialize (&scratch_bitmap, ®_obstack);
bitmap_initialize (&scratch_operand_bitmap, ®_obstack);
@@ -2315,6 +2324,7 @@ lra (FILE *f)
bool live_p, inserted_p;
lra_dump_file = f;
+ lra_dump_bump ("lra_start");
timevar_push (TV_LRA);
@@ -2505,6 +2515,7 @@ lra (FILE *f)
lra_bad_spill_regno_start = lra_constraint_new_regno_start;
lra_assignment_iter_after_spill = 0;
}
+ lra_dump_bump ("lra_finishing");
restore_scratches ();
lra_eliminate (true, false);
lra_final_code_change ();
@@ -2544,6 +2555,7 @@ lra (FILE *f)
check_rtl (true);
timevar_pop (TV_LRA);
+ lra_dump_bump ("lra_end");
}
/* Called once per compiler to initialize LRA data once. */