From patchwork Tue Oct 5 10:44:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 1536604 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=M0RVDkzf; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from 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 RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HNvPK4fKMz9sPB for ; Tue, 5 Oct 2021 21:45:24 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 00EE33858429 for ; Tue, 5 Oct 2021 10:45:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 00EE33858429 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1633430722; bh=eJpXQEEg1ur+MlWX+lkp05m8qBQFOtFAU2MefdfK010=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=M0RVDkzfTR3Icoh2NcIH1JrcunGdv8GVlLuAfJ3Odglk3WbikaGePvxsE5CyQ+enD vMUwt3UkZBjMgutYoan+aMD8HHXXDareUJ8+9TN4o6xphDoGBpuA1cc2rRo/RtmRtO 6VuLOOSinDz0T+Sn6MJvDptjVld8CjLuQ6Ib4xO8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 2FA56385840B for ; Tue, 5 Oct 2021 10:44:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2FA56385840B Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id E479620008 for ; Tue, 5 Oct 2021 10:44:38 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id CFEE013C2B for ; Tue, 5 Oct 2021 10:44:38 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id cMaxMZYsXGHCJwAAMHmgww (envelope-from ) for ; Tue, 05 Oct 2021 10:44:38 +0000 Date: Tue, 5 Oct 2021 12:44:38 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [PATCH] Make flow of option processing more readily visible Message-ID: <36q2n648-487r-p829-95s7-6476oo278q2p@fhfr.qr> MIME-Version: 1.0 X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Richard Biener via Gcc-patches From: Richard Biener Reply-To: Richard Biener Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" This moves calls to various option processing stages to one place, toplev::main. Bootstrap and regtest ongoing on x86_64-unknown-linux-gnu. 2021-10-05 Richard Biener * toplev.c (no_backend): Remove global var. (process_options): Pass in no_backend, move post_options langhook call to toplev::main. (do_compile): Pass in no_backend, move process_options call to toplev::main. (toplev::run_self_tests): Check no_backend at the caller. (toplev::main): Call post_options and process_options split out from do_compile, do self-tests only if no_backend is initialized. --- gcc/toplev.c | 43 +++++++++++++++++++------------------------ 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/gcc/toplev.c b/gcc/toplev.c index 52337f0152f..c5001197fb8 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -104,8 +104,6 @@ along with GCC; see the file COPYING3. If not see #endif static void general_init (const char *, bool); -static void do_compile (); -static void process_options (void); static void backend_init (void); static int lang_dependent_init (const char *); static void init_asm_output (const char *); @@ -114,9 +112,6 @@ static void finalize (bool); static void crash_signal (int) ATTRIBUTE_NORETURN; static void compile_file (void); -/* True if we don't need a backend (e.g. preprocessing only). */ -static bool no_backend; - /* Decoded options, and number of such options. */ struct cl_decoded_option *save_decoded_options; unsigned int save_decoded_options_count; @@ -1233,7 +1228,7 @@ parse_alignment_opts (void) /* Process the options that have been parsed. */ static void -process_options (void) +process_options (bool no_backend) { const char *language_string = lang_hooks.name; /* Just in case lang_hooks.post_options ends up calling a debug_hook. @@ -1242,12 +1237,6 @@ process_options (void) maximum_field_alignment = initial_max_fld_align * BITS_PER_UNIT; - /* Allow the front end to perform consistency checks and do further - initialization based on the command line options. This hook also - sets the original filename if appropriate (e.g. foo.i -> foo.c) - so we can correctly initialize debug output. */ - no_backend = lang_hooks.post_options (&main_input_filename); - /* Some machines may reject certain combinations of options. */ location_t saved_location = input_location; input_location = UNKNOWN_LOCATION; @@ -2150,10 +2139,8 @@ standard_type_bitsize (int bitsize) /* Initialize the compiler, and compile the input file. */ static void -do_compile () +do_compile (bool no_backend) { - process_options (); - /* Don't do any more if an error has already occurred. */ if (!seen_error ()) { @@ -2282,11 +2269,6 @@ toplev::start_timevars () void toplev::run_self_tests () { - if (no_backend) - { - error_at (UNKNOWN_LOCATION, "self-tests incompatible with %<-E%>"); - return; - } #if CHECKING_P /* Reset some state. */ input_location = UNKNOWN_LOCATION; @@ -2373,17 +2355,30 @@ toplev::main (int argc, char **argv) /* Exit early if we can (e.g. -help). */ if (!exit_after_options) { + /* Allow the front end to perform consistency checks and do further + initialization based on the command line options. This hook also + sets the original filename if appropriate (e.g. foo.i -> foo.c) + so we can correctly initialize debug output. */ + bool no_backend = lang_hooks.post_options (&main_input_filename); + + process_options (no_backend); + if (m_use_TV_TOTAL) start_timevars (); - do_compile (); + do_compile (no_backend); + + if (flag_self_test) + { + if (no_backend) + error_at (UNKNOWN_LOCATION, "self-tests incompatible with %<-E%>"); + else + run_self_tests (); + } } if (warningcount || errorcount || werrorcount) print_ignored_options (); - if (flag_self_test) - run_self_tests (); - /* Invoke registered plugin callbacks if any. Some plugins could emit some diagnostics here. */ invoke_plugin_callbacks (PLUGIN_FINISH, NULL);