public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix ipa references removal
@ 2014-01-16 14:24 Ilya Enkovich
  2014-01-16 16:36 ` Jeff Law
  0 siblings, 1 reply; 3+ messages in thread
From: Ilya Enkovich @ 2014-01-16 14:24 UTC (permalink / raw)
  To: gcc-patches

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.enkovich@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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix ipa references removal
  2014-01-16 14:24 [PATCH] Fix ipa references removal Ilya Enkovich
@ 2014-01-16 16:36 ` Jeff Law
  2014-01-17  5:57   ` Ilya Enkovich
  0 siblings, 1 reply; 3+ messages in thread
From: Jeff Law @ 2014-01-16 16:36 UTC (permalink / raw)
  To: Ilya Enkovich, gcc-patches

On 01/16/14 07:24, Ilya Enkovich wrote:
> 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.enkovich@intel.com>
>
>          * ipa-ref.c (ipa_remove_stmt_references): Fix references
>          traversal when removing references.
OK for the trunk.

Do you have a testcase that can be added to the regression suite?

jeff

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix ipa references removal
  2014-01-16 16:36 ` Jeff Law
@ 2014-01-17  5:57   ` Ilya Enkovich
  0 siblings, 0 replies; 3+ messages in thread
From: Ilya Enkovich @ 2014-01-17  5:57 UTC (permalink / raw)
  To: Jeff Law; +Cc: gcc-patches

2014/1/16 Jeff Law <law@redhat.com>:
> On 01/16/14 07:24, Ilya Enkovich wrote:
>>
>> 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.enkovich@intel.com>
>>
>>          * ipa-ref.c (ipa_remove_stmt_references): Fix references
>>          traversal when removing references.
>
> OK for the trunk.

Committed.

>
> Do you have a testcase that can be added to the regression suite?

Unfortunately I couldn't compose a test revealing this problem on the
trunk. I found this bug during Pointer Bounds Checker testing and
regression test will be a part of checker testsuite.

Thanks,
Ilya
>
> jeff
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-01-17  5:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-16 14:24 [PATCH] Fix ipa references removal Ilya Enkovich
2014-01-16 16:36 ` Jeff Law
2014-01-17  5:57   ` Ilya Enkovich

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).