From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2153) id 297633858C54; Thu, 19 May 2022 09:58:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 297633858C54 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jakub Jelinek To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-631] cfgexpand: Yet another spot with debug insns references to global vars without varpool nodes [PR1056 X-Act-Checkin: gcc X-Git-Author: Jakub Jelinek X-Git-Refname: refs/heads/master X-Git-Oldrev: 3b4daa0b3c3d8eb2ac3b40ad6898f314ed4d7919 X-Git-Newrev: 213cfa8d0a9d0bb28bd973323ee2055ee6699d86 Message-Id: <20220519095842.297633858C54@sourceware.org> Date: Thu, 19 May 2022 09:58:42 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 May 2022 09:58:42 -0000 https://gcc.gnu.org/g:213cfa8d0a9d0bb28bd973323ee2055ee6699d86 commit r13-631-g213cfa8d0a9d0bb28bd973323ee2055ee6699d86 Author: Jakub Jelinek Date: Thu May 19 11:58:15 2022 +0200 cfgexpand: Yet another spot with debug insns references to global vars without varpool nodes [PR105630] 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. 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. Diff: --- gcc/cfgexpand.cc | 4 ++++ gcc/testsuite/gcc.dg/pr105630.c | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/gcc/cfgexpand.cc b/gcc/cfgexpand.cc index 49b91827e83..bb33c1b939e 100644 --- a/gcc/cfgexpand.cc +++ b/gcc/cfgexpand.cc @@ -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); diff --git a/gcc/testsuite/gcc.dg/pr105630.c b/gcc/testsuite/gcc.dg/pr105630.c new file mode 100644 index 00000000000..c39ca7dda27 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr105630.c @@ -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; +}