Hi! Before we start looking into enabling certain 'pass_postreload' passes for nvptx, as we've been discussing in <https://inbox.sourceware.org/007a01dac921$82d0d9c0$88728d40$@nextmovesoftware.com> "nvptx vs. [PATCH] Add a late-combine pass [PR106594]", let's first document the (not quite obvious) status quo:
On 2014-10-20T16:24:43+0200, Bernd Schmidt <ber...@codesourcery.com> wrote: > This stops most of the post-regalloc passes to be run if the target > doesn't want register allocation. I'd previously moved them all out of > postreload to the toplevel, but Jakub (I think) pointed out that the > idea is not to run them to avoid crashes if reload fails e.g. for an > invalid asm. So I've made a new container pass. OK to push "Document 'pass_postreload' vs. 'pass_late_compilation'", see attached? Grüße Thomas > A later patch will make thread_prologue_and_epilogue_insns callable from > the backend. > > > Bernd > > gcc/ > * passes.def (pass_compute_alignments, pass_duplicate_computed_gotos, > pass_variable_tracking, pass_free_cfg, pass_machine_reorg, > pass_cleanup_barriers, pass_delay_slots, > pass_split_for_shorten_branches, pass_convert_to_eh_region_ranges, > pass_shorten_branches, pass_est_nothrow_function_flags, > pass_dwarf2_frame, pass_final): Move outside of pass_postreload and > into pass_late_compilation. > (pass_late_compilation): Add. > * passes.c (pass_data_late_compilation, pass_late_compilation, > make_pass_late_compilation): New. > * timevar.def (TV_LATE_COMPILATION): New. > > ------------------------------------------------------------------------ > Index: gcc/passes.def > =================================================================== > --- gcc/passes.def.orig > +++ gcc/passes.def > @@ -415,6 +415,9 @@ along with GCC; see the file COPYING3. > NEXT_PASS (pass_split_before_regstack); > NEXT_PASS (pass_stack_regs_run); > POP_INSERT_PASSES () > + POP_INSERT_PASSES () > + NEXT_PASS (pass_late_compilation); > + PUSH_INSERT_PASSES_WITHIN (pass_late_compilation) > NEXT_PASS (pass_compute_alignments); > NEXT_PASS (pass_variable_tracking); > NEXT_PASS (pass_free_cfg); > Index: gcc/passes.c > =================================================================== > --- gcc/passes.c.orig > +++ gcc/passes.c > @@ -569,6 +569,44 @@ make_pass_postreload (gcc::context *ctxt > return new pass_postreload (ctxt); > } > > +namespace { > + > +const pass_data pass_data_late_compilation = > +{ > + RTL_PASS, /* type */ > + "*all-late_compilation", /* name */ > + OPTGROUP_NONE, /* optinfo_flags */ > + TV_LATE_COMPILATION, /* tv_id */ > + PROP_rtl, /* properties_required */ > + 0, /* properties_provided */ > + 0, /* properties_destroyed */ > + 0, /* todo_flags_start */ > + 0, /* todo_flags_finish */ > +}; > + > +class pass_late_compilation : public rtl_opt_pass > +{ > +public: > + pass_late_compilation (gcc::context *ctxt) > + : rtl_opt_pass (pass_data_late_compilation, ctxt) > + {} > + > + /* opt_pass methods: */ > + virtual bool gate (function *) > + { > + return reload_completed || targetm.no_register_allocation; > + } > + > +}; // class pass_late_compilation > + > +} // anon namespace > + > +static rtl_opt_pass * > +make_pass_late_compilation (gcc::context *ctxt) > +{ > + return new pass_late_compilation (ctxt); > +} > + > > > /* Set the static pass number of pass PASS to ID and record that > Index: gcc/timevar.def > =================================================================== > --- gcc/timevar.def.orig > +++ gcc/timevar.def > @@ -270,6 +270,7 @@ DEFTIMEVAR (TV_EARLY_LOCAL , "early > DEFTIMEVAR (TV_OPTIMIZE , "unaccounted optimizations") > DEFTIMEVAR (TV_REST_OF_COMPILATION , "rest of compilation") > DEFTIMEVAR (TV_POSTRELOAD , "unaccounted post reload") > +DEFTIMEVAR (TV_LATE_COMPILATION , "unaccounted late compilation") > DEFTIMEVAR (TV_REMOVE_UNUSED , "remove unused locals") > DEFTIMEVAR (TV_ADDRESS_TAKEN , "address taken") > DEFTIMEVAR (TV_TODO , "unaccounted todo")
>From 7f708dd9774773e704cb06b7a6f296927f9057df Mon Sep 17 00:00:00 2001 From: Thomas Schwinge <tschwi...@baylibre.com> Date: Fri, 28 Jun 2024 16:04:18 +0200 Subject: [PATCH] Document 'pass_postreload' vs. 'pass_late_compilation' See Subversion r217124 (Git commit 433e4164339f18d0b8798968444a56b681b5232c) "Reorganize post-ra pipeline for targets without register allocation". gcc/ * passes.cc: Document 'pass_postreload' vs. 'pass_late_compilation'. * passes.def: Likewise. --- gcc/passes.cc | 14 +++++++++++++- gcc/passes.def | 3 +++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/gcc/passes.cc b/gcc/passes.cc index d3648a24b58..e444b462113 100644 --- a/gcc/passes.cc +++ b/gcc/passes.cc @@ -660,6 +660,10 @@ make_pass_rest_of_compilation (gcc::context *ctxt) namespace { +/* A container pass (only) for '!targetm.no_register_allocation' targets, for + passes to run if reload completed (..., but not run them if it failed, for + example for an invalid 'asm'). See also 'pass_late_compilation'. */ + const pass_data pass_data_postreload = { RTL_PASS, /* type */ @@ -681,7 +685,12 @@ public: {} /* opt_pass methods: */ - bool gate (function *) final override { return reload_completed; } + bool gate (function *) final override + { + if (reload_completed) + gcc_checking_assert (!targetm.no_register_allocation); + return reload_completed; + } }; // class pass_postreload @@ -695,6 +704,9 @@ make_pass_postreload (gcc::context *ctxt) namespace { +/* A container pass like 'pass_postreload', but for passes to run also for + 'targetm.no_register_allocation' targets. */ + const pass_data pass_data_late_compilation = { RTL_PASS, /* type */ diff --git a/gcc/passes.def b/gcc/passes.def index 61ca210822a..72198bc4c4e 100644 --- a/gcc/passes.def +++ b/gcc/passes.def @@ -507,6 +507,9 @@ along with GCC; see the file COPYING3. If not see NEXT_PASS (pass_early_remat); NEXT_PASS (pass_ira); NEXT_PASS (pass_reload); + /* In the following, some passes are tied to 'pass_postreload' and others + to 'pass_late_compilation'. The difference is that the latter also + run for 'targetm.no_register_allocation' targets. */ NEXT_PASS (pass_postreload); PUSH_INSERT_PASSES_WITHIN (pass_postreload) NEXT_PASS (pass_postreload_cse); -- 2.34.1