public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/61289] New: Bad jump threading generates infinite loop
@ 2014-05-22 21:11 xinliangli at gmail dot com
2014-05-22 21:21 ` [Bug tree-optimization/61289] " ppluzhnikov at google dot com
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: xinliangli at gmail dot com @ 2014-05-22 21:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61289
Bug ID: 61289
Summary: Bad jump threading generates infinite loop
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: xinliangli at gmail dot com
Build the following program with -fno-exceptions -O2, the program aborts at
runtime.
Adding -fno-tree-dominator-opts, the program runs fine.
To trigger the problem, the first iteration needs to return list == new_list
--> the code will then get into the cloned path which is actually an infinite
loop.
(the toy program does something nonsense, but it should finish without
aborting).
jpthread.h
---------
struct MyList {
inline int LastHit () const { return last_; }
// inline int FirstHit () const { return last_-1; }
MyList* PushBack(int);
// MyList* PushFront(int);
void Destroy();
static MyList* Create(int);
MyList(int i): last_(i) {}
void PopBack();
int last_;
};
jpthread.cc
------------
#include "jpthread.h"
void test ()
{
MyList *list = MyList::Create(20);
for (int i = 0; i < 2; ) {
MyList* new_list = list->PushBack(
list->LastHit() + 10);
if (new_list != list) {
list->Destroy();
list = new_list;
++i;
}
}
list->Destroy();
}
int main()
{
test();
}
m.cc
-----
#include <stdlib.h>
#include <stdio.h>
#include "jpthread.h"
int cnt = 0;
MyList *prev = 0;
MyList* MyList::PushBack(int i)
{
cnt ++;
if (cnt == 1)
return prev;
if (cnt > 3) {
fprintf (stderr, "Loop not ending, aborting ..\n");
abort ();
}
prev = this;
return new MyList(i+last_);
}
MyList* MyList::Create(int i)
{
prev = new MyList(i);
return prev;
}
void MyList::Destroy() {
delete this;
}
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/61289] Bad jump threading generates infinite loop
2014-05-22 21:11 [Bug tree-optimization/61289] New: Bad jump threading generates infinite loop xinliangli at gmail dot com
@ 2014-05-22 21:21 ` ppluzhnikov at google dot com
2014-05-23 7:29 ` [Bug tree-optimization/61289] [4.9/4.10 Regression] " jakub at gcc dot gnu.org
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: ppluzhnikov at google dot com @ 2014-05-22 21:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61289
Paul Pluzhnikov <ppluzhnikov at google dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ppluzhnikov at google dot com
--- Comment #1 from Paul Pluzhnikov <ppluzhnikov at google dot com> ---
Google ref: b/15146357
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/61289] [4.9/4.10 Regression] Bad jump threading generates infinite loop
2014-05-22 21:11 [Bug tree-optimization/61289] New: Bad jump threading generates infinite loop xinliangli at gmail dot com
2014-05-22 21:21 ` [Bug tree-optimization/61289] " ppluzhnikov at google dot com
@ 2014-05-23 7:29 ` jakub at gcc dot gnu.org
2014-05-23 8:03 ` rguenth at gcc dot gnu.org
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-05-23 7:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61289
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2014-05-23
CC| |jakub at gcc dot gnu.org
Version|unknown |4.9.0
Target Milestone|--- |4.9.1
Summary|Bad jump threading |[4.9/4.10 Regression] Bad
|generates infinite loop |jump threading generates
| |infinite loop
Ever confirmed|0 |1
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
struct S
{
inline int fn1 () const { return s; }
__attribute__ ((noinline, noclone)) S *fn2 (int);
__attribute__ ((noinline, noclone)) void fn3 ();
__attribute__ ((noinline, noclone)) static S *fn4 (int);
S (int i) : s (i) {}
int s;
};
int a = 0;
S *b = 0;
S *
S::fn2 (int i)
{
a++;
if (a == 1)
return b;
if (a > 3)
__builtin_abort ();
b = this;
return new S (i + s);
}
S *
S::fn4 (int i)
{
b = new S (i);
return b;
}
void
S::fn3 ()
{
delete this;
}
void
foo ()
{
S *c = S::fn4 (20);
for (int i = 0; i < 2;)
{
S *d = c->fn2 (c->fn1 () + 10);
if (d != c)
{
c->fn3 ();
c = d;
++i;
}
}
c->fn3 ();
}
int
main ()
{
foo ();
}
Started with r205279.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/61289] [4.9/4.10 Regression] Bad jump threading generates infinite loop
2014-05-22 21:11 [Bug tree-optimization/61289] New: Bad jump threading generates infinite loop xinliangli at gmail dot com
2014-05-22 21:21 ` [Bug tree-optimization/61289] " ppluzhnikov at google dot com
2014-05-23 7:29 ` [Bug tree-optimization/61289] [4.9/4.10 Regression] " jakub at gcc dot gnu.org
@ 2014-05-23 8:03 ` rguenth at gcc dot gnu.org
2014-06-05 18:25 ` law at gcc dot gnu.org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-05-23 8:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61289
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |wrong-code
Priority|P3 |P2
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/61289] [4.9/4.10 Regression] Bad jump threading generates infinite loop
2014-05-22 21:11 [Bug tree-optimization/61289] New: Bad jump threading generates infinite loop xinliangli at gmail dot com
` (2 preceding siblings ...)
2014-05-23 8:03 ` rguenth at gcc dot gnu.org
@ 2014-06-05 18:25 ` law at gcc dot gnu.org
2014-06-10 17:43 ` [Bug tree-optimization/61289] [4.9 " ppluzhnikov at google dot com
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: law at gcc dot gnu.org @ 2014-06-05 18:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61289
--- Comment #3 from Jeffrey A. Law <law at gcc dot gnu.org> ---
Author: law
Date: Thu Jun 5 18:25:02 2014
New Revision: 211287
URL: http://gcc.gnu.org/viewcvs?rev=211287&root=gcc&view=rev
Log:
PR tree-optimization/61289
* tree-ssa-threadedge.c (invalidate_equivalences): Remove SRC_MAP and
DST_MAP parameters. Invalidate by walking all the SSA_NAME_VALUES
looking for those which match LHS. All callers changed.
(record_temporary_equivalences_from_phis): Remove SRC_MAP and DST_MAP
parameters and code which manipulated them. All callers changed.
(record_temporary_equivalences_from_stmts_at_dest): Remove SRC_MAP
and DST_MAP parameters. Simplify invalidation code by just calling
invalidate_equivalences. All callers changed.
(thread_across_edge): Simplify now that we don't need to maintain
the map of equivalences to invalidate.
PR tree-optimization/61289
* g++.dg/pr61289.C: New test.
* g++.dg/pr61289-2.C: New test.
Added:
trunk/gcc/testsuite/g++.dg/pr61289-2.c
trunk/gcc/testsuite/g++.dg/pr61289.C
Modified:
trunk/gcc/ChangeLog
trunk/gcc/testsuite/ChangeLog
trunk/gcc/tree-ssa-threadedge.c
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/61289] [4.9 Regression] Bad jump threading generates infinite loop
2014-05-22 21:11 [Bug tree-optimization/61289] New: Bad jump threading generates infinite loop xinliangli at gmail dot com
` (3 preceding siblings ...)
2014-06-05 18:25 ` law at gcc dot gnu.org
@ 2014-06-10 17:43 ` ppluzhnikov at google dot com
2014-06-10 18:03 ` law at redhat dot com
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: ppluzhnikov at google dot com @ 2014-06-10 17:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61289
--- Comment #4 from Paul Pluzhnikov <ppluzhnikov at google dot com> ---
Back-port to gcc-4_9-branch?
Thanks,
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/61289] [4.9 Regression] Bad jump threading generates infinite loop
2014-05-22 21:11 [Bug tree-optimization/61289] New: Bad jump threading generates infinite loop xinliangli at gmail dot com
` (4 preceding siblings ...)
2014-06-10 17:43 ` [Bug tree-optimization/61289] [4.9 " ppluzhnikov at google dot com
@ 2014-06-10 18:03 ` law at redhat dot com
2014-06-12 18:38 ` law at gcc dot gnu.org
2014-06-12 18:38 ` law at redhat dot com
7 siblings, 0 replies; 9+ messages in thread
From: law at redhat dot com @ 2014-06-10 18:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61289
--- Comment #5 from Jeffrey A. Law <law at redhat dot com> ---
yes, I'll backport to the 4.9 branch. Waiting to see if there's any
follow-ups.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/61289] [4.9 Regression] Bad jump threading generates infinite loop
2014-05-22 21:11 [Bug tree-optimization/61289] New: Bad jump threading generates infinite loop xinliangli at gmail dot com
` (5 preceding siblings ...)
2014-06-10 18:03 ` law at redhat dot com
@ 2014-06-12 18:38 ` law at gcc dot gnu.org
2014-06-12 18:38 ` law at redhat dot com
7 siblings, 0 replies; 9+ messages in thread
From: law at gcc dot gnu.org @ 2014-06-12 18:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61289
--- Comment #7 from Jeffrey A. Law <law at gcc dot gnu.org> ---
Author: law
Date: Thu Jun 12 18:38:20 2014
New Revision: 211588
URL: http://gcc.gnu.org/viewcvs?rev=211588&root=gcc&view=rev
Log:
Backports from mainline:
PR tree-optimization/61289
* tree-ssa-threadedge.c (invalidate_equivalences): Remove SRC_MAP and
DST_MAP parameters. Invalidate by walking all the SSA_NAME_VALUES
looking for those which match LHS. All callers changed.
(record_temporary_equivalences_from_phis): Remove SRC_MAP and DST_MAP
parameters and code which manipulated them. All callers changed.
(record_temporary_equivalences_from_stmts_at_dest): Remove SRC_MAP
and DST_MAP parameters. Simplify invalidation code by just calling
invalidate_equivalences. All callers changed.
(thread_across_edge): Simplify now that we don't need to maintain
the map of equivalences to invalidate.
PR tree-optimization/61289
* g++.dg/pr61289.C: New test.
* g++.dg/pr61289-2.C: New test.
Added:
branches/gcc-4_9-branch/gcc/testsuite/g++.dg/pr61289-2.c
branches/gcc-4_9-branch/gcc/testsuite/g++.dg/pr61289.C
Modified:
branches/gcc-4_9-branch/gcc/ChangeLog
branches/gcc-4_9-branch/gcc/testsuite/ChangeLog
branches/gcc-4_9-branch/gcc/tree-ssa-threadedge.c
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/61289] [4.9 Regression] Bad jump threading generates infinite loop
2014-05-22 21:11 [Bug tree-optimization/61289] New: Bad jump threading generates infinite loop xinliangli at gmail dot com
` (6 preceding siblings ...)
2014-06-12 18:38 ` law at gcc dot gnu.org
@ 2014-06-12 18:38 ` law at redhat dot com
7 siblings, 0 replies; 9+ messages in thread
From: law at redhat dot com @ 2014-06-12 18:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61289
Jeffrey A. Law <law at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #6 from Jeffrey A. Law <law at redhat dot com> ---
Backported to 4.9 branch as well.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2014-06-12 18:38 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-22 21:11 [Bug tree-optimization/61289] New: Bad jump threading generates infinite loop xinliangli at gmail dot com
2014-05-22 21:21 ` [Bug tree-optimization/61289] " ppluzhnikov at google dot com
2014-05-23 7:29 ` [Bug tree-optimization/61289] [4.9/4.10 Regression] " jakub at gcc dot gnu.org
2014-05-23 8:03 ` rguenth at gcc dot gnu.org
2014-06-05 18:25 ` law at gcc dot gnu.org
2014-06-10 17:43 ` [Bug tree-optimization/61289] [4.9 " ppluzhnikov at google dot com
2014-06-10 18:03 ` law at redhat dot com
2014-06-12 18:38 ` law at gcc dot gnu.org
2014-06-12 18:38 ` law at redhat dot com
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).