diff options
author | Jakub Jelinek <jakub@redhat.com> | 2015-05-04 21:52:33 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2015-05-04 21:52:33 +0200 |
commit | 100c8e9e9d896bbfd6d92b8ac7ab506d0090829b (patch) | |
tree | 84db2409acab690605ecd708b51fa26e9e7a8c22 /gcc | |
parent | 2f4eb706df3bf10b82f571b0910df14317d1ff27 (diff) | |
download | gcc-100c8e9e9d896bbfd6d92b8ac7ab506d0090829b.zip gcc-100c8e9e9d896bbfd6d92b8ac7ab506d0090829b.tar.gz gcc-100c8e9e9d896bbfd6d92b8ac7ab506d0090829b.tar.bz2 |
re PR middle-end/65984 (ICE: definition in block 4 does not dominate use in block 2 with -fnon-call-exceptions -fsanitize=enum)
PR tree-optimization/65984
* ubsan.c: Include tree-cfg.h.
(instrument_bool_enum_load): Use stmt_ends_bb_p instead of
stmt_could_throw_p test, rename can_throw variable to ends_bb.
* c-c++-common/ubsan/pr65984.c: New test.
From-SVN: r222775
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/ubsan/pr65984.c | 23 | ||||
-rw-r--r-- | gcc/ubsan.c | 7 |
4 files changed, 39 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c16c1d0..4837a91 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2015-05-04 Jakub Jelinek <jakub@redhat.com> + + PR tree-optimization/65984 + * ubsan.c: Include tree-cfg.h. + (instrument_bool_enum_load): Use stmt_ends_bb_p instead of + stmt_could_throw_p test, rename can_throw variable to ends_bb. + 2015-05-04 Uros Bizjak <ubizjak@gmail.com> * config/i386/i386.c: Change GET_CODE (...) == CONST_DOUBLE check diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0658ea0c..9525115 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-05-04 Jakub Jelinek <jakub@redhat.com> + + PR tree-optimization/65984 + * c-c++-common/ubsan/pr65984.c: New test. + 2015-05-04 Jeff Law <law@redhat.com> * gcc.dg/tree-ssa/shorten-1.c: New test. diff --git a/gcc/testsuite/c-c++-common/ubsan/pr65984.c b/gcc/testsuite/c-c++-common/ubsan/pr65984.c new file mode 100644 index 0000000..94ba011 --- /dev/null +++ b/gcc/testsuite/c-c++-common/ubsan/pr65984.c @@ -0,0 +1,23 @@ +/* PR tree-optimization/65984 */ +/* { dg-do compile } */ +/* { dg-options "-fnon-call-exceptions -fsanitize=bool,enum" } */ + +#ifndef __cplusplus +#define bool _Bool +#endif + +enum E { E0, E1, E2 }; +enum E e[2]; +bool *b; + +int +foo (int i) +{ + return e[i]; +} + +int +bar (int i) +{ + return b[i]; +} diff --git a/gcc/ubsan.c b/gcc/ubsan.c index 701e9f2..96536c5 100644 --- a/gcc/ubsan.c +++ b/gcc/ubsan.c @@ -87,6 +87,7 @@ along with GCC; see the file COPYING3. If not see #include "builtins.h" #include "tree-object-size.h" #include "tree-eh.h" +#include "tree-cfg.h" /* Map from a tree to a VAR_DECL tree. */ @@ -1420,7 +1421,7 @@ instrument_bool_enum_load (gimple_stmt_iterator *gsi) || TREE_CODE (gimple_assign_lhs (stmt)) != SSA_NAME) return; - bool can_throw = stmt_could_throw_p (stmt); + bool ends_bb = stmt_ends_bb_p (stmt); location_t loc = gimple_location (stmt); tree lhs = gimple_assign_lhs (stmt); tree ptype = build_pointer_type (TREE_TYPE (rhs)); @@ -1432,7 +1433,7 @@ instrument_bool_enum_load (gimple_stmt_iterator *gsi) tree mem = build2 (MEM_REF, utype, gimple_assign_lhs (g), build_int_cst (atype, 0)); tree urhs = make_ssa_name (utype); - if (can_throw) + if (ends_bb) { gimple_assign_set_lhs (stmt, urhs); g = gimple_build_assign (lhs, NOP_EXPR, urhs); @@ -1469,7 +1470,7 @@ instrument_bool_enum_load (gimple_stmt_iterator *gsi) gimple_set_location (g, loc); gsi_insert_after (gsi, g, GSI_NEW_STMT); - if (!can_throw) + if (!ends_bb) { gimple_assign_set_rhs_with_ops (&gsi2, NOP_EXPR, urhs); update_stmt (stmt); |