* [PATCH] Fix VTA ICE after fixup_noreturn_call (PR debug/48768)
@ 2011-04-26 13:59 Jakub Jelinek
2011-04-26 15:15 ` Richard Guenther
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2011-04-26 13:59 UTC (permalink / raw)
To: gcc-patches
Hi!
fixup_noreturn_call when removing LHS of a noreturn call does:
/* We need to remove SSA name to avoid checking errors.
All uses are dominated by the noreturn and thus will
be removed afterwards.
We proactively remove affected non-PHI statements to avoid
fixup_cfg from trying to update them and crashing. */
if (TREE_CODE (op) == SSA_NAME)
{
use_operand_p use_p;
imm_use_iterator iter;
gimple use_stmt;
bitmap_iterator bi;
unsigned int bb_index;
bitmap blocks = BITMAP_ALLOC (NULL);
FOR_EACH_IMM_USE_STMT (use_stmt, iter, op)
{
if (gimple_code (use_stmt) != GIMPLE_PHI)
bitmap_set_bit (blocks, gimple_bb (use_stmt)->index);
else
FOR_EACH_IMM_USE_ON_STMT (use_p, iter)
SET_USE (use_p, error_mark_node);
}
which is fine because all the uses will be cleaned up RSN afterwards.
Unfortunately, during the cleanup VTA triggers and tries to add DEBUG exprs,
if there is a degenerate PHI which contains just error_mark_node set above
unfortunately that results in DEBUG something => <<< error >>>, which isn't
valid.
Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
ok for trunk/4.6?
2011-04-26 Jakub Jelinek <jakub@redhat.com>
PR debug/48768
* tree-ssa.c (insert_debug_temp_for_var_def): If degenerate_phi_result
is error_mark_node, set value to NULL.
* gcc.dg/pr48768.c: New test.
--- gcc/tree-ssa.c.jj 2011-04-13 10:54:49.000000000 +0200
+++ gcc/tree-ssa.c 2011-04-26 10:56:28.000000000 +0200
@@ -352,6 +352,10 @@ insert_debug_temp_for_var_def (gimple_st
value = degenerate_phi_result (def_stmt);
if (value && walk_tree (&value, find_released_ssa_name, NULL, NULL))
value = NULL;
+ /* error_mark_node is what fixup_noreturn_call changes PHI arguments
+ to. */
+ else if (value == error_mark_node)
+ value = NULL;
}
else if (is_gimple_assign (def_stmt))
{
--- gcc/testsuite/gcc.dg/pr48768.c.jj 2011-04-26 10:58:17.000000000 +0200
+++ gcc/testsuite/gcc.dg/pr48768.c 2011-04-26 10:57:30.000000000 +0200
@@ -0,0 +1,38 @@
+/* PR debug/48768 */
+/* { dg-do compile } */
+/* { dg-options "-O -fcompare-debug" } */
+
+int a, b;
+
+int
+bar (void)
+{
+ int i, j = 1;
+ for (i = 0; i != 10; i++)
+ {
+ lab:
+ if (i)
+ {
+ int *k = &j;
+ }
+ else if (j)
+ goto lab;
+ }
+ return 1;
+}
+
+inline int
+foo (int x)
+{
+ unsigned int c = x;
+ int d = x;
+ if (bar ())
+ for (; c; c++)
+ while (x >= 0)
+ if (foo (d) >= 0)
+ {
+ d = bar ();
+ a = b ? b : 1;
+ }
+ return 0;
+}
Jakub
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Fix VTA ICE after fixup_noreturn_call (PR debug/48768)
2011-04-26 13:59 [PATCH] Fix VTA ICE after fixup_noreturn_call (PR debug/48768) Jakub Jelinek
@ 2011-04-26 15:15 ` Richard Guenther
0 siblings, 0 replies; 2+ messages in thread
From: Richard Guenther @ 2011-04-26 15:15 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches
On Tue, Apr 26, 2011 at 3:08 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> fixup_noreturn_call when removing LHS of a noreturn call does:
> /* We need to remove SSA name to avoid checking errors.
> All uses are dominated by the noreturn and thus will
> be removed afterwards.
> We proactively remove affected non-PHI statements to avoid
> fixup_cfg from trying to update them and crashing. */
> if (TREE_CODE (op) == SSA_NAME)
> {
> use_operand_p use_p;
> imm_use_iterator iter;
> gimple use_stmt;
> bitmap_iterator bi;
> unsigned int bb_index;
>
> bitmap blocks = BITMAP_ALLOC (NULL);
>
> FOR_EACH_IMM_USE_STMT (use_stmt, iter, op)
> {
> if (gimple_code (use_stmt) != GIMPLE_PHI)
> bitmap_set_bit (blocks, gimple_bb (use_stmt)->index);
> else
> FOR_EACH_IMM_USE_ON_STMT (use_p, iter)
> SET_USE (use_p, error_mark_node);
> }
> which is fine because all the uses will be cleaned up RSN afterwards.
> Unfortunately, during the cleanup VTA triggers and tries to add DEBUG exprs,
> if there is a degenerate PHI which contains just error_mark_node set above
> unfortunately that results in DEBUG something => <<< error >>>, which isn't
> valid.
>
> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
> ok for trunk/4.6?
Ok.
Thanks,
Richard.
> 2011-04-26 Jakub Jelinek <jakub@redhat.com>
>
> PR debug/48768
> * tree-ssa.c (insert_debug_temp_for_var_def): If degenerate_phi_result
> is error_mark_node, set value to NULL.
>
> * gcc.dg/pr48768.c: New test.
>
> --- gcc/tree-ssa.c.jj 2011-04-13 10:54:49.000000000 +0200
> +++ gcc/tree-ssa.c 2011-04-26 10:56:28.000000000 +0200
> @@ -352,6 +352,10 @@ insert_debug_temp_for_var_def (gimple_st
> value = degenerate_phi_result (def_stmt);
> if (value && walk_tree (&value, find_released_ssa_name, NULL, NULL))
> value = NULL;
> + /* error_mark_node is what fixup_noreturn_call changes PHI arguments
> + to. */
> + else if (value == error_mark_node)
> + value = NULL;
> }
> else if (is_gimple_assign (def_stmt))
> {
> --- gcc/testsuite/gcc.dg/pr48768.c.jj 2011-04-26 10:58:17.000000000 +0200
> +++ gcc/testsuite/gcc.dg/pr48768.c 2011-04-26 10:57:30.000000000 +0200
> @@ -0,0 +1,38 @@
> +/* PR debug/48768 */
> +/* { dg-do compile } */
> +/* { dg-options "-O -fcompare-debug" } */
> +
> +int a, b;
> +
> +int
> +bar (void)
> +{
> + int i, j = 1;
> + for (i = 0; i != 10; i++)
> + {
> + lab:
> + if (i)
> + {
> + int *k = &j;
> + }
> + else if (j)
> + goto lab;
> + }
> + return 1;
> +}
> +
> +inline int
> +foo (int x)
> +{
> + unsigned int c = x;
> + int d = x;
> + if (bar ())
> + for (; c; c++)
> + while (x >= 0)
> + if (foo (d) >= 0)
> + {
> + d = bar ();
> + a = b ? b : 1;
> + }
> + return 0;
> +}
>
> Jakub
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-04-26 13:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-26 13:59 [PATCH] Fix VTA ICE after fixup_noreturn_call (PR debug/48768) Jakub Jelinek
2011-04-26 15:15 ` Richard Guenther
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).