Message ID | 530e2bd8-5f18-deaf-9188-1c5e8e5b365d@mentor.com |
---|---|
State | New |
Headers | show |
Series | [RFC] Add means to split dump file into several files -- Use in lra | expand |
On Thu, 7 Dec 2017, Tom de Vries wrote: > 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? Sometimes it's harder to walk through multiple files IMHO. Merging ira and lra dumps would be nice. ;) And you can open a file multiple times so what's exactly the benefit of having multiple files? Richard.
On 12/07/2017 09:53 AM, Tom de Vries wrote: > 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? > Personally for me the size of LRA dump file is not a problem. What is inconvenient is that sometimes I need to see RTL after each subpass. Currently I do it by calling debug_rtx_range in gdb after the subpass in question. So this approach would be useful at least for me in some cases. But I think it should be not a default approach because in many other cases the current LRA dump file is enough. Moreover I even prefer to have one file for IRA and LRA and frequently use -fira-verbose=1<a digit> which output both IRA and LRA dumps into stderr.
On 12/14/2017 06:00 PM, Vladimir Makarov wrote: > What is inconvenient is that sometimes I need to see RTL after each > subpass. Currently I do it by calling debug_rtx_range in gdb after the > subpass in question. > I've added dumping of the RTL after each subpass. > So this approach would be useful at least for me in some cases. But I > think it should be not a default approach I've added an option flra-split-dump, off by default. The dump files look like: ... $ ls -1 reduc-1.c.278r.reload* reduc-1.c.278r.reload reduc-1.c.278r.reload.001.remove_scratches reduc-1.c.278r.reload.002.lra_constraints reduc-1.c.278r.reload.003.lra_inheritance reduc-1.c.278r.reload.004.lra_create_live_ranges reduc-1.c.278r.reload.005.lra_assign reduc-1.c.278r.reload.006.lra_undo_inheritance reduc-1.c.278r.reload.007.lra_constraints reduc-1.c.278r.reload.008.lra_finishing reduc-1.c.278r.reload.009.remove_scratches reduc-1.c.278r.reload.010.lra_constraints reduc-1.c.278r.reload.011.lra_inheritance reduc-1.c.278r.reload.012.lra_create_live_ranges reduc-1.c.278r.reload.013.lra_assign reduc-1.c.278r.reload.014.lra_undo_inheritance reduc-1.c.278r.reload.015.lra_constraints reduc-1.c.278r.reload.016.lra_finishing reduc-1.c.278r.reload.017.remove_scratches reduc-1.c.278r.reload.018.lra_constraints reduc-1.c.278r.reload.019.lra_inheritance reduc-1.c.278r.reload.020.lra_create_live_ranges reduc-1.c.278r.reload.021.lra_assign reduc-1.c.278r.reload.022.lra_undo_inheritance reduc-1.c.278r.reload.023.lra_constraints reduc-1.c.278r.reload.024.lra_finishing ... The main dump file "reduc-1.c.278r.reload" contains all the dumping that is done by the pass manager, not by the lra pass itself. Bootstrapped and reg-tested on x86_64. Any further comments? Thanks, - Tom Add flra-split-dump 2017-12-20 Tom de Vries <tom@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. (dump_start): Handle bump field. (gcc::dump_manager::dump_bump, dump_bump) (gcc::dump_manager::reset_dump_bump, reset_dump_bump): New function. * dumpfile.h (struct dump_file_info): Add bump, save_bump and bump_name fields. (dump_bump, reset_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, lra_dump_bump_start, lra_reset_dump_bump): New function. (remove_scratches): Use lra_dump_bump. (lra): Use lra_dump_bump_start, lra_dump_bump and lra_reset_dump_bump. * common.opt (flra-split-dump): New switch. * ira.c (do_reload): Handle flag_lra_split_dump. --- gcc/common.opt | 3 ++ gcc/dumpfile.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++----- gcc/dumpfile.h | 13 +++++++- gcc/ira.c | 2 +- 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 | 47 ++++++++++++++++++++++++++++ 12 files changed, 149 insertions(+), 10 deletions(-) diff --git a/gcc/common.opt b/gcc/common.opt index d80ae5b..9da73e4 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -1798,6 +1798,9 @@ flra-remat Common Report Var(flag_lra_remat) Optimization Do CFG-sensitive rematerialization in LRA. +flra-split-dump +Common Report Var(flag_lra_split_dump) + flto Common Enable link-time optimization. diff --git a/gcc/dumpfile.c b/gcc/dumpfile.c index 4a59d60..d23f84f 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, 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 @@ -494,11 +514,12 @@ dump_start (int phase, dump_flags_t *flag_ptr) name = get_dump_file_name (phase); if (name) { - stream = strcmp ("stderr", name) == 0 - ? stderr - : strcmp ("stdout", name) == 0 - ? stdout - : fopen (name, dfi->pstate < 0 ? "w" : "a"); + stream + = (strcmp ("stderr", name) == 0 + ? stderr + : strcmp ("stdout", name) == 0 + ? stdout + : fopen (name, (dfi->pstate < 0 || dfi->bump) ? "w" : "a")); if (!stream) error ("could not open dump file %qs: %m", name); else @@ -529,6 +550,42 @@ 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); + if (dfi->save_bump) + { + dfi->bump = dfi->save_bump; + dfi->save_bump = 0; + } + dfi->bump++; + dfi->bump_name = bump_name; + dump_start (phase, NULL); + return dfi->pstream; +} + +FILE * +gcc::dump_manager::reset_dump_bump (int phase) +{ + 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->save_bump = dfi->bump; + dfi->bump = 0; + dfi->bump_name = NULL; + 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 +628,18 @@ 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 * +reset_dump_bump (int phase) +{ + return g->get_dumps ()->reset_dump_bump (phase); +} + +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..2d154c5 100644 --- a/gcc/dumpfile.h +++ b/gcc/dumpfile.h @@ -149,6 +149,9 @@ struct dump_file_info int alt_state; /* Dump file number. */ int num; + int bump; + int save_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 +162,8 @@ struct dump_file_info /* In dumpfile.c */ extern FILE *dump_begin (int, dump_flags_t *); +extern FILE *dump_bump (int, const char * = NULL); +extern FILE *reset_dump_bump (int); extern void dump_end (int, FILE *); extern int opt_info_switch_p (const char *); extern const char *dump_flag_name (int); @@ -244,7 +249,13 @@ public: int dump_start (int phase, dump_flags_t *flag_ptr); - /* Finish a tree dump for PHASE and close associated dump streams. Also + FILE * + dump_bump (int phase, const char *); + + FILE * + reset_dump_bump (int); + +/* Finish a tree dump for PHASE and close associated dump streams. Also reset the globals DUMP_FILE, ALT_DUMP_FILE, and DUMP_FLAGS. */ void dump_finish (int phase); diff --git a/gcc/ira.c b/gcc/ira.c index 79837da..ca5dbd8 100644 --- a/gcc/ira.c +++ b/gcc/ira.c @@ -5416,7 +5416,7 @@ do_reload (void) bool need_dce; unsigned pic_offset_table_regno = INVALID_REGNUM; - if (flag_ira_verbose < 10) + if (flag_lra_split_dump || flag_ira_verbose < 10) ira_dump_file = dump_file; /* If pic_offset_table_rtx is a pseudo register, then keep it so 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 4adf4bf..7523e04 100644 --- a/gcc/lra-constraints.c +++ b/gcc/lra-constraints.c @@ -4646,6 +4646,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); @@ -6449,6 +6450,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; @@ -6903,6 +6905,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 785e436..49eed3b 100644 --- a/gcc/lra-lives.c +++ b/gcc/lra-lives.c @@ -1377,6 +1377,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 943d1ca..fc5f019 100644 --- a/gcc/lra.c +++ b/gcc/lra.c @@ -121,6 +121,48 @@ 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" +#include "tree-cfg.h" + +static bool first_bump; + +static void +lra_dump_bump_start (void) +{ + if (!flag_lra_split_dump) + return; + + first_bump = true; +} + +void +lra_dump_bump (const char *bump_name) +{ + if (!flag_lra_split_dump) + return; + + if (first_bump) + first_bump = false; + else + { + fprintf (lra_dump_file, "\nlra subpass result:\n"); + print_rtl_with_bb (lra_dump_file, get_insns (), dump_flags); + } + + lra_dump_file = dump_bump (current_pass->static_pass_number, bump_name); +} + +static void +lra_reset_dump_bump (void) +{ + if (!flag_lra_split_dump) + return; + + fprintf (lra_dump_file, "\nlra subpass result:\n"); + print_rtl_with_bb (lra_dump_file, get_insns (), dump_flags); + + lra_dump_file = reset_dump_bump (current_pass->static_pass_number); +} /* Dump bitmap SET with TITLE and BB INDEX. */ void @@ -2048,6 +2090,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); @@ -2335,6 +2379,7 @@ lra (FILE *f) bool live_p, inserted_p; lra_dump_file = f; + lra_dump_bump_start (); timevar_push (TV_LRA); @@ -2525,6 +2570,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 (); @@ -2564,6 +2610,7 @@ lra (FILE *f) check_rtl (true); timevar_pop (TV_LRA); + lra_reset_dump_bump (); } /* Called once per compiler to initialize LRA data once. */
On 12/20/2017 07:42 AM, Tom de Vries wrote: > On 12/14/2017 06:00 PM, Vladimir Makarov wrote: >> What is inconvenient is that sometimes I need to see RTL after each >> subpass. Currently I do it by calling debug_rtx_range in gdb after the >> subpass in question. >> > > I've added dumping of the RTL after each subpass. > >> So this approach would be useful at least for me in some cases. But I >> think it should be not a default approach > > I've added an option flra-split-dump, off by default. > > The dump files look like: > ... > $ ls -1 reduc-1.c.278r.reload* > reduc-1.c.278r.reload > reduc-1.c.278r.reload.001.remove_scratches > reduc-1.c.278r.reload.002.lra_constraints > reduc-1.c.278r.reload.003.lra_inheritance > reduc-1.c.278r.reload.004.lra_create_live_ranges > reduc-1.c.278r.reload.005.lra_assign > reduc-1.c.278r.reload.006.lra_undo_inheritance > reduc-1.c.278r.reload.007.lra_constraints > reduc-1.c.278r.reload.008.lra_finishing > reduc-1.c.278r.reload.009.remove_scratches > reduc-1.c.278r.reload.010.lra_constraints > reduc-1.c.278r.reload.011.lra_inheritance > reduc-1.c.278r.reload.012.lra_create_live_ranges > reduc-1.c.278r.reload.013.lra_assign > reduc-1.c.278r.reload.014.lra_undo_inheritance > reduc-1.c.278r.reload.015.lra_constraints > reduc-1.c.278r.reload.016.lra_finishing > reduc-1.c.278r.reload.017.remove_scratches > reduc-1.c.278r.reload.018.lra_constraints > reduc-1.c.278r.reload.019.lra_inheritance > reduc-1.c.278r.reload.020.lra_create_live_ranges > reduc-1.c.278r.reload.021.lra_assign > reduc-1.c.278r.reload.022.lra_undo_inheritance > reduc-1.c.278r.reload.023.lra_constraints > reduc-1.c.278r.reload.024.lra_finishing > ... > > The main dump file "reduc-1.c.278r.reload" contains all the dumping that > is done by the pass manager, not by the lra pass itself. > > Bootstrapped and reg-tested on x86_64. > > Any further comments? The new option needs a help string in the .opt file and documentation in invoke.texi, no? -Sandra
Add dump_bump 2017-12-07 Tom de Vries <tom@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. */