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

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