public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Martin Jambor <jamborm@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-5003] ipa: Unshare expresseions before putting them into debug statements (PR 103099, PR 103107)
Date: Mon,  8 Nov 2021 16:54:44 +0000 (GMT)	[thread overview]
Message-ID: <20211108165444.6F9443858D3C@sourceware.org> (raw)

https://gcc.gnu.org/g:239d82d4c05b30632fd09ba4056de7dac5aee070

commit r12-5003-g239d82d4c05b30632fd09ba4056de7dac5aee070
Author: Martin Jambor <mjambor@suse.cz>
Date:   Mon Nov 8 17:49:54 2021 +0100

    ipa: Unshare expresseions before putting them into debug statements (PR 103099, PR 103107)
    
    My recent patch to improve debug experience when there are removed
    parameters (by ipa-sra or ipa-split) was not careful to unshare the
    expressions that were then put into debug statements, which manifests
    itself as PR 103099.  This patch adds unsharing them using
    unshare_expr_without_location which is a bit more careful with stripping
    locations than what we were doing manually and so also fixes PR 103107.
    
    gcc/ChangeLog:
    
    2021-11-08  Martin Jambor  <mjambor@suse.cz>
    
            PR ipa/103099
            PR ipa/103107
            * tree-inline.c (remap_gimple_stmt): Unshare the expression without
            location before invoking remap_with_debug_expressions on it.
            * ipa-param-manipulation.c
            (ipa_param_body_adjustments::prepare_debug_expressions): Likewise.
    
    gcc/testsuite/ChangeLog:
    
    2021-11-08  Martin Jambor  <mjambor@suse.cz>
    
            PR ipa/103099
            PR ipa/103107
            * g++.dg/ipa/pr103099.C: New test.
            * gcc.dg/ipa/pr103107.c: Likewise.

Diff:
---
 gcc/ipa-param-manipulation.c        |  4 ++--
 gcc/testsuite/g++.dg/ipa/pr103099.C | 25 +++++++++++++++++++++++++
 gcc/testsuite/gcc.dg/ipa/pr103107.c | 17 +++++++++++++++++
 gcc/tree-inline.c                   |  5 ++++-
 4 files changed, 48 insertions(+), 3 deletions(-)

diff --git a/gcc/ipa-param-manipulation.c b/gcc/ipa-param-manipulation.c
index c84d669521c..44f3bed2640 100644
--- a/gcc/ipa-param-manipulation.c
+++ b/gcc/ipa-param-manipulation.c
@@ -1185,8 +1185,8 @@ ipa_param_body_adjustments::prepare_debug_expressions (tree dead_ssa)
 	  return (*d != NULL_TREE);
 	}
 
-      tree val = gimple_assign_rhs_to_tree (def);
-      SET_EXPR_LOCATION (val, UNKNOWN_LOCATION);
+      tree val
+	= unshare_expr_without_location (gimple_assign_rhs_to_tree (def));
       remap_with_debug_expressions (&val);
 
       tree vexpr = make_node (DEBUG_EXPR_DECL);
diff --git a/gcc/testsuite/g++.dg/ipa/pr103099.C b/gcc/testsuite/g++.dg/ipa/pr103099.C
new file mode 100644
index 00000000000..5fb137d6799
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ipa/pr103099.C
@@ -0,0 +1,25 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -g" } */
+
+void pthread_mutex_unlock(int *);
+int __gthread_mutex_unlock___mutex, unlock___trans_tmp_1;
+struct Object {
+  void _change_notify() {}
+  bool _is_queued_for_deletion;
+};
+struct ClassDB {
+  template <class N, class M> static int bind_method(N, M);
+};
+struct CanvasItemMaterial : Object {
+  bool particles_animation;
+  void set_particles_animation(bool);
+};
+void CanvasItemMaterial::set_particles_animation(bool p_particles_anim) {
+  particles_animation = p_particles_anim;
+  if (unlock___trans_tmp_1)
+    pthread_mutex_unlock(&__gthread_mutex_unlock___mutex);
+  _change_notify();
+}
+void CanvasItemMaterial_bind_methods() {
+  ClassDB::bind_method("", &CanvasItemMaterial::set_particles_animation);
+}
diff --git a/gcc/testsuite/gcc.dg/ipa/pr103107.c b/gcc/testsuite/gcc.dg/ipa/pr103107.c
new file mode 100644
index 00000000000..3ea3fc55947
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/pr103107.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-options "-Og -g -fipa-sra -fno-tree-dce" } */
+
+typedef int __attribute__((__vector_size__ (8))) V;
+V v;
+
+static void
+bar (int i)
+{
+  V l = v + i;
+}
+
+void
+foo (void)
+{
+  bar (0);
+}
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index d78e4392b69..53d664ec2e4 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -1825,7 +1825,10 @@ remap_gimple_stmt (gimple *stmt, copy_body_data *id)
 	  tree value = gimple_debug_bind_get_value (stmt);
 	  if (id->param_body_adjs
 	      && id->param_body_adjs->m_dead_stmts.contains (stmt))
-	    id->param_body_adjs->remap_with_debug_expressions (&value);
+	    {
+	      value = unshare_expr_without_location (value);
+	      id->param_body_adjs->remap_with_debug_expressions (&value);
+	    }
 
 	  gdebug *copy = gimple_build_debug_bind (var, value, stmt);
 	  if (id->reset_location)


                 reply	other threads:[~2021-11-08 16:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211108165444.6F9443858D3C@sourceware.org \
    --to=jamborm@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).