rs6000.h (RS6000_BTM_ALWAYS): New.
[platform/upstream/gcc.git] / gcc / symtab.c
1 /* Symbol table.
2    Copyright (C) 2012 Free Software Foundation, Inc.
3    Contributed by Jan Hubicka
4
5 This file is part of GCC.
6
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
10 version.
11
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15 for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3.  If not see
19 <http://www.gnu.org/licenses/>.  */
20
21 #include "config.h"
22 #include "system.h"
23 #include "coretypes.h"
24 #include "tm.h"
25 #include "tree.h"
26 #include "tree-inline.h"
27 #include "langhooks.h"
28 #include "hashtab.h"
29 #include "ggc.h"
30 #include "cgraph.h"
31 #include "diagnostic.h"
32 #include "timevar.h"
33 #include "lto-streamer.h"
34 #include "rtl.h"
35
36 const char * const ld_plugin_symbol_resolution_names[]=
37 {
38   "",
39   "undef",
40   "prevailing_def",
41   "prevailing_def_ironly",
42   "preempted_reg",
43   "preempted_ir",
44   "resolved_ir",
45   "resolved_exec",
46   "resolved_dyn",
47   "prevailing_def_ironly_exp"
48 };
49
50 /* Hash table used to convert declarations into nodes.  */
51 static GTY((param_is (union symtab_node_def))) htab_t symtab_hash;
52 /* Hash table used to convert assembler names into nodes.  */
53 static GTY((param_is (union symtab_node_def))) htab_t assembler_name_hash;
54
55 /* Linked list of symbol table nodes.  */
56 symtab_node symtab_nodes;
57
58 /* The order index of the next symtab node to be created.  This is
59    used so that we can sort the cgraph nodes in order by when we saw
60    them, to support -fno-toplevel-reorder.  */
61 int symtab_order;
62
63 /* Returns a hash code for P.  */
64
65 static hashval_t
66 hash_node (const void *p)
67 {
68   const_symtab_node n = (const_symtab_node ) p;
69   return (hashval_t) DECL_UID (n->symbol.decl);
70 }
71
72
73 /* Returns nonzero if P1 and P2 are equal.  */
74
75 static int
76 eq_node (const void *p1, const void *p2)
77 {
78   const_symtab_node n1 = (const_symtab_node) p1;
79   const_symtab_node n2 = (const_symtab_node) p2;
80   return DECL_UID (n1->symbol.decl) == DECL_UID (n2->symbol.decl);
81 }
82
83 /* Returns a hash code for P.  */
84
85 static hashval_t
86 hash_node_by_assembler_name (const void *p)
87 {
88   const_symtab_node n = (const_symtab_node) p;
89   return (hashval_t) decl_assembler_name_hash (DECL_ASSEMBLER_NAME (n->symbol.decl));
90 }
91
92 /* Returns nonzero if P1 and P2 are equal.  */
93
94 static int
95 eq_assembler_name (const void *p1, const void *p2)
96 {
97   const_symtab_node n1 = (const_symtab_node) p1;
98   const_tree name = (const_tree)p2;
99   return (decl_assembler_name_equal (n1->symbol.decl, name));
100 }
101
102 /* Insert NODE to assembler name hash.  */
103
104 static void
105 insert_to_assembler_name_hash (symtab_node node)
106 {
107   gcc_checking_assert (!node->symbol.previous_sharing_asm_name
108                        && !node->symbol.next_sharing_asm_name);
109   if (assembler_name_hash)
110     {
111       void **aslot;
112       tree name = DECL_ASSEMBLER_NAME (node->symbol.decl);
113
114       aslot = htab_find_slot_with_hash (assembler_name_hash, name,
115                                         decl_assembler_name_hash (name),
116                                         INSERT);
117       gcc_assert (*aslot != node);
118       node->symbol.next_sharing_asm_name = (symtab_node)*aslot;
119       if (*aslot != NULL)
120         ((symtab_node)*aslot)->symbol.previous_sharing_asm_name = node;
121       *aslot = node;
122     }
123
124 }
125
126 /* Remove NODE from assembler name hash.  */
127
128 static void
129 unlink_from_assembler_name_hash (symtab_node node)
130 {
131   if (assembler_name_hash)
132     {
133       if (node->symbol.next_sharing_asm_name)
134         node->symbol.next_sharing_asm_name->symbol.previous_sharing_asm_name
135           = node->symbol.previous_sharing_asm_name;
136       if (node->symbol.previous_sharing_asm_name)
137         {
138           node->symbol.previous_sharing_asm_name->symbol.next_sharing_asm_name
139             = node->symbol.next_sharing_asm_name;
140         }
141       else
142         {
143           tree name = DECL_ASSEMBLER_NAME (node->symbol.decl);
144           void **slot;
145           slot = htab_find_slot_with_hash (assembler_name_hash, name,
146                                            decl_assembler_name_hash (name),
147                                            NO_INSERT);
148           gcc_assert (*slot == node);
149           if (!node->symbol.next_sharing_asm_name)
150             htab_clear_slot (assembler_name_hash, slot);
151           else
152             *slot = node->symbol.next_sharing_asm_name;
153         }
154     }
155 }
156
157
158 /* Add node into symbol table.  This function is not used directly, but via
159    cgraph/varpool node creation routines.  */
160
161 void
162 symtab_register_node (symtab_node node)
163 {
164   struct symtab_node_base key;
165   symtab_node *slot;
166
167   node->symbol.next = symtab_nodes;
168   node->symbol.previous = NULL;
169   if (symtab_nodes)
170     symtab_nodes->symbol.previous = node;
171   symtab_nodes = node;
172
173   if (!symtab_hash)
174     symtab_hash = htab_create_ggc (10, hash_node, eq_node, NULL);
175   key.decl = node->symbol.decl;
176   slot = (symtab_node *) htab_find_slot (symtab_hash, &key, INSERT);
177   if (*slot == NULL)
178     *slot = node;
179
180   ipa_empty_ref_list (&node->symbol.ref_list);
181
182   node->symbol.order = symtab_order++;
183
184   /* Be sure to do this last; C++ FE might create new nodes via
185      DECL_ASSEMBLER_NAME langhook!  */
186   insert_to_assembler_name_hash (node);
187 }
188
189 /* Make NODE to be the one symtab hash is pointing to.  Used when reshaping tree
190    of inline clones.  */
191
192 void
193 symtab_insert_node_to_hashtable (symtab_node node)
194 {
195   struct symtab_node_base key;
196   symtab_node *slot;
197
198   if (!symtab_hash)
199     symtab_hash = htab_create_ggc (10, hash_node, eq_node, NULL);
200   key.decl = node->symbol.decl;
201   slot = (symtab_node *) htab_find_slot (symtab_hash, &key, INSERT);
202   *slot = node;
203 }
204
205 /* Remove node from symbol table.  This function is not used directly, but via
206    cgraph/varpool node removal routines.  */
207
208 void
209 symtab_unregister_node (symtab_node node)
210 {
211   void **slot;
212   ipa_remove_all_references (&node->symbol.ref_list);
213   ipa_remove_all_referring (&node->symbol.ref_list);
214
215   if (node->symbol.same_comdat_group)
216     {
217       symtab_node prev;
218       for (prev = node->symbol.same_comdat_group;
219            prev->symbol.same_comdat_group != node;
220            prev = prev->symbol.same_comdat_group)
221         ;
222       if (node->symbol.same_comdat_group == prev)
223         prev->symbol.same_comdat_group = NULL;
224       else
225         prev->symbol.same_comdat_group = node->symbol.same_comdat_group;
226       node->symbol.same_comdat_group = NULL;
227     }
228
229   if (node->symbol.previous)
230     node->symbol.previous->symbol.next = node->symbol.next;
231   else
232     symtab_nodes = node->symbol.next;
233   if (node->symbol.next)
234     node->symbol.next->symbol.previous = node->symbol.previous;
235   node->symbol.next = NULL;
236   node->symbol.previous = NULL;
237
238   slot = htab_find_slot (symtab_hash, node, NO_INSERT);
239   if (*slot == node)
240     {
241       symtab_node replacement_node = NULL;
242       if (symtab_function_p (node))
243         replacement_node = (symtab_node)cgraph_find_replacement_node (cgraph (node));
244       if (!replacement_node)
245         htab_clear_slot (symtab_hash, slot);
246       else
247         *slot = replacement_node;
248     }
249   unlink_from_assembler_name_hash (node);
250 }
251
252 /* Return symbol table node associated with DECL, if any,
253    and NULL otherwise.  */
254
255 symtab_node
256 symtab_get_node (const_tree decl)
257 {
258   symtab_node *slot;
259   struct symtab_node_base key;
260
261   gcc_checking_assert (TREE_CODE (decl) == FUNCTION_DECL
262                        || (TREE_CODE (decl) == VAR_DECL
263                            && (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
264                                || in_lto_p)));
265
266   if (!symtab_hash)
267     return NULL;
268
269   key.decl = CONST_CAST2 (tree, const_tree, decl);
270
271   slot = (symtab_node *) htab_find_slot (symtab_hash, &key,
272                                          NO_INSERT);
273
274   if (slot)
275     return *slot;
276   return NULL;
277 }
278
279 /* Remove symtab NODE from the symbol table.  */
280
281 void
282 symtab_remove_node (symtab_node node)
283 {
284   if (symtab_function_p (node))
285     cgraph_remove_node (cgraph (node));
286   else if (symtab_variable_p (node))
287     varpool_remove_node (varpool (node));
288 }
289
290 /* Return the cgraph node that has ASMNAME for its DECL_ASSEMBLER_NAME.
291    Return NULL if there's no such node.  */
292
293 symtab_node
294 symtab_node_for_asm (const_tree asmname)
295 {
296   symtab_node node;
297   void **slot;
298
299   if (!assembler_name_hash)
300     {
301       assembler_name_hash =
302         htab_create_ggc (10, hash_node_by_assembler_name, eq_assembler_name,
303                          NULL);
304       FOR_EACH_SYMBOL (node)
305         insert_to_assembler_name_hash (node);
306     }
307
308   slot = htab_find_slot_with_hash (assembler_name_hash, asmname,
309                                    decl_assembler_name_hash (asmname),
310                                    NO_INSERT);
311
312   if (slot)
313     {
314       node = (symtab_node) *slot;
315       return node;
316     }
317   return NULL;
318 }
319
320 /* Set the DECL_ASSEMBLER_NAME and update symtab hashtables.  */
321
322 void
323 change_decl_assembler_name (tree decl, tree name)
324 {
325   symtab_node node = NULL;
326
327   /* We can have user ASM names on things, like global register variables, that
328      are not in the symbol table.  */
329   if ((TREE_CODE (decl) == VAR_DECL
330        && (TREE_STATIC (decl) || DECL_EXTERNAL (decl)))
331       || TREE_CODE (decl) == FUNCTION_DECL)
332     node = symtab_get_node (decl);
333   if (!DECL_ASSEMBLER_NAME_SET_P (decl))
334     {
335       SET_DECL_ASSEMBLER_NAME (decl, name);
336       if (node)
337         insert_to_assembler_name_hash (node);
338     }
339   else
340     {
341       if (name == DECL_ASSEMBLER_NAME (decl))
342         return;
343
344       if (node)
345         unlink_from_assembler_name_hash (node);
346       if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))
347           && DECL_RTL_SET_P (decl))
348         warning (0, "%D renamed after being referenced in assembly", decl);
349
350       SET_DECL_ASSEMBLER_NAME (decl, name);
351       if (node)
352         insert_to_assembler_name_hash (node);
353     }
354 }
355
356 /* Add NEW_ to the same comdat group that OLD is in.  */
357
358 void
359 symtab_add_to_same_comdat_group (symtab_node new_node,
360                                  symtab_node old_node)
361 {
362   gcc_assert (DECL_ONE_ONLY (old_node->symbol.decl));
363   gcc_assert (!new_node->symbol.same_comdat_group);
364   gcc_assert (new_node != old_node);
365
366   DECL_COMDAT_GROUP (new_node->symbol.decl) = DECL_COMDAT_GROUP (old_node->symbol.decl);
367   new_node->symbol.same_comdat_group = old_node;
368   if (!old_node->symbol.same_comdat_group)
369     old_node->symbol.same_comdat_group = new_node;
370   else
371     {
372       symtab_node n;
373       for (n = old_node->symbol.same_comdat_group;
374            n->symbol.same_comdat_group != old_node;
375            n = n->symbol.same_comdat_group)
376         ;
377       n->symbol.same_comdat_group = new_node;
378     }
379 }
380
381 /* Dissolve the same_comdat_group list in which NODE resides.  */
382
383 void
384 symtab_dissolve_same_comdat_group_list (symtab_node node)
385 {
386   symtab_node n = node, next;
387
388   if (!node->symbol.same_comdat_group)
389     return;
390   do
391     {
392       next = n->symbol.same_comdat_group;
393       n->symbol.same_comdat_group = NULL;
394       n = next;
395     }
396   while (n != node);
397 }
398
399 /* Return printable assembler name of NODE.
400    This function is used only for debugging.  When assembler name
401    is unknown go with identifier name.  */
402
403 const char *
404 symtab_node_asm_name (symtab_node node)
405 {
406   if (!DECL_ASSEMBLER_NAME_SET_P (node->symbol.decl))
407     return lang_hooks.decl_printable_name (node->symbol.decl, 2);
408   return IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (node->symbol.decl));
409 }
410
411 /* Return printable identifier name.  */
412
413 const char *
414 symtab_node_name (symtab_node node)
415 {
416   return lang_hooks.decl_printable_name (node->symbol.decl, 2);
417 }
418
419 static const char * const symtab_type_names[] = {"symbol", "function", "variable"};
420
421 /* Dump base fields of symtab nodes.  Not to be used directly.  */
422
423 void
424 dump_symtab_base (FILE *f, symtab_node node)
425 {
426   static const char * const visibility_types[] = {
427     "default", "protected", "hidden", "internal"
428   };
429
430   fprintf (f, "%s/%i (%s)",
431            symtab_node_asm_name (node),
432            node->symbol.order,
433            symtab_node_name (node));
434   dump_addr (f, " @", (void *)node);
435   fprintf (f, "\n  Type: %s\n", symtab_type_names[node->symbol.type]);
436   fprintf (f, "  Visibility:");
437
438   if (node->symbol.in_other_partition)
439     fprintf (f, " in_other_partition");
440   if (node->symbol.used_from_other_partition)
441     fprintf (f, " used_from_other_partition");
442   if (node->symbol.force_output)
443     fprintf (f, " force_output");
444   if (node->symbol.resolution != LDPR_UNKNOWN)
445     fprintf (f, " %s",
446              ld_plugin_symbol_resolution_names[(int)node->symbol.resolution]);
447   if (TREE_ASM_WRITTEN (node->symbol.decl))
448     fprintf (f, " asm_written");
449   if (DECL_EXTERNAL (node->symbol.decl))
450     fprintf (f, " external");
451   if (TREE_PUBLIC (node->symbol.decl))
452     fprintf (f, " public");
453   if (DECL_COMMON (node->symbol.decl))
454     fprintf (f, " common");
455   if (DECL_WEAK (node->symbol.decl))
456     fprintf (f, " weak");
457   if (DECL_DLLIMPORT_P (node->symbol.decl))
458     fprintf (f, " dll_import");
459   if (DECL_COMDAT (node->symbol.decl))
460     fprintf (f, " comdat");
461   if (DECL_COMDAT_GROUP (node->symbol.decl))
462     fprintf (f, " comdat_group:%s",
463              IDENTIFIER_POINTER (DECL_COMDAT_GROUP (node->symbol.decl)));
464   if (DECL_ONE_ONLY (node->symbol.decl))
465     fprintf (f, " one_only");
466   if (DECL_SECTION_NAME (node->symbol.decl))
467     fprintf (f, " section_name:%s",
468              TREE_STRING_POINTER (DECL_SECTION_NAME (node->symbol.decl)));
469   if (DECL_VISIBILITY_SPECIFIED (node->symbol.decl))
470     fprintf (f, " visibility_specified");
471   if (DECL_VISIBILITY (node->symbol.decl))
472     fprintf (f, " visibility:%s",
473              visibility_types [DECL_VISIBILITY (node->symbol.decl)]);
474   if (DECL_VIRTUAL_P (node->symbol.decl))
475     fprintf (f, " virtual");
476   if (DECL_ARTIFICIAL (node->symbol.decl))
477     fprintf (f, " artificial");
478   if (TREE_CODE (node->symbol.decl) == FUNCTION_DECL)
479     {
480       if (DECL_STATIC_CONSTRUCTOR (node->symbol.decl))
481         fprintf (f, " constructor");
482       if (DECL_STATIC_DESTRUCTOR (node->symbol.decl))
483         fprintf (f, " destructor");
484     }
485   fprintf (f, "\n");
486   
487   if (node->symbol.same_comdat_group)
488     fprintf (f, "  Same comdat group as: %s/%i\n",
489              symtab_node_asm_name (node->symbol.same_comdat_group),
490              node->symbol.same_comdat_group->symbol.order);
491   if (node->symbol.next_sharing_asm_name)
492     fprintf (f, "  next sharing asm name: %i\n",
493              node->symbol.next_sharing_asm_name->symbol.order);
494   if (node->symbol.previous_sharing_asm_name)
495     fprintf (f, "  previous sharing asm name: %i\n",
496              node->symbol.previous_sharing_asm_name->symbol.order);
497
498   if (node->symbol.address_taken)
499     fprintf (f, "  Address is taken.\n");
500   if (node->symbol.aux)
501     {
502       fprintf (f, "  Aux:");
503       dump_addr (f, " @", (void *)node->symbol.aux);
504     }
505
506   fprintf (f, "  References: ");
507   ipa_dump_references (f, &node->symbol.ref_list);
508   fprintf (f, "  Referring: ");
509   ipa_dump_referring (f, &node->symbol.ref_list);
510 }
511
512 /* Dump symtab node.  */
513
514 void
515 dump_symtab_node (FILE *f, symtab_node node)
516 {
517   if (symtab_function_p (node))
518     dump_cgraph_node (f, cgraph (node));
519   else if (symtab_variable_p (node))
520     dump_varpool_node (f, varpool (node));
521 }
522
523 /* Dump symbol table.  */
524
525 void
526 dump_symtab (FILE *f)
527 {
528   symtab_node node;
529   fprintf (f, "Symbol table:\n\n");
530   FOR_EACH_SYMBOL (node)
531     dump_symtab_node (f, node);
532 }
533
534 /* Dump symtab node NODE to stderr.  */
535
536 DEBUG_FUNCTION void
537 debug_symtab_node (symtab_node node)
538 {
539   dump_symtab_node (stderr, node);
540 }
541
542 /* Dump symbol table to stderr.  */
543
544 DEBUG_FUNCTION void
545 debug_symtab (void)
546 {
547   dump_symtab (stderr);
548 }
549
550 /* Verify common part of symtab nodes.  */
551
552 DEBUG_FUNCTION bool
553 verify_symtab_base (symtab_node node)
554 {
555   bool error_found = false;
556   symtab_node hashed_node;
557
558   if (symtab_function_p (node))
559     {
560       if (TREE_CODE (node->symbol.decl) != FUNCTION_DECL)
561         {
562           error ("function symbol is not function");
563           error_found = true;
564         }
565     }
566   else if (symtab_variable_p (node))
567     {
568       if (TREE_CODE (node->symbol.decl) != VAR_DECL)
569         {
570           error ("variable symbol is not variable");
571           error_found = true;
572         }
573     }
574   else
575     {
576       error ("node has unknown type");
577       error_found = true;
578     }
579    
580   hashed_node = symtab_get_node (node->symbol.decl);
581   if (!hashed_node)
582     {
583       error ("node not found in symtab decl hashtable");
584       error_found = true;
585     }
586   if (assembler_name_hash)
587     {
588       hashed_node = symtab_node_for_asm (DECL_ASSEMBLER_NAME (node->symbol.decl));
589       if (hashed_node && hashed_node->symbol.previous_sharing_asm_name)
590         {
591           error ("assembler name hash list corrupted");
592           error_found = true;
593         }
594       while (hashed_node)
595         {
596           if (hashed_node == node)
597             break;
598           hashed_node = hashed_node->symbol.next_sharing_asm_name;
599         }
600       if (!hashed_node)
601         {
602           error ("node not found in symtab assembler name hash");
603           error_found = true;
604         }
605     }
606   if (node->symbol.previous_sharing_asm_name
607       && node->symbol.previous_sharing_asm_name->symbol.next_sharing_asm_name != node)
608     {
609       error ("double linked list of assembler names corrupted");
610     }
611   if (node->symbol.same_comdat_group)
612     {
613       symtab_node n = node->symbol.same_comdat_group;
614
615       if (!DECL_ONE_ONLY (n->symbol.decl))
616         {
617           error ("non-DECL_ONE_ONLY node in a same_comdat_group list");
618           error_found = true;
619         }
620       if (n->symbol.type != node->symbol.type)
621         {
622           error ("mixing different types of symbol in same comdat groups is not supported");
623           error_found = true;
624         }
625       if (n == node)
626         {
627           error ("node is alone in a comdat group");
628           error_found = true;
629         }
630       do
631         {
632           if (!n->symbol.same_comdat_group)
633             {
634               error ("same_comdat_group is not a circular list");
635               error_found = true;
636               break;
637             }
638           n = n->symbol.same_comdat_group;
639         }
640       while (n != node);
641     }
642   return error_found;
643 }
644
645 /* Verify consistency of NODE.  */
646
647 DEBUG_FUNCTION void
648 verify_symtab_node (symtab_node node)
649 {
650   if (seen_error ())
651     return;
652
653   timevar_push (TV_CGRAPH_VERIFY);
654   if (symtab_function_p (node))
655     verify_cgraph_node (cgraph (node));
656   else
657     if (verify_symtab_base (node))
658       {
659         dump_symtab_node (stderr, node);
660         internal_error ("verify_symtab_node failed");
661       }
662   timevar_pop (TV_CGRAPH_VERIFY);
663 }
664
665 /* Verify symbol table for internal consistency.  */
666
667 DEBUG_FUNCTION void
668 verify_symtab (void)
669 {
670   symtab_node node;
671   FOR_EACH_SYMBOL (node)
672    verify_symtab_node (node);
673 }
674
675 /* Return true when RESOLUTION indicate that linker will use
676    the symbol from non-LTO object files.  */
677
678 bool
679 resolution_used_from_other_file_p (enum ld_plugin_symbol_resolution resolution)
680 {
681   return (resolution == LDPR_PREVAILING_DEF
682           || resolution == LDPR_PREEMPTED_REG
683           || resolution == LDPR_RESOLVED_EXEC
684           || resolution == LDPR_RESOLVED_DYN);
685 }
686
687 /* Return true when NODE is known to be used from other (non-LTO) object file.
688    Known only when doing LTO via linker plugin.  */
689
690 bool
691 symtab_used_from_object_file_p (symtab_node node)
692 {
693   if (!TREE_PUBLIC (node->symbol.decl) || DECL_EXTERNAL (node->symbol.decl))
694     return false;
695   if (resolution_used_from_other_file_p (node->symbol.resolution))
696     return true;
697   return false;
698 }
699
700 /* Make DECL local.  FIXME: We shouldn't need to mess with rtl this early,
701    but other code such as notice_global_symbol generates rtl.  */
702 void
703 symtab_make_decl_local (tree decl)
704 {
705   rtx rtl, symbol;
706
707   if (TREE_CODE (decl) == VAR_DECL)
708     DECL_COMMON (decl) = 0;
709   else gcc_assert (TREE_CODE (decl) == FUNCTION_DECL);
710
711   if (DECL_ONE_ONLY (decl) || DECL_COMDAT (decl))
712     {
713       /* It is possible that we are linking against library defining same COMDAT
714          function.  To avoid conflict we need to rename our local name of the
715          function just in the case WHOPR partitioning decide to make it hidden
716          to avoid cross partition references.  */
717       if (flag_wpa)
718         {
719           const char *old_name;
720           symtab_node node = symtab_get_node (decl);
721           old_name  = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
722           change_decl_assembler_name (decl,
723                                       clone_function_name (decl, "local"));
724           if (node->symbol.lto_file_data)
725             lto_record_renamed_decl (node->symbol.lto_file_data,
726                                      old_name,
727                                      IDENTIFIER_POINTER
728                                        (DECL_ASSEMBLER_NAME (decl)));
729         }
730       DECL_SECTION_NAME (decl) = 0;
731       DECL_COMDAT (decl) = 0;
732     }
733   DECL_COMDAT_GROUP (decl) = 0;
734   DECL_WEAK (decl) = 0;
735   DECL_EXTERNAL (decl) = 0;
736   TREE_PUBLIC (decl) = 0;
737   if (!DECL_RTL_SET_P (decl))
738     return;
739
740   /* Update rtl flags.  */
741   make_decl_rtl (decl);
742
743   rtl = DECL_RTL (decl);
744   if (!MEM_P (rtl))
745     return;
746
747   symbol = XEXP (rtl, 0);
748   if (GET_CODE (symbol) != SYMBOL_REF)
749     return;
750
751   SYMBOL_REF_WEAK (symbol) = DECL_WEAK (decl);
752 }
753 #include "gt-symtab.h"