From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 45CBE3858409 for ; Thu, 13 Jan 2022 09:54:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 45CBE3858409 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 2914C1F3CF; Thu, 13 Jan 2022 09:54:15 +0000 (UTC) Received: from murzim.suse.de (murzim.suse.de [10.160.4.192]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 238D1A3B83; Thu, 13 Jan 2022 09:54:15 +0000 (UTC) Date: Thu, 13 Jan 2022 10:54:15 +0100 (CET) From: Richard Biener To: Jakub Jelinek cc: Jason Merrill , gcc-patches@gcc.gnu.org Subject: Re: [PATCH] inliner: Don't emit copy stmts for empty type parameters [PR103989] In-Reply-To: <20220113091052.GS2646553@tucnak> Message-ID: <8roos4n1-rpn0-pqs-pps7-o453q644qs@fhfr.qr> References: <20220113091052.GS2646553@tucnak> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, 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-List-Received-Date: Thu, 13 Jan 2022 09:54:18 -0000 On Thu, 13 Jan 2022, Jakub Jelinek wrote: > Hi! > > The following patch avoids emitting a parameter copy statement when inlining > if the parameter has empty type. E.g. the gimplifier does something similar > (except that it needs to evaluate side-effects if any, which isn't the case > here): > /* For empty types only gimplify the left hand side and right hand > side as statements and throw away the assignment. Do this after > gimplify_modify_expr_rhs so we handle TARGET_EXPRs of addressable > types properly. */ > if (is_empty_type (TREE_TYPE (*from_p)) > && !want_value > /* Don't do this for calls that return addressable types, expand_call > relies on those having a lhs. */ > && !(TREE_ADDRESSABLE (TREE_TYPE (*from_p)) > && TREE_CODE (*from_p) == CALL_EXPR)) > { > gimplify_stmt (from_p, pre_p); > gimplify_stmt (to_p, pre_p); > *expr_p = NULL_TREE; > return GS_ALL_DONE; > } > Unfortunately, this patch doesn't cure the uninit warnings in that PR, > but I think is desirable anyway. > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? Hmm, but not emitting the initialization might cause even more such warnings for the case where the passed in argument _is_ initialized (or not visible as not, like when being a function parameter itself)? Otherwise sure, it's the same what the gimplifier does. I wonder if instead uninit warning should simply ignore uses of "empty" typed variables? OK. Thanks, Richard. > 2022-01-13 Jakub Jelinek > > PR tree-optimization/103989 > * tree-inline.c (setup_one_parameter): Don't copy parms with > empty type. > > --- gcc/tree-inline.c.jj 2022-01-11 23:11:23.422275652 +0100 > +++ gcc/tree-inline.c 2022-01-12 18:37:44.119950128 +0100 > @@ -3608,7 +3608,7 @@ setup_one_parameter (copy_body_data *id, > init_stmt = gimple_build_assign (def, rhs); > } > } > - else > + else if (!is_empty_type (TREE_TYPE (var))) > init_stmt = gimple_build_assign (var, rhs); > > if (bb && init_stmt) > > Jakub > > -- Richard Biener SUSE Software Solutions Germany GmbH, Maxfeldstrasse 5, 90409 Nuernberg, Germany; GF: Ivo Totev; HRB 36809 (AG Nuernberg)