From 723afc4436e1c3753b152e0a14e6de5c52b07202 Mon Sep 17 00:00:00 2001 From: Richard Guenther Date: Thu, 10 Nov 2011 12:22:46 +0000 Subject: [PATCH] re PR middle-end/51071 (ICE in gimple_has_side_effects, at gimple.c:2513) 2011-11-10 Richard Guenther PR middle-end/51071 * gimple.c (gimple_has_side_effects): Remove checking code that doesn't belong here. * gcc.dg/torture/pr51071.c: New testcase. From-SVN: r181253 --- gcc/ChangeLog | 6 ++++ gcc/gimple.c | 42 +++----------------------- gcc/testsuite/ChangeLog | 5 +++ gcc/testsuite/gcc.dg/torture/pr51071.c | 33 ++++++++++++++++++++ 4 files changed, 48 insertions(+), 38 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr51071.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 380779b5d10..56505f75a35 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2011-11-10 Richard Guenther + + PR middle-end/51071 + * gimple.c (gimple_has_side_effects): Remove checking code + that doesn't belong here. + 2011-11-10 Ira Rosen PR tree-optimization/51058 diff --git a/gcc/gimple.c b/gcc/gimple.c index 57f15af313c..6168d33ac05 100644 --- a/gcc/gimple.c +++ b/gcc/gimple.c @@ -2457,8 +2457,6 @@ gimple_set_modified (gimple s, bool modifiedp) bool gimple_has_side_effects (const_gimple s) { - unsigned i; - if (is_gimple_debug (s)) return false; @@ -2474,47 +2472,15 @@ gimple_has_side_effects (const_gimple s) if (is_gimple_call (s)) { - unsigned nargs = gimple_call_num_args (s); - tree fn; + int flags = gimple_call_flags (s); - if (!(gimple_call_flags (s) & (ECF_CONST | ECF_PURE))) - return true; - else if (gimple_call_flags (s) & ECF_LOOPING_CONST_OR_PURE) - /* An infinite loop is considered a side effect. */ + /* An infinite loop is considered a side effect. */ + if (!(flags & (ECF_CONST | ECF_PURE)) + || (flags & ECF_LOOPING_CONST_OR_PURE)) return true; - if (gimple_call_lhs (s) - && TREE_SIDE_EFFECTS (gimple_call_lhs (s))) - { - gcc_checking_assert (gimple_has_volatile_ops (s)); - return true; - } - - fn = gimple_call_fn (s); - if (fn && TREE_SIDE_EFFECTS (fn)) - return true; - - for (i = 0; i < nargs; i++) - if (TREE_SIDE_EFFECTS (gimple_call_arg (s, i))) - { - gcc_checking_assert (gimple_has_volatile_ops (s)); - return true; - } - return false; } - else - { - for (i = 0; i < gimple_num_ops (s); i++) - { - tree op = gimple_op (s, i); - if (op && TREE_SIDE_EFFECTS (op)) - { - gcc_checking_assert (gimple_has_volatile_ops (s)); - return true; - } - } - } return false; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 833db9b117a..c36aa0612e0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-11-10 Richard Guenther + + PR middle-end/51071 + * gcc.dg/torture/pr51071.c: New testcase. + 2011-11-10 Eric Botcazou * gnat.dg/loop_optimization9.ad[sb]: New test. diff --git a/gcc/testsuite/gcc.dg/torture/pr51071.c b/gcc/testsuite/gcc.dg/torture/pr51071.c new file mode 100644 index 00000000000..99af9587d05 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr51071.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ + +void foo (void); +void bar (void *); +extern int t; + +static void kmalloc_large (int size, int flags) +{ + (void) size; + (void) flags; + foo (); + bar (({__here:&&__here;})); +} + +static void kmalloc (int size, int flags) +{ + if (size) + { + if ((unsigned long) size > 0x1000) + kmalloc_large (size, flags); + + if (flags) + bar (({__here:&&__here;})); + } +} + +void compress_file_range (int i, int j, int k) +{ + int nr_pages = ({j < k;}); + + if (i || t) + kmalloc (0x1000UL * nr_pages, 0x40UL); +} -- 2.30.2