From: Jakub Jelinek Date: Wed, 1 Apr 2020 07:44:59 +0000 (+0200) Subject: objsz: Don't call replace_uses_by on SSA_NAME_OCCURS_IN_ABNORMAL_PHI [PR94423] X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9ecb3ecc8cc0497a2cc815589c59547fd5af8512;p=gcc.git 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 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. --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index fc836b83e17..654356c8dc8 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2020-04-01 Jakub Jelinek + + 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. + 2020-04-01 Kewen Lin PR tree-optimization/94043 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6f41ffbb048..49a45f2854e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2020-04-01 Jakub Jelinek + + PR middle-end/94423 + * gcc.dg/ubsan/pr94423.c: New test. + 2020-04-01 Kewen Lin PR tree-optimization/94043 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 116413c2d8f..255ea63cab6 100644 --- a/gcc/tree-object-size.c +++ b/gcc/tree-object-size.c @@ -1393,7 +1393,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); } }