From: Jakub Jelinek Date: Fri, 12 Aug 2016 19:56:26 +0000 (+0200) Subject: re PR c/71512 (ICE: verify_gimple failed with UBSAN) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b0cea284970de2f81be3a0564afa10a15f7802d6;p=gcc.git re PR c/71512 (ICE: verify_gimple failed with UBSAN) PR c/71512 * ubsan.c (instrument_si_overflow): Pass true instead of false to gsi_replace. (pass_ubsan::execute): Call gimple_purge_dead_eh_edges at the end of bbs. Return TODO_cleanup_cfg if any returned true. * g++.dg/ubsan/pr71512.C: New test. * c-c++-common/ubsan/pr71512-1.c: New test. * c-c++-common/ubsan/pr71512-2.c: New test. From-SVN: r239430 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c920e7af67c..db6138d9aa7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2016-08-12 Jakub Jelinek + + PR c/71512 + * ubsan.c (instrument_si_overflow): Pass true instead of false + to gsi_replace. + (pass_ubsan::execute): Call gimple_purge_dead_eh_edges at the end + of bbs. Return TODO_cleanup_cfg if any returned true. + 2016-08-12 Michael Meissner * config/rs6000/vsx.md (vsx_concat_): Add support for the diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 34c1ab777af..6ea002dba66 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2016-08-12 Jakub Jelinek + + PR c/71512 + * g++.dg/ubsan/pr71512.C: New test. + * c-c++-common/ubsan/pr71512-1.c: New test. + * c-c++-common/ubsan/pr71512-2.c: New test. + 2016-08-12 Michael Meissner * gcc.target/powerpc/vec-init-1.c: New tests to test various diff --git a/gcc/testsuite/c-c++-common/ubsan/pr71512-1.c b/gcc/testsuite/c-c++-common/ubsan/pr71512-1.c new file mode 100644 index 00000000000..2a90ab18d51 --- /dev/null +++ b/gcc/testsuite/c-c++-common/ubsan/pr71512-1.c @@ -0,0 +1,5 @@ +/* PR c/71512 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fnon-call-exceptions -ftrapv -fexceptions -fsanitize=undefined" } */ + +#include "../../gcc.dg/pr44545.c" diff --git a/gcc/testsuite/c-c++-common/ubsan/pr71512-2.c b/gcc/testsuite/c-c++-common/ubsan/pr71512-2.c new file mode 100644 index 00000000000..1c955930be8 --- /dev/null +++ b/gcc/testsuite/c-c++-common/ubsan/pr71512-2.c @@ -0,0 +1,5 @@ +/* PR c/71512 */ +/* { dg-do compile } */ +/* { dg-options "-O -fexceptions -fnon-call-exceptions -ftrapv -fsanitize=undefined" } */ + +#include "../../gcc.dg/pr47086.c" diff --git a/gcc/testsuite/g++.dg/ubsan/pr71512.C b/gcc/testsuite/g++.dg/ubsan/pr71512.C new file mode 100644 index 00000000000..9822c989a1c --- /dev/null +++ b/gcc/testsuite/g++.dg/ubsan/pr71512.C @@ -0,0 +1,20 @@ +/* PR c/71512 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftrapv -fnon-call-exceptions -fsanitize=undefined" } */ + +bool +foo (int *x, int *y, int *z) +{ + try + { + x[0] = y[0] + z[0]; + x[1] = y[1] - z[1]; + x[2] = y[2] * z[2]; + x[3] = -y[3]; + } + catch (...) + { + return true; + } + return false; +} diff --git a/gcc/ubsan.c b/gcc/ubsan.c index 8ee57d5f1e1..a118af297f8 100644 --- a/gcc/ubsan.c +++ b/gcc/ubsan.c @@ -1292,7 +1292,7 @@ instrument_si_overflow (gimple_stmt_iterator gsi) ? IFN_UBSAN_CHECK_SUB : IFN_UBSAN_CHECK_MUL, 2, a, b); gimple_call_set_lhs (g, lhs); - gsi_replace (&gsi, g, false); + gsi_replace (&gsi, g, true); break; case NEGATE_EXPR: /* Represent i = -u; @@ -1302,7 +1302,7 @@ instrument_si_overflow (gimple_stmt_iterator gsi) b = gimple_assign_rhs1 (stmt); g = gimple_build_call_internal (IFN_UBSAN_CHECK_SUB, 2, a, b); gimple_call_set_lhs (g, lhs); - gsi_replace (&gsi, g, false); + gsi_replace (&gsi, g, true); break; case ABS_EXPR: /* Transform i = ABS_EXPR; @@ -1955,6 +1955,7 @@ pass_ubsan::execute (function *fun) { basic_block bb; gimple_stmt_iterator gsi; + unsigned int ret = 0; initialize_sanitizer_builtins (); @@ -2013,8 +2014,10 @@ pass_ubsan::execute (function *fun) gsi_next (&gsi); } + if (gimple_purge_dead_eh_edges (bb)) + ret = TODO_cleanup_cfg; } - return 0; + return ret; } } // anon namespace