re PR middle-end/20622 (Alias to nocommon variable fails to assemble on ppc64)
authorJakub Jelinek <jakub@redhat.com>
Tue, 29 Mar 2005 15:37:29 +0000 (17:37 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 29 Mar 2005 15:37:29 +0000 (17:37 +0200)
PR middle-end/20622
* cgraph.h (struct cgraph_varpool_node): Add alias field.
* cgraph.c (cgraph_varpool_assemble_pending_decls): Don't call
assemble_variable on aliases.
* varasm.c (assemble_alias): Set node->alias.
* toplev.c (wrapup_global_declarations): Don't call
rest_of_decl_compilation on aliases again.

* gcc.dg/alias-7.c: New test.

From-SVN: r97161

gcc/ChangeLog
gcc/cgraph.c
gcc/cgraph.h
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/alias-7.c [new file with mode: 0644]
gcc/toplev.c
gcc/varasm.c

index a4bb18168de2f450d5b4e27f135802d09d84c88d..9922f7e64741f3806a18173435aac3b31f88ab8a 100644 (file)
@@ -1,3 +1,13 @@
+2005-03-29  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/20622
+       * cgraph.h (struct cgraph_varpool_node): Add alias field.
+       * cgraph.c (cgraph_varpool_assemble_pending_decls): Don't call
+       assemble_variable on aliases.
+       * varasm.c (assemble_alias): Set node->alias.
+       * toplev.c (wrapup_global_declarations): Don't call
+       rest_of_decl_compilation on aliases again.
+
 2005-03-29  Paul Brook  <paul@codesourcery.com>
 
        * config/arm/arm-protos.h (arm_dbx_register_number): Add prototype.
index 3aabc4071fb95e777d754a58c3bf0e560eb51032..b769f841085bfc1c8c4f832afd23548e10a30f13 100644 (file)
@@ -724,11 +724,11 @@ cgraph_varpool_assemble_pending_decls (void)
 
   while (cgraph_varpool_nodes_queue)
     {
-      tree decl = cgraph_varpool_nodes_queue->decl;
       struct cgraph_varpool_node *node = cgraph_varpool_nodes_queue;
+      tree decl = node->decl;
 
       cgraph_varpool_nodes_queue = cgraph_varpool_nodes_queue->next_needed;
-      if (!TREE_ASM_WRITTEN (decl))
+      if (!TREE_ASM_WRITTEN (decl) && !node->alias)
        {
          assemble_variable (decl, 0, 1, 0);
          changed = true;
index 2a1c1b3b949451a9118c59ac13080ad691e18c89..46f9f0a660dbbe45e411de890abdc970eed89aff 100644 (file)
@@ -153,6 +153,8 @@ struct cgraph_varpool_node GTY(())
   bool finalized;
   /* Set when function is scheduled to be assembled.  */
   bool output;
+  /* Set for aliases once they got through assemble_alias.  */
+  bool alias;
 };
 
 extern GTY(()) struct cgraph_node *cgraph_nodes;
index 6ba4ac90b8dba0a18815283030c3b6e68d0f5c50..2cc2451ee8da40edfa49d035700e722bb96010ef 100644 (file)
@@ -1,3 +1,8 @@
+2005-03-29  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/20622
+       * gcc.dg/alias-7.c: New test.
+
 2005-03-29  Eric Botcazou  <ebotcazou@libertysurf.fr>
 
        * gcc.dg/sparc-reg-1.c: New test.
diff --git a/gcc/testsuite/gcc.dg/alias-7.c b/gcc/testsuite/gcc.dg/alias-7.c
new file mode 100644 (file)
index 0000000..6974970
--- /dev/null
@@ -0,0 +1,16 @@
+/* { dg-do run } */
+/* { dg-require-alias "" } */
+/* { dg-options "-O2" } */
+
+extern void abort (void);
+
+int foo __asm__ ("foo") __attribute__((nocommon));
+extern __typeof (foo) bar __attribute__ ((weak, alias ("foo")));
+
+int
+main (void)
+{
+  if (&foo != &bar || foo || bar)
+    abort ();
+  return bar;
+}
index 7c8723ca5e3fd3a75367dbcf4cb8fde2035877a6..5895d37a0bc7de4a22594c1d954a7741c74b576e 100644 (file)
@@ -783,6 +783,8 @@ wrapup_global_declarations (tree *vec, int len)
 
              if (flag_unit_at_a_time && node->finalized)
                needed = 0;
+             else if (node->alias)
+               needed = 0;
              else if ((flag_unit_at_a_time && !cgraph_global_info_ready)
                       && (TREE_USED (decl)
                           || TREE_USED (DECL_ASSEMBLER_NAME (decl))))
index 751c8bce959f6606c6b0c9cce72e056457908a29..c51f6c045d6c78fde6c650971437ff0a9a456dac 100644 (file)
@@ -4518,7 +4518,7 @@ assemble_alias (tree decl, tree target)
   if (TREE_CODE (decl) == FUNCTION_DECL)
     cgraph_node (decl);
   else
-    cgraph_varpool_node (decl);
+    cgraph_varpool_node (decl)->alias = true;
 
   /* If the target has already been emitted, we don't have to queue the
      alias.  This saves a tad o memory.  */