public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/51998] New: compiler hangs on self-recursive alias attribute
@ 2012-01-25 14:39 vries at gcc dot gnu.org
2012-01-25 14:41 ` [Bug middle-end/51998] " rguenth at gcc dot gnu.org
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: vries at gcc dot gnu.org @ 2012-01-25 14:39 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51998
Bug #: 51998
Summary: compiler hangs on self-recursive alias attribute
Classification: Unclassified
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: vries@gcc.gnu.org
inline-2.c:
...
static void f (void) __attribute__((alias("f")));
void g ()
{
f ();
}
...
hangs (with compiler build with r183325):
...
$ gcc inline-2.c -O2 -S
...
a mutually recursive version has the same problem:
...
static void f (void) __attribute__((alias("g")));
static void g (void) __attribute__((alias("f")));
void h ()
{
f ();
}
...
The compiler is stuck in this loop in cgraph_function_or_thunk_node:
...
1042 while (node)
(gdb)
1044 if (node->alias && node->analyzed)
(gdb)
1045 node = cgraph_alias_aliased_node (node);
(gdb)
1042 while (node)
...
The following tentative patch allows the compiler to abort compilation:
...
Index: cgraph.h
===================================================================
--- cgraph.h (revision 183325)
+++ cgraph.h (working copy)
@@ -27,6 +27,7 @@ along with GCC; see the file COPYING3.
#include "tree.h"
#include "basic-block.h"
#include "function.h"
+#include "diagnostic-core.h"
#include "ipa-ref.h" /* FIXME: inappropriate dependency of cgraph on IPA.
*/
enum availability
@@ -1037,12 +1038,17 @@ cgraph_function_node (struct cgraph_node
static inline struct cgraph_node *
cgraph_function_or_thunk_node (struct cgraph_node *node, enum availability
*availability)
{
+ struct cgraph_node *start = node;
if (availability)
*availability = cgraph_function_body_availability (node);
while (node)
{
if (node->alias && node->analyzed)
- node = cgraph_alias_aliased_node (node);
+ {
+ node = cgraph_alias_aliased_node (node);
+ if (start == node)
+ fatal_error ("function %q+D part of alias cycle", start->decl);
+ }
else
return node;
if (node && availability)
...
with an error message:
...
$ gcc inline-2.c inline-3.c -O2 -S
inline-2.c:1:13: fatal error: function ‘f’ part of alias cycle
compilation terminated.
inline-3.c:1:13: fatal error: function ‘f’ part of alias cycle
compilation terminated.
...
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug middle-end/51998] compiler hangs on self-recursive alias attribute
2012-01-25 14:39 [Bug middle-end/51998] New: compiler hangs on self-recursive alias attribute vries at gcc dot gnu.org
@ 2012-01-25 14:41 ` rguenth at gcc dot gnu.org
2012-01-25 15:03 ` jakub at gcc dot gnu.org
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-01-25 14:41 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51998
Richard Guenther <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2012-01-25
CC| |hubicka at gcc dot gnu.org
Ever Confirmed|0 |1
--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-01-25 14:27:09 UTC ---
Honza?
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug middle-end/51998] compiler hangs on self-recursive alias attribute
2012-01-25 14:39 [Bug middle-end/51998] New: compiler hangs on self-recursive alias attribute vries at gcc dot gnu.org
2012-01-25 14:41 ` [Bug middle-end/51998] " rguenth at gcc dot gnu.org
@ 2012-01-25 15:03 ` jakub at gcc dot gnu.org
2012-01-25 17:17 ` vries at gcc dot gnu.org
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-01-25 15:03 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51998
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-01-25 14:43:46 UTC ---
I think fatal_error is undesirable, you should error on it somewhere and just
drop the alias attribute.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug middle-end/51998] compiler hangs on self-recursive alias attribute
2012-01-25 14:39 [Bug middle-end/51998] New: compiler hangs on self-recursive alias attribute vries at gcc dot gnu.org
2012-01-25 14:41 ` [Bug middle-end/51998] " rguenth at gcc dot gnu.org
2012-01-25 15:03 ` jakub at gcc dot gnu.org
@ 2012-01-25 17:17 ` vries at gcc dot gnu.org
2012-01-25 17:32 ` jakub at gcc dot gnu.org
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: vries at gcc dot gnu.org @ 2012-01-25 17:17 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51998
--- Comment #3 from vries at gcc dot gnu.org 2012-01-25 16:33:12 UTC ---
(In reply to comment #2)
> I think fatal_error is undesirable, you should error on it somewhere and just
> drop the alias attribute.
Jakub,
like this? :
...
Index: cgraph.h
===================================================================
--- cgraph.h (revision 183325)
+++ cgraph.h (working copy)
@@ -27,6 +27,7 @@ along with GCC; see the file COPYING3.
#include "tree.h"
#include "basic-block.h"
#include "function.h"
+#include "diagnostic-core.h"
#include "ipa-ref.h" /* FIXME: inappropriate dependency of cgraph on IPA.
*/
enum availability
@@ -1037,12 +1038,21 @@ cgraph_function_node (struct cgraph_node
static inline struct cgraph_node *
cgraph_function_or_thunk_node (struct cgraph_node *node, enum availability
*availability)
{
+ struct cgraph_node *start = node;
if (availability)
*availability = cgraph_function_body_availability (node);
while (node)
{
if (node->alias && node->analyzed)
- node = cgraph_alias_aliased_node (node);
+ {
+ node = cgraph_alias_aliased_node (node);
+ if (start == node)
+ {
+ node->alias = false;
+ error ("function %q+D part of alias cycle", start->decl);
+ return node;
+ }
+ }
else
return node;
if (node && availability)
...
now normal rather than fatal errors:
...
$ gcc inline-2.c inline-3.c -O2 -S
inline-2.c:1:13: error: function ‘f’ part of alias cycle
inline-3.c:1:13: error: function ‘f’ part of alias cycle
...
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug middle-end/51998] compiler hangs on self-recursive alias attribute
2012-01-25 14:39 [Bug middle-end/51998] New: compiler hangs on self-recursive alias attribute vries at gcc dot gnu.org
` (2 preceding siblings ...)
2012-01-25 17:17 ` vries at gcc dot gnu.org
@ 2012-01-25 17:32 ` jakub at gcc dot gnu.org
2012-01-26 15:14 ` hubicka at ucw dot cz
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-01-25 17:32 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51998
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-01-25 16:38:05 UTC ---
I think remove_attribute would be desirable too. But I wonder if it can't be
detected earlier than here. In any case, I'd like to hear Honza on this.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug middle-end/51998] compiler hangs on self-recursive alias attribute
2012-01-25 14:39 [Bug middle-end/51998] New: compiler hangs on self-recursive alias attribute vries at gcc dot gnu.org
` (3 preceding siblings ...)
2012-01-25 17:32 ` jakub at gcc dot gnu.org
@ 2012-01-26 15:14 ` hubicka at ucw dot cz
2012-01-31 14:21 ` hubicka at gcc dot gnu.org
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: hubicka at ucw dot cz @ 2012-01-26 15:14 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51998
--- Comment #5 from Jan Hubicka <hubicka at ucw dot cz> 2012-01-26 14:23:21 UTC ---
> I think remove_attribute would be desirable too. But I wonder if it can't be
> detected earlier than here. In any case, I'd like to hear Honza on this.
I was under impression that varasm code on aliases should already detect
cycles.
I guess best time to detect cycle is when alias node is created, I will prepare
patch
for this.
Honza
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug middle-end/51998] compiler hangs on self-recursive alias attribute
2012-01-25 14:39 [Bug middle-end/51998] New: compiler hangs on self-recursive alias attribute vries at gcc dot gnu.org
` (4 preceding siblings ...)
2012-01-26 15:14 ` hubicka at ucw dot cz
@ 2012-01-31 14:21 ` hubicka at gcc dot gnu.org
2012-01-31 15:28 ` jakub at gcc dot gnu.org
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: hubicka at gcc dot gnu.org @ 2012-01-31 14:21 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51998
--- Comment #6 from Jan Hubicka <hubicka at gcc dot gnu.org> 2012-01-31 13:56:41 UTC ---
Created attachment 26534
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26534
Patch in testing
Hi,
I am testing the attached patch. It also plugs symmetric problem on varpool.
The cycle testing code in varasm I was mentioning is used for weakrefs only.
Porbably that checks could go, but I would preffer to wait for 4.8. There are
too many changes in 4.7 concerning aliases already.
Honza
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug middle-end/51998] compiler hangs on self-recursive alias attribute
2012-01-25 14:39 [Bug middle-end/51998] New: compiler hangs on self-recursive alias attribute vries at gcc dot gnu.org
` (5 preceding siblings ...)
2012-01-31 14:21 ` hubicka at gcc dot gnu.org
@ 2012-01-31 15:28 ` jakub at gcc dot gnu.org
2012-02-02 13:30 ` hubicka at gcc dot gnu.org
2012-02-02 13:32 ` hubicka at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-01-31 15:28 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51998
--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-01-31 14:50:56 UTC ---
I guess in varpool.c you shouldn't talk about function in the message.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug middle-end/51998] compiler hangs on self-recursive alias attribute
2012-01-25 14:39 [Bug middle-end/51998] New: compiler hangs on self-recursive alias attribute vries at gcc dot gnu.org
` (6 preceding siblings ...)
2012-01-31 15:28 ` jakub at gcc dot gnu.org
@ 2012-02-02 13:30 ` hubicka at gcc dot gnu.org
2012-02-02 13:32 ` hubicka at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: hubicka at gcc dot gnu.org @ 2012-02-02 13:30 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51998
--- Comment #8 from Jan Hubicka <hubicka at gcc dot gnu.org> 2012-02-02 13:29:34 UTC ---
Author: hubicka
Date: Thu Feb 2 13:29:31 2012
New Revision: 183836
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=183836
Log:
PR middle-end/51998
* cgraphunit.c (cgraph_analyze_function): Break cyclic aliases.
* varpool.c (varpool_analyze_pending_decls): Likewise.
* testsuite/gcc.dg/alias-12.c: New testcase.
* testsuite/gcc.dg/alias-13.c: New testcase.
Added:
trunk/gcc/testsuite/gcc.dg/alias-12.c
trunk/gcc/testsuite/gcc.dg/alias-13.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/cgraphunit.c
trunk/gcc/testsuite/ChangeLog
trunk/gcc/varpool.c
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug middle-end/51998] compiler hangs on self-recursive alias attribute
2012-01-25 14:39 [Bug middle-end/51998] New: compiler hangs on self-recursive alias attribute vries at gcc dot gnu.org
` (7 preceding siblings ...)
2012-02-02 13:30 ` hubicka at gcc dot gnu.org
@ 2012-02-02 13:32 ` hubicka at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: hubicka at gcc dot gnu.org @ 2012-02-02 13:32 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51998
Jan Hubicka <hubicka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
--- Comment #9 from Jan Hubicka <hubicka at gcc dot gnu.org> 2012-02-02 13:32:20 UTC ---
Updated the error message (thanks, Jakub) and comitted.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2012-02-02 13:32 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-25 14:39 [Bug middle-end/51998] New: compiler hangs on self-recursive alias attribute vries at gcc dot gnu.org
2012-01-25 14:41 ` [Bug middle-end/51998] " rguenth at gcc dot gnu.org
2012-01-25 15:03 ` jakub at gcc dot gnu.org
2012-01-25 17:17 ` vries at gcc dot gnu.org
2012-01-25 17:32 ` jakub at gcc dot gnu.org
2012-01-26 15:14 ` hubicka at ucw dot cz
2012-01-31 14:21 ` hubicka at gcc dot gnu.org
2012-01-31 15:28 ` jakub at gcc dot gnu.org
2012-02-02 13:30 ` hubicka at gcc dot gnu.org
2012-02-02 13:32 ` hubicka at gcc dot gnu.org
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).