Message ID | 3f7bc23c-6daf-3d99-7ae7-4575a9d2659a@suse.cz |
---|---|
State | New |
Headers |
Return-Path: <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9B5B43857823 for <patchwork@sourceware.org>; Mon, 29 Nov 2021 15:16:44 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 793D6385840B for <gcc-patches@gcc.gnu.org>; Mon, 29 Nov 2021 15:16:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 793D6385840B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.cz 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-out1.suse.de (Postfix) with ESMTPS id 3C05F21709; Mon, 29 Nov 2021 15:16:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1638198987; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=adBSs7wEzjb7/pHPq4XBsAvy0PXFouIBalnCPpou7hY=; b=2HFveZRHf1dJ2aQyvkguxbfsJN+yeQKMegeWEtaF4O0KoFm34sOCs4rmZKpKJmnwzhDMqZ //Lc+5UK8GXz+RX5wyuMeBex2ezinSsE1/4DV8Oh6IVAHMLmmuhv0+2KrqX9Kza+fweZRP PzsnT7Udj88qWZMc+ANMDNuQBeS/x6M= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1638198987; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=adBSs7wEzjb7/pHPq4XBsAvy0PXFouIBalnCPpou7hY=; b=OAMbzI5l8IVUQyB9eOfc0eSpJzdK3AfQ2Y5no7zrtTOmAZ/67jHKuCoxpkknw3D//ugEXh +kSZfggcVCei8vAw== 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 2644413B2B; Mon, 29 Nov 2021 15:16:27 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id KoltB8vupGH2GgAAMHmgww (envelope-from <mliska@suse.cz>); Mon, 29 Nov 2021 15:16:27 +0000 Message-ID: <3f7bc23c-6daf-3d99-7ae7-4575a9d2659a@suse.cz> Date: Mon, 29 Nov 2021 16:16:26 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 From: =?utf-8?q?Martin_Li=C5=A1ka?= <mliska@suse.cz> Subject: [PATCH] Fix --help -Q output To: gcc-patches@gcc.gnu.org Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-11.6 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 <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> |
Series |
Fix --help -Q output
|
|
Commit Message
Martin Liška
Nov. 29, 2021, 3:16 p.m. UTC
There are cases where a default option value is -1 and auto-detection happens in e.g. target. Do not print these options. Leads to the following diff: - -fdelete-null-pointer-checks [enabled] + -fdelete-null-pointer-checks @@ -332 +332 @@ - -fleading-underscore [enabled] + -fleading-underscore @@ -393 +393 @@ - -fprefetch-loop-arrays [enabled] + -fprefetch-loop-arrays @@ -502 +502 @@ - -fstrict-volatile-bitfields [enabled] + -fstrict-volatile-bitfields @@ -533 +533 @@ - -ftree-loop-if-convert [enabled] + -ftree-loop-if-convert Patch can bootstrap on x86_64-linux-gnu and survives regression tests. Ready to be installed? Thanks, Martin PR middle-end/103438 gcc/ChangeLog: * opts-common.c (option_enabled): Return flag_var for BOOLEAN types (the can contain an unknown value -1). --- gcc/opts-common.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
Comments
On Mon, Nov 29, 2021 at 4:16 PM Martin Liška <mliska@suse.cz> wrote: > > There are cases where a default option value is -1 and > auto-detection happens in e.g. target. > > Do not print these options. Leads to the following diff: > > - -fdelete-null-pointer-checks [enabled] > + -fdelete-null-pointer-checks > @@ -332 +332 @@ > - -fleading-underscore [enabled] > + -fleading-underscore > @@ -393 +393 @@ > - -fprefetch-loop-arrays [enabled] > + -fprefetch-loop-arrays > @@ -502 +502 @@ > - -fstrict-volatile-bitfields [enabled] > + -fstrict-volatile-bitfields > @@ -533 +533 @@ > - -ftree-loop-if-convert [enabled] > + -ftree-loop-if-convert > > Patch can bootstrap on x86_64-linux-gnu and survives regression tests. > > Ready to be installed? > Thanks, > Martin > > PR middle-end/103438 > > gcc/ChangeLog: > > * opts-common.c (option_enabled): Return flag_var for BOOLEAN > types (the can contain an unknown value -1). > --- > gcc/opts-common.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/gcc/opts-common.c b/gcc/opts-common.c > index 9d1914ff2ff..c4a19b9a0b6 100644 > --- a/gcc/opts-common.c > +++ b/gcc/opts-common.c > @@ -1586,7 +1586,8 @@ option_flag_var (int opt_index, struct gcc_options *opts) > } > > /* Return 1 if option OPT_IDX is enabled in OPTS, 0 if it is disabled, > - or -1 if it isn't a simple on-off switch. */ > + or -1 if it isn't a simple on-off switch (or if the value is unknown, > + typically set later in target). */ > > int > option_enabled (int opt_idx, unsigned lang_mask, void *opts) > @@ -1608,9 +1609,9 @@ option_enabled (int opt_idx, unsigned lang_mask, void *opts) > { > case CLVC_BOOLEAN: > if (option->cl_host_wide_int) > - return *(HOST_WIDE_INT *) flag_var != 0; > + return *(HOST_WIDE_INT *) flag_var; > else > - return *(int *) flag_var != 0; > + return *(int *) flag_var; So can we assert that only 1, 0 and -1 are returned here? For example I see (random picked) /* [64] = */ { "--param=align-threshold=", "Select fraction of the maximal frequency of executions of basic block in function given basic block get alignment.", NULL, NULL, NULL, NULL, N_OPTS, N_OPTS, 23, /* .neg_idx = */ -1, CL_COMMON | CL_JOINED | CL_OPTIMIZATION | CL_PARAMS, 0, 0, 0, 0, 0, 0, 0, 0, 1 /* UInteger */, 0, 0, 0, offsetof (struct gcc_options, x_param_align_threshold), 0, CLVC_BOOLEAN, 0, 1, 65536 }, or /* [877] = */ { "-faligned-new=", "-faligned-new=<N> Use C++17 over-aligned type allocation for alignments greater than N.", NULL, NULL, NULL, NULL, N_OPTS, N_OPTS, 13, /* .neg_idx = */ -1, CL_CXX | CL_ObjCXX | CL_JOINED, 0, 0, 0, 0, 0, 0, 1 /* RejectNegative */, 0, 1 /* UInteger */, 0, 0, 0, offsetof (struct gcc_options, x_aligned_new_threshold), 0, CLVC_BOOLEAN, 0, -1, -1 }, and the "docs" say /* The switch is enabled when FLAG_VAR is nonzero. */ CLVC_BOOLEAN, so a -1 init contradicts this. I also wonder what determines the CLVC_* kind, it seems it's simply the "default" kind chosen when nothing else matches in var_set(). > > case CLVC_EQUAL: > if (option->cl_host_wide_int) > -- > 2.34.0 >
On 11/30/21 10:33, Richard Biener wrote: > and the "docs" say > > /* The switch is enabled when FLAG_VAR is nonzero. */ > CLVC_BOOLEAN, That's bogus, because real meaning of CLVC_BOOLEAN is that it holds an integer value. It can be just true/false for a simple flag, can be 0,1,2 for things like flag_lifetime_dse, or it can be an arbitrary integer value for things like params. That said, I would suggest removing that.. Thoughts about the patch? Martin
On Thu, Dec 2, 2021 at 3:07 PM Martin Liška <mliska@suse.cz> wrote: > > On 11/30/21 10:33, Richard Biener wrote: > > and the "docs" say > > > > /* The switch is enabled when FLAG_VAR is nonzero. */ > > CLVC_BOOLEAN, > > That's bogus, because real meaning of CLVC_BOOLEAN is that it holds an integer value. > It can be just true/false for a simple flag, can be 0,1,2 for things like flag_lifetime_dse, > or it can be an arbitrary integer value for things like params. > > That said, I would suggest removing that.. > > Thoughts about the patch? + return v > 0 ? (v < 0 ? -1 : 1) : 0; the ?:s look odd to me, the above is equivalent to v > 0 ? 1 : 0, no? Did you mean to make v > 0 v != 0? > Martin
On 12/2/21 15:11, Richard Biener wrote: > the ?:s look odd to me, the above is equivalent to v > 0 ? 1 : 0, no? > Did you mean to make v > 0 v != 0? Yeah, it's typo, should be 'v != 0 ? ...'. Martin
On 12/2/21 15:22, Martin Liška wrote: > On 12/2/21 15:11, Richard Biener wrote: >> the ?:s look odd to me, the above is equivalent to v > 0 ? 1 : 0, no? >> Did you mean to make v > 0 v != 0? > > Yeah, it's typo, should be 'v != 0 ? ...'. > > Martin There's a tested patch can bootstrap on x86_64-linux-gnu and survives regression tests. Ready to be installed? Thanks, Martin
On Thu, Dec 2, 2021 at 4:55 PM Martin Liška <mliska@suse.cz> wrote: > > On 12/2/21 15:22, Martin Liška wrote: > > On 12/2/21 15:11, Richard Biener wrote: > >> the ?:s look odd to me, the above is equivalent to v > 0 ? 1 : 0, no? > >> Did you mean to make v > 0 v != 0? > > > > Yeah, it's typo, should be 'v != 0 ? ...'. > > > > Martin > > There's a tested patch can bootstrap on x86_64-linux-gnu and survives regression tests. > > Ready to be installed? OK. Thanks, Richard. > Thanks, > Martin
diff --git a/gcc/opts-common.c b/gcc/opts-common.c index 9d1914ff2ff..c4a19b9a0b6 100644 --- a/gcc/opts-common.c +++ b/gcc/opts-common.c @@ -1586,7 +1586,8 @@ option_flag_var (int opt_index, struct gcc_options *opts) } /* Return 1 if option OPT_IDX is enabled in OPTS, 0 if it is disabled, - or -1 if it isn't a simple on-off switch. */ + or -1 if it isn't a simple on-off switch (or if the value is unknown, + typically set later in target). */ int option_enabled (int opt_idx, unsigned lang_mask, void *opts) @@ -1608,9 +1609,9 @@ option_enabled (int opt_idx, unsigned lang_mask, void *opts) { case CLVC_BOOLEAN: if (option->cl_host_wide_int) - return *(HOST_WIDE_INT *) flag_var != 0; + return *(HOST_WIDE_INT *) flag_var; else - return *(int *) flag_var != 0; + return *(int *) flag_var; case CLVC_EQUAL: if (option->cl_host_wide_int)