public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-68] expand: Throw away non-external decls without varpool nodes [PR105415]
@ 2022-05-02  9:33 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2022-05-02  9:33 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:02f03c5c826d0cb7c32398af0c4282921e6e072a

commit r13-68-g02f03c5c826d0cb7c32398af0c4282921e6e072a
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Mon May 2 11:30:58 2022 +0200

    expand: Throw away non-external decls without varpool nodes [PR105415]
    
    The following testcase fails -fcompare-debug on aarch64-linux.  The problem
    is that for the n variable we create a varpool node, then remove it again
    because the var isn't really used, but it keeps being referenced in debug
    stmts/insns with -g.  Later during sched1 pass we ask whether the n var
    can be modified through some store to an anchored variable and with -g
    we create a new varpool node for it again just so that we can find its
    ultimate alias target.  Even later on we create some cgraph node for the
    loop parallelization, but as there has been an extra varpool node creation
    in between, we get higher node->order with -g than without.
    
    The patch fixes that by throwing variables without varpool nodes away
    during expansion time, they are very unlikely to actually end up with
    useful debug info anyway.
    
    I've bootstrapped/regtested the following on x86_64-linux and i686-linux,
    then bootstrapped with the patch reverted, reapplied the patch and did make
    cc1plus in stage3.  The debug section sizes are identical, .debug_info and
    .debug_loc is identical too, so I think we don't lose any debug info through
    it.
    So at least on cc1plus it makes no difference.
    
    2022-05-02  Jakub Jelinek  <jakub@redhat.com>
    
            PR debug/105415
            * cfgexpand.cc (expand_debug_expr): Don't make_decl_rtl_for_debug
            if there is no symtab node for the VAR_DECL.
    
            * gcc.dg/pr105415.c: New test.

Diff:
---
 gcc/cfgexpand.cc                |  3 ++-
 gcc/testsuite/gcc.dg/pr105415.c | 26 ++++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/gcc/cfgexpand.cc b/gcc/cfgexpand.cc
index d3cc77d2ca9..49b91827e83 100644
--- a/gcc/cfgexpand.cc
+++ b/gcc/cfgexpand.cc
@@ -4565,7 +4565,8 @@ expand_debug_expr (tree exp)
 	      || !DECL_NAME (exp)
 	      || DECL_HARD_REGISTER (exp)
 	      || DECL_IN_CONSTANT_POOL (exp)
-	      || mode == VOIDmode)
+	      || mode == VOIDmode
+	      || symtab_node::get (exp) == NULL)
 	    return NULL;
 
 	  op0 = make_decl_rtl_for_debug (exp);
diff --git a/gcc/testsuite/gcc.dg/pr105415.c b/gcc/testsuite/gcc.dg/pr105415.c
new file mode 100644
index 00000000000..4603c0cb6e1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr105415.c
@@ -0,0 +1,26 @@
+/* PR debug/105415 */
+/* { dg-do compile } */
+/* { dg-require-effective-target pthread } */
+/* { dg-options "-O2 -ftree-parallelize-loops=2 -fcompare-debug" } */
+
+int m;
+static int n;
+
+void
+foo (void)
+{
+  int s = 0;
+
+  while (m < 1)
+    {
+      s += n;
+      ++m;
+    }
+}
+
+void
+bar (int *arr, int i)
+{
+  while (i < 1)
+    arr[i++] = 1;
+}


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-05-02  9:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-02  9:33 [gcc r13-68] expand: Throw away non-external decls without varpool nodes [PR105415] Jakub Jelinek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).