]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
* c-family/c-common.c (handle_alias_ifunc_attribute): Do not set
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 11 Jun 2013 22:41:54 +0000 (22:41 +0000)
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 11 Jun 2013 22:41:54 +0000 (22:41 +0000)
DECL_EXTERNAL for weakref variables.
* c-family/c-pragma.c (handle_pragma_weak): Make sure aliases
are not declared as external.
* cgraph.c (cgraph_create_function_alias): Set weakref flag.
* cgraph.h (symtab_node_base): Add weakref flag.
* cgraphunit.c (cgraph_reset_node): Clear weakref flag.
(handle_alias_pairs): Set weakref flag, do not set DECL_EXTERNAL.
(output_weakrefs): Use weakref flag.
* fold-const.c (simple_operand_p): Handle WEAK.
* gimple-fold.c (can_refer_decl_in_current_unit_p): Drop weakref.
* ipa.c (varpool_externally_visible_p): Drop weakref.
(function_and_variable_visibility): Update comment; fix weakref
sanity checks; do not clear DECL_WEAK on them.
* lto-cgraph.c (lto_output_node): update.
(lto_output_varpool_node): Update.
(input_overwrite_node): Update.
(input_node): Update.
(input_varpool_node): Update.
* lto-symtab.c (lto_symtab_symbol_p): Do not special case weakrefs.
(lto_symtab_merge_symbols): Add sanity check.
(lto_symtab_prevailing_decl): Do not special case weakrefs.
* passes.c (rest_of_decl_compilation): Set static flag, too.
* symtab.c (dump_symtab_base): Dump weakref.
(verify_symtab_base): Sanity check weakrefs.
(symtab_make_decl_local): Remove duplicated code.
(symtab_alias_ultimate_target): Simplify.
* varpool.c (varpool_create_variable_alias): Set weakref flag.

* lto-partition.c (get_symbol_class): Simplify weakref handling.
(add_symbol_to_partition_1): Likewise.
(contained_in_symbol): Likewise.
(lto_balanced_map): Likewise.
(rename_statics): Drop weakref.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@199971 138bc75d-0d04-0410-961f-82ee72b054a4

18 files changed:
gcc/ChangeLog
gcc/c-family/ChangeLog
gcc/c-family/c-common.c
gcc/c-family/c-pragma.c
gcc/cgraph.c
gcc/cgraph.h
gcc/cgraphunit.c
gcc/configure
gcc/fold-const.c
gcc/gimple-fold.c
gcc/ipa.c
gcc/lto-cgraph.c
gcc/lto-symtab.c
gcc/lto/ChangeLog
gcc/lto/lto-partition.c
gcc/passes.c
gcc/symtab.c
gcc/varpool.c

index baab301427b81d5eb9c865e11839dd7e53855f9a..486b77ff4a31539c92e6b21d5ffef9e926161a7f 100644 (file)
@@ -1,3 +1,30 @@
+2013-06-11  Jan Hubicka  <jh@suse.cz>
+
+       * cgraph.c (cgraph_create_function_alias): Set weakref flag.
+       * cgraph.h (symtab_node_base): Add weakref flag.
+       * cgraphunit.c (cgraph_reset_node): Clear weakref flag.
+       (handle_alias_pairs): Set weakref flag, do not set DECL_EXTERNAL.
+       (output_weakrefs): Use weakref flag.
+       * fold-const.c (simple_operand_p): Handle WEAK.
+       * gimple-fold.c (can_refer_decl_in_current_unit_p): Drop weakref.
+       * ipa.c (varpool_externally_visible_p): Drop weakref.
+       (function_and_variable_visibility): Update comment; fix weakref
+       sanity checks; do not clear DECL_WEAK on them.
+       * lto-cgraph.c (lto_output_node): update.
+       (lto_output_varpool_node): Update.
+       (input_overwrite_node): Update.
+       (input_node): Update.
+       (input_varpool_node): Update.
+       * lto-symtab.c (lto_symtab_symbol_p): Do not special case weakrefs.
+       (lto_symtab_merge_symbols): Add sanity check.
+       (lto_symtab_prevailing_decl): Do not special case weakrefs.
+       * passes.c (rest_of_decl_compilation): Set static flag, too.
+       * symtab.c (dump_symtab_base): Dump weakref.
+       (verify_symtab_base): Sanity check weakrefs.
+       (symtab_make_decl_local): Remove duplicated code.
+       (symtab_alias_ultimate_target): Simplify.
+       * varpool.c (varpool_create_variable_alias): Set weakref flag.
+       
 2013-06-11  DJ Delorie  <dj@redhat.com>
 
        * config/rl78/rl78.c (TARGET_UNWIND_WORD_MODE): Define.
index aaa1b76f19ba8ec89e59f92c645bf6aec9baff4d..3d8f68f7d310b669eda7b8bc211916e0ebecade7 100644 (file)
@@ -1,3 +1,10 @@
+2013-06-11  Jan Hubicka  <jh@suse.cz>
+
+       * c-common.c (handle_alias_ifunc_attribute): Do not set
+       DECL_EXTERNAL for weakref variables.
+       * c-pragma.c (handle_pragma_weak): Make sure aliases
+       are not declared as external.
+
 2013-06-07  Balaji V. Iyer  <balaji.v.iyer@intel.com>
 
        * array-notation-common.c (length_mismatch_in_expr_p): Moved this
index dec887fb4c0457db1d9c3a62262d72db285281a4..7cb87345a808329fce6db220700e4508130ade00 100644 (file)
@@ -7576,13 +7576,7 @@ handle_alias_ifunc_attribute (bool is_alias, tree *node, tree name, tree args,
       if (TREE_CODE (decl) == FUNCTION_DECL)
        DECL_INITIAL (decl) = error_mark_node;
       else
-       {
-         if (lookup_attribute ("weakref", DECL_ATTRIBUTES (decl)))
-           DECL_EXTERNAL (decl) = 1;
-         else
-           DECL_EXTERNAL (decl) = 0;
-         TREE_STATIC (decl) = 1;
-       }
+       TREE_STATIC (decl) = 1;
 
       if (!is_alias)
        /* ifuncs are also aliases, so set that attribute too. */
index d63cbd209e122f491a065c2b2042af59e2632ed5..309859fc8ec4cee702a5e0e93ef975a342c90854 100644 (file)
@@ -367,7 +367,12 @@ handle_pragma_weak (cpp_reader * ARG_UNUSED (dummy))
     {
       apply_pragma_weak (decl, value);
       if (value)
-       assemble_alias (decl, value);
+       {
+         DECL_EXTERNAL (decl) = 0;
+         if (TREE_CODE (decl) == VAR_DECL)
+           TREE_STATIC (decl) = 1;
+         assemble_alias (decl, value);
+       }
     }
   else
     {
index 7bcff2033796373aef239c37cdb2d761d18c0adb..9ebe905c27bf48b8299e62728afe5095994a1805 100644 (file)
@@ -568,6 +568,8 @@ cgraph_create_function_alias (tree alias, tree target)
   alias_node->symbol.alias_target = target;
   alias_node->symbol.definition = true;
   alias_node->symbol.alias = true;
+  if (lookup_attribute ("weakref", DECL_ATTRIBUTES (alias)) != NULL)
+    alias_node->symbol.weakref = true;
   return alias_node;
 }
 
index dda4402e07715fad5b9fbaa63f3200e0b3a0d6d4..c67506d42f5eb75186b88ce06370b28fc9b3b888 100644 (file)
@@ -56,6 +56,8 @@ struct GTY(()) symtab_node_base
   /* True when symbol is an alias.  
      Set by assemble_alias.  */
   unsigned alias : 1;
+  /* True when alias is a weakref.  */
+  unsigned weakref : 1;
   /* C++ frontend produce same body aliases and extra name aliases for
      virutal functions and vtables that are obviously equivalent.
      Those aliases are bit special, especially because C++ frontend
index 044bdf7b02ba4517d4077acbbdc36966c614491e..016a6e43fa98e1b9be695eb43b694de4f52277f2 100644 (file)
@@ -379,6 +379,7 @@ cgraph_reset_node (struct cgraph_node *node)
   node->symbol.analyzed = false;
   node->symbol.definition = false;
   node->symbol.alias = false;
+  node->symbol.weakref = false;
   node->symbol.cpp_implicit_alias = false;
 
   cgraph_node_remove_callees (node);
@@ -1021,9 +1022,9 @@ handle_alias_pairs (void)
          if (node)
            {
              node->symbol.alias_target = p->target;
+             node->symbol.weakref = true;
              node->symbol.alias = true;
            }
-         DECL_EXTERNAL (p->decl) = 1;
          alias_pairs->unordered_remove (i);
          continue;
        }
@@ -1034,16 +1035,6 @@ handle_alias_pairs (void)
          continue;
        }
 
-      /* Normally EXTERNAL flag is used to mark external inlines,
-        however for aliases it seems to be allowed to use it w/o
-        any meaning. See gcc.dg/attr-alias-3.c  
-        However for weakref we insist on EXTERNAL flag being set.
-        See gcc.dg/attr-alias-5.c  */
-      if (DECL_EXTERNAL (p->decl))
-       DECL_EXTERNAL (p->decl)
-         = lookup_attribute ("weakref",
-                             DECL_ATTRIBUTES (p->decl)) != NULL;
-
       if (DECL_EXTERNAL (target_node->symbol.decl)
          /* We use local aliases for C++ thunks to force the tailcall
             to bind locally.  This is a hack - to keep it working do
@@ -1885,9 +1876,9 @@ output_weakrefs (void)
 {
   symtab_node node;
   FOR_EACH_SYMBOL (node)
-    if (node->symbol.alias && DECL_EXTERNAL (node->symbol.decl)
+    if (node->symbol.alias
         && !TREE_ASM_WRITTEN (node->symbol.decl)
-       && lookup_attribute ("weakref", DECL_ATTRIBUTES (node->symbol.decl)))
+       && node->symbol.weakref)
       {
        tree target;
 
index 8c221078102381412fb42da6dc4b81abb4695288..a59e7c867f8dd5797aefea378f993133a133bd4c 100755 (executable)
@@ -21973,7 +21973,7 @@ else
   then gcc_cv_as_weakref=yes
 fi
   elif test x$gcc_cv_as != x; then
-    $as_echo ' .weakref foobar, barfnot' > conftest.s
+    $as_echo ' .weakref2 foobar, barfnot' > conftest.s
     if { ac_try='$gcc_cv_as $gcc_cv_as_flags  -o conftest.o conftest.s >&5'
   { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
   (eval $ac_try) 2>&5
index a2b7ac183126ec6d28afcef4ecea6ca5068809a0..66e565ced9040803ffe0b575678a971c481fbc02 100644 (file)
@@ -3755,6 +3755,10 @@ simple_operand_p (const_tree exp)
                 #pragma weak, etc).  */
              && ! TREE_PUBLIC (exp)
              && ! DECL_EXTERNAL (exp)
+             /* Weakrefs are not safe to be read, since they can be NULL.
+                They are !TREE_PUBLIC && !DECL_EXTERNAL but still
+                have DECL_WEAK flag set.  */
+             && (! VAR_OR_FUNCTION_DECL_P (exp) || ! DECL_WEAK (exp))
              /* Loading a static variable is unduly expensive, but global
                 registers aren't expensive.  */
              && (! TREE_STATIC (exp) || DECL_REGISTER (exp))));
index 181d28d1b617d969476044e48615a6deb3566f0a..60fca6bc28541c7833b8b0ea870ec5e748212959 100644 (file)
@@ -73,11 +73,6 @@ can_refer_decl_in_current_unit_p (tree decl, tree from_decl)
   if ((!TREE_STATIC (decl) && !DECL_EXTERNAL (decl))
       || (TREE_CODE (decl) != VAR_DECL && TREE_CODE (decl) != FUNCTION_DECL))
     return true;
-  /* Weakrefs have somewhat confusing DECL_EXTERNAL flag set; they
-     are always safe.  */
-  if (DECL_EXTERNAL (decl)
-      && lookup_attribute ("weakref", DECL_ATTRIBUTES (decl)))
-    return true;
   /* We are folding reference from external vtable.  The vtable may reffer
      to a symbol keyed to other compilation unit.  The other compilation
      unit may be in separate DSO and the symbol may be hidden.  */
index a73cbb1c08962f5bc2a574774d6ccc788a67c1e0..98a7b07841690dc803b58078fc8fdcb74f7a58e9 100644 (file)
--- a/gcc/ipa.c
+++ b/gcc/ipa.c
@@ -664,12 +664,6 @@ cgraph_externally_visible_p (struct cgraph_node *node,
 bool
 varpool_externally_visible_p (struct varpool_node *vnode)
 {
-  /* Do not touch weakrefs; while they are not externally visible,
-     dropping their DECL_EXTERNAL flags confuse most
-     of code handling them.  */
-  if (vnode->symbol.alias && DECL_EXTERNAL (vnode->symbol.decl))
-    return true;
-
   if (DECL_EXTERNAL (vnode->symbol.decl))
     return true;
 
@@ -784,9 +778,9 @@ function_and_variable_visibility (bool whole_program)
         happy.  Clear the flag here to avoid confusion in middle-end.  */
       if (DECL_COMDAT (node->symbol.decl) && !TREE_PUBLIC (node->symbol.decl))
         DECL_COMDAT (node->symbol.decl) = 0;
-      /* For external decls stop tracking same_comdat_group, it doesn't matter
-        what comdat group they are in when they won't be emitted in this TU,
-        and simplifies later passes.  */
+
+      /* For external decls stop tracking same_comdat_group. It doesn't matter
+        what comdat group they are in when they won't be emitted in this TU.  */
       if (node->symbol.same_comdat_group && DECL_EXTERNAL (node->symbol.decl))
        {
 #ifdef ENABLE_CHECKING
@@ -804,6 +798,7 @@ function_and_variable_visibility (bool whole_program)
       gcc_assert ((!DECL_WEAK (node->symbol.decl)
                  && !DECL_COMDAT (node->symbol.decl))
                  || TREE_PUBLIC (node->symbol.decl)
+                 || node->symbol.weakref
                  || DECL_EXTERNAL (node->symbol.decl));
       if (cgraph_externally_visible_p (node, whole_program))
         {
@@ -815,7 +810,8 @@ function_and_variable_visibility (bool whole_program)
          node->symbol.externally_visible = false;
          node->symbol.forced_by_abi = false;
        }
-      if (!node->symbol.externally_visible && node->symbol.definition
+      if (!node->symbol.externally_visible
+         && node->symbol.definition && !node->symbol.weakref
          && !DECL_EXTERNAL (node->symbol.decl))
        {
          gcc_assert (whole_program || in_lto_p
@@ -860,6 +856,7 @@ function_and_variable_visibility (bool whole_program)
     {
       /* weak flag makes no sense on local variables.  */
       gcc_assert (!DECL_WEAK (vnode->symbol.decl)
+                 || vnode->symbol.weakref
                  || TREE_PUBLIC (vnode->symbol.decl)
                  || DECL_EXTERNAL (vnode->symbol.decl));
       /* In several cases declarations can not be common:
@@ -897,7 +894,8 @@ function_and_variable_visibility (bool whole_program)
           vnode->symbol.externally_visible = false;
          vnode->symbol.forced_by_abi = false;
        }
-      if (!vnode->symbol.externally_visible)
+      if (!vnode->symbol.externally_visible
+         && !vnode->symbol.weakref)
        {
          gcc_assert (in_lto_p || whole_program || !TREE_PUBLIC (vnode->symbol.decl));
          symtab_make_decl_local (vnode->symbol.decl);
index bc9e5cdbf75ec865814dedd64dbb0907ec034744..63a9ddb222738232a954997e5bbe52888c80210a 100644 (file)
@@ -487,8 +487,9 @@ lto_output_node (struct lto_simple_output_block *ob, struct cgraph_node *node,
      defined in other unit, we may use the info on aliases to resolve 
      symbol1 != symbol2 type tests that we can do only for locally defined objects
      otherwise.  */
-  alias_p = node->symbol.alias && (!boundary_p || DECL_EXTERNAL (node->symbol.decl));
+  alias_p = node->symbol.alias && (!boundary_p || node->symbol.weakref);
   bp_pack_value (&bp, alias_p, 1);
+  bp_pack_value (&bp, node->symbol.weakref, 1);
   bp_pack_value (&bp, node->frequency, 2);
   bp_pack_value (&bp, node->only_called_at_startup, 1);
   bp_pack_value (&bp, node->only_called_at_exit, 1);
@@ -531,8 +532,9 @@ lto_output_varpool_node (struct lto_simple_output_block *ob, struct varpool_node
   bp_pack_value (&bp, node->symbol.forced_by_abi, 1);
   bp_pack_value (&bp, node->symbol.unique_name, 1);
   bp_pack_value (&bp, node->symbol.definition, 1);
-  alias_p = node->symbol.alias && (!boundary_p || DECL_EXTERNAL (node->symbol.decl));
+  alias_p = node->symbol.alias && (!boundary_p || node->symbol.weakref);
   bp_pack_value (&bp, alias_p, 1);
+  bp_pack_value (&bp, node->symbol.weakref, 1);
   bp_pack_value (&bp, node->symbol.analyzed && !boundary_p, 1);
   gcc_assert (node->symbol.definition || !node->symbol.analyzed);
   /* Constant pool initializers can be de-unified into individual ltrans units.
@@ -906,6 +908,7 @@ input_overwrite_node (struct lto_file_decl_data *file_data,
       TREE_STATIC (node->symbol.decl) = 0;
     }
   node->symbol.alias = bp_unpack_value (bp, 1);
+  node->symbol.weakref = bp_unpack_value (bp, 1);
   node->frequency = (enum node_frequency)bp_unpack_value (bp, 2);
   node->only_called_at_startup = bp_unpack_value (bp, 1);
   node->only_called_at_exit = bp_unpack_value (bp, 1);
@@ -1010,8 +1013,7 @@ input_node (struct lto_file_decl_data *file_data,
       node->thunk.virtual_value = virtual_value;
       node->thunk.virtual_offset_p = (type & 4);
     }
-  if (node->symbol.alias && !node->symbol.analyzed
-      && lookup_attribute ("weakref", DECL_ATTRIBUTES (node->symbol.decl)))
+  if (node->symbol.alias && !node->symbol.analyzed && node->symbol.weakref)
     node->symbol.alias_target = get_alias_symbol (node->symbol.decl);
   return node;
 }
@@ -1046,6 +1048,7 @@ input_varpool_node (struct lto_file_decl_data *file_data,
   node->symbol.unique_name = bp_unpack_value (&bp, 1);
   node->symbol.definition = bp_unpack_value (&bp, 1);
   node->symbol.alias = bp_unpack_value (&bp, 1);
+  node->symbol.weakref = bp_unpack_value (&bp, 1);
   node->symbol.analyzed = bp_unpack_value (&bp, 1);
   node->symbol.used_from_other_partition = bp_unpack_value (&bp, 1);
   node->symbol.in_other_partition = bp_unpack_value (&bp, 1);
@@ -1054,8 +1057,7 @@ input_varpool_node (struct lto_file_decl_data *file_data,
       DECL_EXTERNAL (node->symbol.decl) = 1;
       TREE_STATIC (node->symbol.decl) = 0;
     }
-  if (node->symbol.alias && !node->symbol.analyzed
-      && lookup_attribute ("weakref", DECL_ATTRIBUTES (node->symbol.decl)))
+  if (node->symbol.alias && !node->symbol.analyzed && node->symbol.weakref)
     node->symbol.alias_target = get_alias_symbol (node->symbol.decl);
   ref = streamer_read_hwi (ib);
   /* Store a reference for now, and fix up later to be a pointer.  */
index 2b41933c67e0ff3eb5f72ea76312610e1ff965ad..5f0b97165560690f4aa7d44e7c3b613619ac06ec 100644 (file)
@@ -235,9 +235,6 @@ lto_symtab_symbol_p (symtab_node e)
 {
   if (!TREE_PUBLIC (e->symbol.decl) && !DECL_EXTERNAL (e->symbol.decl))
     return false;
-  /* weakrefs are really static variables that are made external by a hack.  */
-  if (lookup_attribute ("weakref", DECL_ATTRIBUTES (e->symbol.decl)))
-    return false;
   return symtab_real_symbol_p (e);
 }
 
@@ -589,6 +586,7 @@ lto_symtab_merge_symbols (void)
          if (!node->symbol.analyzed && node->symbol.alias_target)
            {
              symtab_node tgt = symtab_node_for_asm (node->symbol.alias_target);
+             gcc_assert (node->symbol.weakref);
              if (tgt)
                symtab_resolve_alias (node, tgt);
            }
@@ -617,11 +615,6 @@ lto_symtab_prevailing_decl (tree decl)
   if (TREE_CODE (decl) == FUNCTION_DECL && DECL_BUILT_IN (decl))
     return decl;
 
-  /* As an anoying special cases weakrefs are really static variables with
-     EXTERNAL flag.  */
-  if (lookup_attribute ("weakref", DECL_ATTRIBUTES (decl)))
-    return decl;
-
   /* Ensure DECL_ASSEMBLER_NAME will not set assembler name.  */
   gcc_assert (DECL_ASSEMBLER_NAME_SET_P (decl));
 
index f98c31d725aafd771814f773b06bf2b1c475975e..153f023b4a13ddc9ce15b0e5f192ed8ac84accb2 100644 (file)
@@ -1,3 +1,11 @@
+2013-06-11 Jan Hubicka  <jh@suse.cz>
+
+       * lto-partition.c (get_symbol_class): Simplify weakref handling.
+       (add_symbol_to_partition_1): Likewise.
+       (contained_in_symbol): Likewise.
+       (lto_balanced_map): Likewise.
+       (rename_statics): Drop weakref.
+
 2013-06-05  Richard Biener  <rguenther@suse.de>
 
        * lto.c (num_merged_types): New global variable.
index 921b4e26e311f4acf189d7d43f87fb9c7a8f882f..6f4538061558766dd331af71da5464f83f0fce2c 100644 (file)
@@ -60,7 +60,7 @@ get_symbol_class (symtab_node node)
     return SYMBOL_DUPLICATE;
 
   /* Weakref aliases are always duplicated.  */
-  if (lookup_attribute ("weakref", DECL_ATTRIBUTES (node->symbol.decl)))
+  if (node->symbol.weakref)
     return SYMBOL_DUPLICATE;
 
   /* External declarations are external.  */
@@ -218,10 +218,7 @@ add_symbol_to_partition_1 (ltrans_partition part, symtab_node node)
 
   /* Add all aliases associated with the symbol.  */
   for (i = 0; ipa_ref_list_referring_iterate (&node->symbol.ref_list, i, ref); i++)
-    if (ref->use == IPA_REF_ALIAS
-       && !lookup_attribute ("weakref",
-                             DECL_ATTRIBUTES
-                               (ref->referring->symbol.decl)))
+    if (ref->use == IPA_REF_ALIAS && !node->symbol.weakref)
       add_symbol_to_partition_1 (part, ref->referring);
 
   /* Ensure that SAME_COMDAT_GROUP lists all allways added in a group.  */
@@ -243,8 +240,7 @@ static symtab_node
 contained_in_symbol (symtab_node node)
 {
   /* Weakrefs are never contained in anything.  */
-  if (lookup_attribute ("weakref",
-                       DECL_ATTRIBUTES (node->symbol.decl)))
+  if (node->symbol.weakref)
     return node;
   if (cgraph_node *cnode = dyn_cast <cgraph_node> (node))
     {
@@ -561,8 +557,7 @@ lto_balanced_map (void)
 
              last_visited_node++;
 
-             gcc_assert (node->symbol.definition
-                         || lookup_attribute ("weakref", DECL_ATTRIBUTES (node->symbol.decl)));
+             gcc_assert (node->symbol.definition || node->symbol.weakref);
 
              /* Compute boundary cost of callgraph edges.  */
              for (edge = node->callees; edge; edge = edge->next_callee)
@@ -871,8 +866,7 @@ rename_statics (lto_symtab_encoder_t encoder, symtab_node node)
         once this is fixed.  */
         || DECL_EXTERNAL (node->symbol.decl)
         || !symtab_real_symbol_p (node))
-       && !may_need_named_section_p (encoder, node)
-       && !lookup_attribute ("weakref", DECL_ATTRIBUTES (node->symbol.decl)))
+       && !may_need_named_section_p (encoder, node))
     return;
 
   /* Now walk symbols sharing the same name and see if there are any conflicts.
@@ -897,11 +891,9 @@ rename_statics (lto_symtab_encoder_t encoder, symtab_node node)
   /* Assign every symbol in the set that shares the same ASM name an unique
      mangled name.  */
   for (s = symtab_node_for_asm (name); s;)
-    if ((!s->symbol.externally_visible
-        || lookup_attribute ("weakref", DECL_ATTRIBUTES (node->symbol.decl)))
+    if (!s->symbol.externally_visible
        && ((symtab_real_symbol_p (s)
-             && (!DECL_EXTERNAL (node->symbol.decl)
-                || lookup_attribute ("weakref", DECL_ATTRIBUTES (node->symbol.decl)))
+             && !DECL_EXTERNAL (node->symbol.decl)
             && !TREE_PUBLIC (node->symbol.decl))
            || may_need_named_section_p (encoder, s))
        && (!encoder
index a4dad2aace46a5e64d1fcee14e4eae4aa6baf0e4..c8b03eef133532246afc2f0d4cd9bff6e0f0e811 100644 (file)
@@ -136,8 +136,8 @@ rest_of_decl_compilation (tree decl,
        /* A quirk of the initial implementation of aliases required that the
           user add "extern" to all of them.  Which is silly, but now
           historical.  Do note that the symbol is in fact locally defined.  */
-       if (!lookup_attribute ("weakref", DECL_ATTRIBUTES (decl)))
-         DECL_EXTERNAL (decl) = 0;
+       DECL_EXTERNAL (decl) = 0;
+       TREE_STATIC (decl) = 1;
        assemble_alias (decl, alias);
       }
   }
index 28ee6f0e0a1c3c878f0c33bf4729c45901661e13..7a02270c2578f7a57377334f33a98a087bf34288 100644 (file)
@@ -481,6 +481,8 @@ dump_symtab_base (FILE *f, symtab_node node)
     fprintf (f, " analyzed");
   if (node->symbol.alias)
     fprintf (f, " alias");
+  if (node->symbol.weakref)
+    fprintf (f, " weakref");
   if (node->symbol.cpp_implicit_alias)
     fprintf (f, " cpp_implicit_alias");
   if (node->symbol.alias_target)
@@ -682,11 +684,16 @@ verify_symtab_base (symtab_node node)
       error_found = true;
     }
   if (node->symbol.alias && !node->symbol.definition
-      && !lookup_attribute ("weakref", DECL_ATTRIBUTES (node->symbol.decl)))
+      && !node->symbol.weakref)
     {
       error ("node is alias but not definition");
       error_found = true;
     }
+  if (node->symbol.weakref && !node->symbol.alias)
+    {
+      error ("node is weakref but not an alias");
+      error_found = true;
+    }
   if (node->symbol.same_comdat_group)
     {
       symtab_node n = node->symbol.same_comdat_group;
@@ -799,8 +806,6 @@ symtab_make_decl_local (tree decl)
   DECL_VISIBILITY_SPECIFIED (decl) = 0;
   DECL_VISIBILITY (decl) = VISIBILITY_DEFAULT;
   TREE_PUBLIC (decl) = 0;
-  DECL_VISIBILITY_SPECIFIED (decl) = 0;
-  DECL_VISIBILITY (decl) = VISIBILITY_DEFAULT;
   if (!DECL_RTL_SET_P (decl))
     return;
 
@@ -861,7 +866,7 @@ symtab_alias_ultimate_target (symtab_node node, enum availability *availability)
 
   if (availability)
     {
-      weakref_p = DECL_EXTERNAL (node->symbol.decl) && node->symbol.alias;
+      weakref_p = node->symbol.weakref;
       if (!weakref_p)
         *availability = symtab_node_availability (node);
       else
@@ -893,7 +898,7 @@ symtab_alias_ultimate_target (symtab_node node, enum availability *availability)
          enum availability a = symtab_node_availability (node);
          if (a < *availability)
            *availability = a;
-          weakref_p = DECL_EXTERNAL (node->symbol.decl) && node->symbol.alias;
+          weakref_p = node->symbol.weakref;
        }
     }
   if (availability)
index a3e9325a2ce4548a90b8a291e57c9da427c3f389..4b238843aea940a46c49482489b468fbfe47184d 100644 (file)
@@ -452,6 +452,8 @@ varpool_create_variable_alias (tree alias, tree decl)
   alias_node->symbol.alias = true;
   alias_node->symbol.definition = true;
   alias_node->symbol.alias_target = decl;
+  if (lookup_attribute ("weakref", DECL_ATTRIBUTES (alias)) != NULL)
+    alias_node->symbol.weakref = true;
   return alias_node;
 }