From patchwork Fri Jun 28 15:07:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 1954013 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=opNqy0xe; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W9f2C36J7z20Xg for ; Sat, 29 Jun 2024 01:08:03 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 283783826DE2 for ; Fri, 28 Jun 2024 15:08:00 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by sourceware.org (Postfix) with ESMTPS id D019D388461C for ; Fri, 28 Jun 2024 15:07:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D019D388461C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=baylibre.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D019D388461C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::336 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719587261; cv=none; b=n9vJxr3c0fyHNcLBXGm1JrcKuTeCBXWhHegGSPk4O0bw7Ju1c4/UFBdsgC753tZjBT0i1zvio9/tBsCDZRDaMA5szaeEY3SEONHFidTaXSo2Z7nimIJRstwEiuTTY0kw1FBpzhIEc33TjtbQS1hEtisfS86ACkF7hnblk+EPfAQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719587261; c=relaxed/simple; bh=X6htiGJWFAZ0Bc1/cFz71pWqIfJGrqutFuA1CVFSizw=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=liRaFmVEloWIIvx+Pl3IJSphM3X0RxLE+uFkaP6HzvelOOUpXivKpomYfxectPl+6i73TffHujTAfXOKDAuTwcON8Hs2s9pqopuefQSpSd/yhEj1nb8H1Y7gkB+DF6T9MUmPWHBeL++VkdphW3wQf8l8mR0UrLHcobUunhO0RzU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-424ad289912so5377015e9.2 for ; Fri, 28 Jun 2024 08:07:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1719587256; x=1720192056; darn=gcc.gnu.org; h=mime-version:message-id:date:user-agent:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=zbA4V8MZTVR414xRWikXqdLkk1/XJYFOLXJZpW0zqJ8=; b=opNqy0xe7AtjzSKAols7X5FjWrUmP1GP1Rr1sXuv1CZLyGZA89GB/An/frp1Ktmuxm UTJ42GBk6qDrdSzh9ZCTUj1yEo2IlEFb1UOQcWYExFUhy4jSp60QasX8X15G9ITCCCOl X4AXEZHyTa76Yc+U0i6uoq8qxN/i30+QoQfyiCG2zXWLSnSarRSbyfkw6WfKvOs+vJ41 eOLeYKppKWD7AbNUtsaxMOu2W9+mBgL8noJFP5dKrsnfpGj9yGK+pISkHVcSKp9jVLgm CF1q3qYZEVm4eTnhw4xVyF3TXqHabBY+U5YgipnoGg4IJFjmlXw4lHnBBJAu+FojuBvH QdPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719587256; x=1720192056; h=mime-version:message-id:date:user-agent:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=zbA4V8MZTVR414xRWikXqdLkk1/XJYFOLXJZpW0zqJ8=; b=JNbGta/Cv3WDjDXF0ZVjNM12D5ANVDqbfZNTUWS4keFs8BJIbC9KGRIto+B1kvvTar fYG6pb8Gjx2ZqOpL0Z9xAMid6oWHq/VoIyyL8gs5EBw4W2Aw2AyC03hJXDHGTw7iNXUq 0vdUSSFFCsbKPCHNeMGoNvEMc8NKUemiD6aPhnAsR0aABo3Iv2jcFH0MiF/t3YpaZYc9 ubc9JgMnp/3BJiV0yHNZaB73SHI3kEEH1d0tvdFOSRCvGIhXh851rNRifW7CuxXTn9xM ROnmbBRiqESgg5EE8WqkLH+4/hIDXizAV/evx9JXyx0LjP+pqs6jXPVIsuuq1pRpSqKH EewQ== X-Gm-Message-State: AOJu0YzewsHVnUEOiD1nrWiU2kqBJAM8jo/YioGbcFgjuG+5JaJ4GLAE VF+Y2HF1h80S0BVu11o/F8t5w2JOfn4VliU7JEUJ+k9teSfw1OZl3e0hhnrUlB0lVnjKihYzQXl dTpQ= X-Google-Smtp-Source: AGHT+IGcs+67zR/OUAtrYzN5CVUPbk87fQRyIo+vYV4f4nNvJZZIXVx9zfXbi6o9YbuEPkw67u8MSA== X-Received: by 2002:a05:600c:434b:b0:424:abd7:2321 with SMTP id 5b1f17b1804b1-424abd72412mr69403155e9.12.1719587256124; Fri, 28 Jun 2024 08:07:36 -0700 (PDT) Received: from euler.schwinge.ddns.net (p200300c8b733b9005e8fc6f38b6af531.dip0.t-ipconnect.de. [2003:c8:b733:b900:5e8f:c6f3:8b6a:f531]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256af3c272sm40430665e9.8.2024.06.28.08.07.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jun 2024 08:07:35 -0700 (PDT) From: Thomas Schwinge To: gcc-patches@gcc.gnu.org Cc: Jeff Law , Jakub Jelinek , Tom de Vries , Roger Sayle Subject: Document 'pass_postreload' vs. 'pass_late_compilation' (was: The nvptx port [4/11+] Post-RA pipeline) In-Reply-To: <54451B2B.5070209@codesourcery.com> References: <54451994.9070209@codesourcery.com> <54451B2B.5070209@codesourcery.com> User-Agent: Notmuch/0.30+8~g47a4bad (https://notmuchmail.org) Emacs/29.3 (x86_64-pc-linux-gnu) Date: Fri, 28 Jun 2024 17:07:24 +0200 Message-ID: <87a5j5t8b7.fsf@euler.schwinge.ddns.net> MIME-Version: 1.0 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Hi! Before we start looking into enabling certain 'pass_postreload' passes for nvptx, as we've been discussing in "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 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 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