public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/redhat/heads/gcc-8-branch)] objsz: Don't call replace_uses_by on SSA_NAME_OCCURS_IN_ABNORMAL_PHI [PR94423]
@ 2020-09-17 17:21 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2020-09-17 17:21 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:4cf91d649308d2130d891af451cc39b2822d41ee

commit 4cf91d649308d2130d891af451cc39b2822d41ee
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue Apr 7 21:01:06 2020 +0200

    objsz: Don't call replace_uses_by on SSA_NAME_OCCURS_IN_ABNORMAL_PHI [PR94423]
    
    The following testcase ICEs because the objsz pass calls replace_uses_by
    on SSA_NAME_OCCURS_IN_ABNORMAL_PHI SSA_NAME.  The following patch instead
    of that calls replace_call_with_value, which will turn it into
      xyz_123(ab) = 234;
    
    2020-04-01  Jakub Jelinek  <jakub@redhat.com>
    
            PR middle-end/94423
            * tree-object-size.c (pass_object_sizes::execute): Don't call
            replace_uses_by for SSA_NAME_OCCURS_IN_ABNORMAL_PHI lhs, instead
            call replace_call_with_value.
    
            * gcc.dg/ubsan/pr94423.c: New test.
    
    (cherry picked from commit 4486a537f14bc3b05ac552c3cbe18e540e397ed7)

Diff:
---
 gcc/testsuite/gcc.dg/ubsan/pr94423.c | 17 +++++++++++++++++
 gcc/tree-object-size.c               |  5 ++++-
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.dg/ubsan/pr94423.c b/gcc/testsuite/gcc.dg/ubsan/pr94423.c
new file mode 100644
index 00000000000..76f831f26e2
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ubsan/pr94423.c
@@ -0,0 +1,17 @@
+/* PR middle-end/94423 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fsanitize=object-size" } */
+
+void foo (void);
+typedef struct { long buf[22]; } jmp_buf[1];
+extern int sigsetjmp (jmp_buf, int) __attribute__ ((__nothrow__));
+jmp_buf buf;
+
+void
+bar (int *c)
+{
+  while (*c)
+    foo ();
+  while (*c)
+    sigsetjmp (buf, 0);
+}
diff --git a/gcc/tree-object-size.c b/gcc/tree-object-size.c
index f9998597c49..bfcb37653c5 100644
--- a/gcc/tree-object-size.c
+++ b/gcc/tree-object-size.c
@@ -1378,7 +1378,10 @@ pass_object_sizes::execute (function *fun)
 	    }
 
 	  /* Propagate into all uses and fold those stmts.  */
-	  replace_uses_by (lhs, result);
+	  if (!SSA_NAME_OCCURS_IN_ABNORMAL_PHI (lhs))
+	    replace_uses_by (lhs, result);
+	  else
+	    replace_call_with_value (&i, result);
 	}
     }


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

only message in thread, other threads:[~2020-09-17 17:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-17 17:21 [gcc(refs/vendors/redhat/heads/gcc-8-branch)] objsz: Don't call replace_uses_by on SSA_NAME_OCCURS_IN_ABNORMAL_PHI [PR94423] 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).