]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/symtab.c
2012-09-19 Richard Guenther <rguenther@suse.de>
[thirdparty/gcc.git] / gcc / symtab.c
CommitLineData
0704fb2e 1/* Symbol table.
2 Copyright (C) 2012 Free Software Foundation, Inc.
3 Contributed by Jan Hubicka
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify it under
8the terms of the GNU General Public License as published by the Free
9Software Foundation; either version 3, or (at your option) any later
10version.
11
12GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13WARRANTY; without even the implied warranty of MERCHANTABILITY or
14FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15for more details.
16
17You should have received a copy of the GNU General Public License
18along 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"
18841b0c 27#include "langhooks.h"
0704fb2e 28#include "hashtab.h"
cfbe30aa 29#include "ggc.h"
0704fb2e 30#include "cgraph.h"
cfbe30aa 31#include "diagnostic.h"
3e7775f6 32#include "timevar.h"
cf951b1a 33#include "lto-streamer.h"
34#include "rtl.h"
35
36const 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};
cfbe30aa 49
50/* Hash table used to convert declarations into nodes. */
51static GTY((param_is (union symtab_node_def))) htab_t symtab_hash;
52/* Hash table used to convert assembler names into nodes. */
53static GTY((param_is (union symtab_node_def))) htab_t assembler_name_hash;
0704fb2e 54
55/* Linked list of symbol table nodes. */
56symtab_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. */
61int symtab_order;
62
cfbe30aa 63/* Returns a hash code for P. */
64
65static hashval_t
66hash_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
75static int
76eq_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
85static hashval_t
86hash_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
94static int
95eq_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
104static void
105insert_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
128static void
129unlink_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
0704fb2e 158/* Add node into symbol table. This function is not used directly, but via
159 cgraph/varpool node creation routines. */
160
161void
162symtab_register_node (symtab_node node)
163{
cfbe30aa 164 struct symtab_node_base key;
165 symtab_node *slot;
166
0704fb2e 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
cfbe30aa 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
ad0fe105 180 ipa_empty_ref_list (&node->symbol.ref_list);
cfbe30aa 181
0704fb2e 182 node->symbol.order = symtab_order++;
183
ad0fe105 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);
0704fb2e 187}
188
cfbe30aa 189/* Make NODE to be the one symtab hash is pointing to. Used when reshaping tree
190 of inline clones. */
191
192void
193symtab_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
0704fb2e 205/* Remove node from symbol table. This function is not used directly, but via
206 cgraph/varpool node removal routines. */
207
208void
209symtab_unregister_node (symtab_node node)
210{
cfbe30aa 211 void **slot;
0704fb2e 212 ipa_remove_all_references (&node->symbol.ref_list);
04ec15fa 213 ipa_remove_all_referring (&node->symbol.ref_list);
0704fb2e 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;
cfbe30aa 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
255symtab_node
256symtab_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;
0704fb2e 277}
278
279/* Remove symtab NODE from the symbol table. */
280
281void
282symtab_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}
cfbe30aa 289
290/* Return the cgraph node that has ASMNAME for its DECL_ASSEMBLER_NAME.
291 Return NULL if there's no such node. */
292
293symtab_node
294symtab_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
322void
323change_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
cf951b1a 356/* Add NEW_ to the same comdat group that OLD is in. */
357
358void
359symtab_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
383void
384symtab_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
18841b0c 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
403const char *
404symtab_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
413const char *
414symtab_node_name (symtab_node node)
415{
416 return lang_hooks.decl_printable_name (node->symbol.decl, 2);
417}
418
419static const char * const symtab_type_names[] = {"symbol", "function", "variable"};
420
421/* Dump base fields of symtab nodes. Not to be used directly. */
422
423void
424dump_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");
8efa224a 442 if (node->symbol.force_output)
443 fprintf (f, " force_output");
18841b0c 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",
5300ccdd 468 TREE_STRING_POINTER (DECL_SECTION_NAME (node->symbol.decl)));
18841b0c 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");
9a2639fc 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 }
18841b0c 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",
cfacc26f 493 node->symbol.next_sharing_asm_name->symbol.order);
18841b0c 494 if (node->symbol.previous_sharing_asm_name)
495 fprintf (f, " previous sharing asm name: %i\n",
cfacc26f 496 node->symbol.previous_sharing_asm_name->symbol.order);
18841b0c 497
498 if (node->symbol.address_taken)
cfacc26f 499 fprintf (f, " Address is taken.\n");
ff2a5ada 500 if (node->symbol.aux)
501 {
502 fprintf (f, " Aux:");
503 dump_addr (f, " @", (void *)node->symbol.aux);
504 }
18841b0c 505
506 fprintf (f, " References: ");
507 ipa_dump_references (f, &node->symbol.ref_list);
04ec15fa 508 fprintf (f, " Referring: ");
509 ipa_dump_referring (f, &node->symbol.ref_list);
18841b0c 510}
511
512/* Dump symtab node. */
513
514void
515dump_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
525void
526dump_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
536DEBUG_FUNCTION void
537debug_symtab_node (symtab_node node)
538{
539 dump_symtab_node (stderr, node);
540}
541
542/* Dump symbol table to stderr. */
543
544DEBUG_FUNCTION void
545debug_symtab (void)
546{
547 dump_symtab (stderr);
548}
549
3e7775f6 550/* Verify common part of symtab nodes. */
551
552DEBUG_FUNCTION bool
553verify_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
647DEBUG_FUNCTION void
648verify_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
667DEBUG_FUNCTION void
668verify_symtab (void)
669{
670 symtab_node node;
671 FOR_EACH_SYMBOL (node)
672 verify_symtab_node (node);
673}
674
cf951b1a 675/* Return true when RESOLUTION indicate that linker will use
676 the symbol from non-LTO object files. */
677
678bool
679resolution_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
690bool
691symtab_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. */
702void
703symtab_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;
b6f96313 737 DECL_VISIBILITY_SPECIFIED (decl) = 0;
738 DECL_VISIBILITY (decl) = VISIBILITY_DEFAULT;
cf951b1a 739 if (!DECL_RTL_SET_P (decl))
740 return;
741
742 /* Update rtl flags. */
743 make_decl_rtl (decl);
744
745 rtl = DECL_RTL (decl);
746 if (!MEM_P (rtl))
747 return;
748
749 symbol = XEXP (rtl, 0);
750 if (GET_CODE (symbol) != SYMBOL_REF)
751 return;
752
753 SYMBOL_REF_WEAK (symbol) = DECL_WEAK (decl);
754}
cfbe30aa 755#include "gt-symtab.h"