* [PATCH] Fix ubsan non-call-exceptions ICE (PR tree-optimization/65984)
@ 2015-05-04 18:16 Jakub Jelinek
2015-05-04 19:43 ` Jeff Law
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2015-05-04 18:16 UTC (permalink / raw)
To: Richard Biener; +Cc: gcc-patches
Hi!
The code I've added in r217755 was assuming that stmt_could_throw_p
memory read will always end a bb, but that is clearly not the case.
Thus, the following patch uses stmt_ends_bb_p instead.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk/5?
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.
* c-c++-common/ubsan/pr65984.c: New test.
--- gcc/ubsan.c.jj 2015-04-09 21:49:59.000000000 +0200
+++ gcc/ubsan.c 2015-05-04 17:17:34.273661884 +0200
@@ -87,6 +87,7 @@ along with GCC; see the file COPYING3.
#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_i
|| 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_i
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_i
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);
--- gcc/testsuite/c-c++-common/ubsan/pr65984.c.jj 2015-05-04 14:16:59.655378975 +0200
+++ gcc/testsuite/c-c++-common/ubsan/pr65984.c 2015-05-04 17:19:55.875447821 +0200
@@ -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];
+}
Jakub
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Fix ubsan non-call-exceptions ICE (PR tree-optimization/65984)
2015-05-04 18:16 [PATCH] Fix ubsan non-call-exceptions ICE (PR tree-optimization/65984) Jakub Jelinek
@ 2015-05-04 19:43 ` Jeff Law
0 siblings, 0 replies; 2+ messages in thread
From: Jeff Law @ 2015-05-04 19:43 UTC (permalink / raw)
To: Jakub Jelinek, Richard Biener; +Cc: gcc-patches
On 05/04/2015 12:16 PM, Jakub Jelinek wrote:
> Hi!
>
> The code I've added in r217755 was assuming that stmt_could_throw_p
> memory read will always end a bb, but that is clearly not the case.
> Thus, the following patch uses stmt_ends_bb_p instead.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk/5?
>
> 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.
>
> * c-c++-common/ubsan/pr65984.c: New test.
OK.
Jeff
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-05-04 19:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-04 18:16 [PATCH] Fix ubsan non-call-exceptions ICE (PR tree-optimization/65984) Jakub Jelinek
2015-05-04 19:43 ` Jeff Law
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).