Hi,

I found ipa_remove_stmt_references incorrectly iterates over
references after reference removal. When reference is removed, the
last one takes it's place and is not checked at all. It means we do
not remove all required references in some cases.

Here is a patch to fix it. Bootstrapped and tested on linux-x86_64. OK
for trunk?

Thanks,
Ilya
--
2014-01-16  Ilya Enkovich  <ilya.enkov...@intel.com>

        * ipa-ref.c (ipa_remove_stmt_references): Fix references
        traversal when removing references.

diff --git a/gcc/ipa-ref.c b/gcc/ipa-ref.c
index b8c3d51..6aa41e6 100644
--- a/gcc/ipa-ref.c
+++ b/gcc/ipa-ref.c
@@ -291,11 +291,13 @@ void
 ipa_remove_stmt_references (symtab_node *referring_node, gimple stmt)
 {
   struct ipa_ref *r = NULL;
-  int i;
+  int i = 0;

-  for (i = 0; ipa_ref_list_reference_iterate
(&referring_node->ref_list, i, r); i++)
+  while (ipa_ref_list_reference_iterate (&referring_node->ref_list, i, r))
     if (r->stmt == stmt)
       ipa_remove_reference (r);
+    else
+      i++;
 }

 /* Remove all stmt references in non-speculative references.

Reply via email to