From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 02016385141D for ; Thu, 19 May 2022 09:47:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 02016385141D Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 1F08821B4C; Thu, 19 May 2022 09:47:43 +0000 (UTC) Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (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 18FB52C141; Thu, 19 May 2022 09:47:43 +0000 (UTC) Date: Thu, 19 May 2022 09:47:43 +0000 (UTC) From: Richard Biener To: Jakub Jelinek cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] cfgexpand: Yet another spot with debug insns references to global vars without varpool nodes [PR105630] In-Reply-To: Message-ID: References: User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_STOCKGEN, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 May 2022 09:47:45 -0000 On Thu, 19 May 2022, Jakub Jelinek wrote: > Hi! > > This is similar to the earlier patch to avoid having MEM_EXPRs > referencing global vars without varpool nodes, but this time > the difference is that during gimplification some hashing > actually created DECL_RTLs for the n VAR_DECL and the previous > change was in the if above this when DECL_RTL is NULL and we are > considering creating it. > > The following patch drops on the floor references to vars where > we've optimized away the varpool node even when it has DECL_RTL. > > Bootstrapped/regtested on x86_64-linux and i686-linux, plus > bootstrapped on those without the cfgexpand.cc change, reapplied > it and rebuilt stage3 cc1/cc1plus, the resulting cc1/cc1plus > binaries on both targets were identical except for the 16-byte > executable_checksum (I've done the second bootstraps in the same > directory as the first one after moving the previous one elsewhere, > so pathnames were the same, just checksum hasn't been regenerated). > So, at least on those binaries this patch doesn't affect debug info > at all. > > Ok for trunk? OK. Thanks, Richard. > 2022-05-19 Jakub Jelinek > > PR debug/105630 > * cfgexpand.cc (expand_debug_expr): For VAR_DECL, punt for > global vars without symtab node even when they have DECL_RTL > set. > > * gcc.dg/pr105630.c: New test. > > --- gcc/cfgexpand.cc.jj 2022-05-09 09:09:20.005477502 +0200 > +++ gcc/cfgexpand.cc 2022-05-18 13:53:49.622983222 +0200 > @@ -4575,6 +4575,10 @@ expand_debug_expr (tree exp) > || SYMBOL_REF_DECL (XEXP (op0, 0)) != exp) > return NULL; > } > + else if (VAR_P (exp) > + && is_global_var (exp) > + && symtab_node::get (exp) == NULL) > + return NULL; > else > op0 = copy_rtx (op0); > > --- gcc/testsuite/gcc.dg/pr105630.c.jj 2022-05-18 14:02:18.426050242 +0200 > +++ gcc/testsuite/gcc.dg/pr105630.c 2022-05-18 14:02:07.103204525 +0200 > @@ -0,0 +1,22 @@ > +/* PR debug/105630 */ > +/* { dg-do compile { target pthread } } */ > +/* { dg-options "-O1 -ftree-parallelize-loops=2 -fcompare-debug" } */ > + > +int m; > +static int n; > + > +void > +foo (void) > +{ > + int *arr[] = { &n, &n, &n }; > + int unused = n; > + > + m = 0; > +} > + > +void > +bar (int *arr, int i) > +{ > + while (i < 1) > + arr[i++] = 1; > +} > > Jakub > > -- Richard Biener SUSE Software Solutions Germany GmbH, Maxfeldstrasse 5, 90409 Nuernberg, Germany; GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman; HRB 36809 (AG Nuernberg)