* Add TARGET_CANNOT_SUBSTITUTE_MEM_EQUIV target macro.
[official-gcc.git] / gcc / lto / lto-symtab.c
blobf5d82a74b082fdecea3b0b092d8a9733a0917b76
1 /* LTO symbol table.
2 Copyright (C) 2009-2014 Free Software Foundation, Inc.
3 Contributed by CodeSourcery, Inc.
5 This file is part of GCC.
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.
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.
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/>. */
21 #include "config.h"
22 #include "system.h"
23 #include "coretypes.h"
24 #include "diagnostic-core.h"
25 #include "tree.h"
26 #include "predict.h"
27 #include "vec.h"
28 #include "hashtab.h"
29 #include "hash-set.h"
30 #include "machmode.h"
31 #include "tm.h"
32 #include "hard-reg-set.h"
33 #include "input.h"
34 #include "function.h"
35 #include "basic-block.h"
36 #include "tree-ssa-alias.h"
37 #include "internal-fn.h"
38 #include "gimple-expr.h"
39 #include "is-a.h"
40 #include "gimple.h"
41 #include "plugin-api.h"
42 #include "hash-map.h"
43 #include "ipa-ref.h"
44 #include "cgraph.h"
45 #include "lto-streamer.h"
46 #include "ipa-utils.h"
47 #include "alloc-pool.h"
48 #include "ipa-prop.h"
49 #include "ipa-inline.h"
50 #include "builtins.h"
52 /* Replace the cgraph node NODE with PREVAILING_NODE in the cgraph, merging
53 all edges and removing the old node. */
55 static void
56 lto_cgraph_replace_node (struct cgraph_node *node,
57 struct cgraph_node *prevailing_node)
59 struct cgraph_edge *e, *next;
60 bool compatible_p;
62 if (symtab->dump_file)
64 fprintf (symtab->dump_file, "Replacing cgraph node %s/%i by %s/%i"
65 " for symbol %s\n",
66 node->name (), node->order,
67 prevailing_node->name (),
68 prevailing_node->order,
69 IDENTIFIER_POINTER ((*targetm.asm_out.mangle_assembler_name)
70 (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (node->decl)))));
73 /* Merge node flags. */
74 if (node->force_output)
75 prevailing_node->mark_force_output ();
76 if (node->forced_by_abi)
77 prevailing_node->forced_by_abi = true;
78 if (node->address_taken)
80 gcc_assert (!prevailing_node->global.inlined_to);
81 prevailing_node->mark_address_taken ();
84 /* Redirect all incoming edges. */
85 compatible_p
86 = types_compatible_p (TREE_TYPE (TREE_TYPE (prevailing_node->decl)),
87 TREE_TYPE (TREE_TYPE (node->decl)));
88 for (e = node->callers; e; e = next)
90 next = e->next_caller;
91 e->redirect_callee (prevailing_node);
92 /* If there is a mismatch between the supposed callee return type and
93 the real one do not attempt to inline this function.
94 ??? We really need a way to match function signatures for ABI
95 compatibility and perform related promotions at inlining time. */
96 if (!compatible_p)
97 e->call_stmt_cannot_inline_p = 1;
99 /* Redirect incomming references. */
100 prevailing_node->clone_referring (node);
102 /* Fix instrumentation references. */
103 if (node->instrumented_version)
105 gcc_assert (node->instrumentation_clone
106 == prevailing_node->instrumentation_clone);
107 node->instrumented_version->instrumented_version = prevailing_node;
108 if (!prevailing_node->instrumented_version)
109 prevailing_node->instrumented_version = node->instrumented_version;
110 /* Need to reset node->instrumented_version to NULL,
111 otherwise node removal code would reset
112 node->instrumented_version->instrumented_version. */
113 node->instrumented_version = NULL;
116 ipa_merge_profiles (prevailing_node, node);
117 lto_free_function_in_decl_state_for_node (node);
119 if (node->decl != prevailing_node->decl)
120 node->release_body ();
122 /* Finally remove the replaced node. */
123 node->remove ();
126 /* Replace the cgraph node NODE with PREVAILING_NODE in the cgraph, merging
127 all edges and removing the old node. */
129 static void
130 lto_varpool_replace_node (varpool_node *vnode,
131 varpool_node *prevailing_node)
133 gcc_assert (!vnode->definition || prevailing_node->definition);
134 gcc_assert (!vnode->analyzed || prevailing_node->analyzed);
136 prevailing_node->clone_referring (vnode);
137 if (vnode->force_output)
138 prevailing_node->force_output = true;
139 if (vnode->forced_by_abi)
140 prevailing_node->forced_by_abi = true;
142 /* Be sure we can garbage collect the initializer. */
143 if (DECL_INITIAL (vnode->decl)
144 && vnode->decl != prevailing_node->decl)
145 DECL_INITIAL (vnode->decl) = error_mark_node;
147 /* Check and report ODR violations on virtual tables. */
148 if (DECL_VIRTUAL_P (vnode->decl) || DECL_VIRTUAL_P (prevailing_node->decl))
149 compare_virtual_tables (prevailing_node, vnode);
151 if (vnode->tls_model != prevailing_node->tls_model)
153 error_at (DECL_SOURCE_LOCATION (vnode->decl),
154 "%qD is defined as %s", vnode->decl, tls_model_names [vnode->tls_model]);
155 inform (DECL_SOURCE_LOCATION (prevailing_node->decl),
156 "previously defined here as %s",
157 tls_model_names [prevailing_node->tls_model]);
159 /* Finally remove the replaced node. */
160 vnode->remove ();
163 /* Merge two variable or function symbol table entries PREVAILING and ENTRY.
164 Return false if the symbols are not fully compatible and a diagnostic
165 should be emitted. */
167 static bool
168 lto_symtab_merge (symtab_node *prevailing, symtab_node *entry)
170 tree prevailing_decl = prevailing->decl;
171 tree decl = entry->decl;
172 tree prevailing_type, type;
174 if (prevailing_decl == decl)
175 return true;
177 /* Merge decl state in both directions, we may still end up using
178 the new decl. */
179 TREE_ADDRESSABLE (prevailing_decl) |= TREE_ADDRESSABLE (decl);
180 TREE_ADDRESSABLE (decl) |= TREE_ADDRESSABLE (prevailing_decl);
182 /* The linker may ask us to combine two incompatible symbols.
183 Detect this case and notify the caller of required diagnostics. */
185 if (TREE_CODE (decl) == FUNCTION_DECL)
187 if (!types_compatible_p (TREE_TYPE (prevailing_decl),
188 TREE_TYPE (decl)))
189 /* If we don't have a merged type yet...sigh. The linker
190 wouldn't complain if the types were mismatched, so we
191 probably shouldn't either. Just use the type from
192 whichever decl appears to be associated with the
193 definition. If for some odd reason neither decl is, the
194 older one wins. */
195 (void) 0;
197 return true;
200 /* Now we exclusively deal with VAR_DECLs. */
202 /* Sharing a global symbol is a strong hint that two types are
203 compatible. We could use this information to complete
204 incomplete pointed-to types more aggressively here, ignoring
205 mismatches in both field and tag names. It's difficult though
206 to guarantee that this does not have side-effects on merging
207 more compatible types from other translation units though. */
209 /* We can tolerate differences in type qualification, the
210 qualification of the prevailing definition will prevail.
211 ??? In principle we might want to only warn for structurally
212 incompatible types here, but unless we have protective measures
213 for TBAA in place that would hide useful information. */
214 prevailing_type = TYPE_MAIN_VARIANT (TREE_TYPE (prevailing_decl));
215 type = TYPE_MAIN_VARIANT (TREE_TYPE (decl));
217 if (!types_compatible_p (prevailing_type, type))
219 if (COMPLETE_TYPE_P (type))
220 return false;
222 /* If type is incomplete then avoid warnings in the cases
223 that TBAA handles just fine. */
225 if (TREE_CODE (prevailing_type) != TREE_CODE (type))
226 return false;
228 if (TREE_CODE (prevailing_type) == ARRAY_TYPE)
230 tree tem1 = TREE_TYPE (prevailing_type);
231 tree tem2 = TREE_TYPE (type);
232 while (TREE_CODE (tem1) == ARRAY_TYPE
233 && TREE_CODE (tem2) == ARRAY_TYPE)
235 tem1 = TREE_TYPE (tem1);
236 tem2 = TREE_TYPE (tem2);
239 if (TREE_CODE (tem1) != TREE_CODE (tem2))
240 return false;
242 if (!types_compatible_p (tem1, tem2))
243 return false;
246 /* Fallthru. Compatible enough. */
249 /* ??? We might want to emit a warning here if type qualification
250 differences were spotted. Do not do this unconditionally though. */
252 /* There is no point in comparing too many details of the decls here.
253 The type compatibility checks or the completing of types has properly
254 dealt with most issues. */
256 /* The following should all not invoke fatal errors as in non-LTO
257 mode the linker wouldn't complain either. Just emit warnings. */
259 /* Report a warning if user-specified alignments do not match. */
260 if ((DECL_USER_ALIGN (prevailing_decl) && DECL_USER_ALIGN (decl))
261 && DECL_ALIGN (prevailing_decl) < DECL_ALIGN (decl))
262 return false;
264 return true;
267 /* Return true if the symtab entry E can be replaced by another symtab
268 entry. */
270 static bool
271 lto_symtab_resolve_replaceable_p (symtab_node *e)
273 if (DECL_EXTERNAL (e->decl)
274 || DECL_COMDAT (e->decl)
275 || DECL_ONE_ONLY (e->decl)
276 || DECL_WEAK (e->decl))
277 return true;
279 if (TREE_CODE (e->decl) == VAR_DECL)
280 return (DECL_COMMON (e->decl)
281 || (!flag_no_common && !DECL_INITIAL (e->decl)));
283 return false;
286 /* Return true, if the symbol E should be resolved by lto-symtab.
287 Those are all external symbols and all real symbols that are not static (we
288 handle renaming of static later in partitioning). */
290 static bool
291 lto_symtab_symbol_p (symtab_node *e)
293 if (!TREE_PUBLIC (e->decl) && !DECL_EXTERNAL (e->decl))
294 return false;
295 return e->real_symbol_p ();
298 /* Return true if the symtab entry E can be the prevailing one. */
300 static bool
301 lto_symtab_resolve_can_prevail_p (symtab_node *e)
303 if (!lto_symtab_symbol_p (e))
304 return false;
306 /* The C++ frontend ends up neither setting TREE_STATIC nor
307 DECL_EXTERNAL on virtual methods but only TREE_PUBLIC.
308 So do not reject !TREE_STATIC here but only DECL_EXTERNAL. */
309 if (DECL_EXTERNAL (e->decl))
310 return false;
312 return e->definition;
315 /* Resolve the symbol with the candidates in the chain *SLOT and store
316 their resolutions. */
318 static symtab_node *
319 lto_symtab_resolve_symbols (symtab_node *first)
321 symtab_node *e;
322 symtab_node *prevailing = NULL;
324 /* Always set e->node so that edges are updated to reflect decl merging. */
325 for (e = first; e; e = e->next_sharing_asm_name)
326 if (lto_symtab_symbol_p (e)
327 && (e->resolution == LDPR_PREVAILING_DEF_IRONLY
328 || e->resolution == LDPR_PREVAILING_DEF_IRONLY_EXP
329 || e->resolution == LDPR_PREVAILING_DEF))
331 prevailing = e;
332 break;
335 /* If the chain is already resolved there is nothing else to do. */
336 if (prevailing)
338 /* Assert it's the only one. */
339 for (e = prevailing->next_sharing_asm_name; e; e = e->next_sharing_asm_name)
340 if (lto_symtab_symbol_p (e)
341 && (e->resolution == LDPR_PREVAILING_DEF_IRONLY
342 || e->resolution == LDPR_PREVAILING_DEF_IRONLY_EXP
343 || e->resolution == LDPR_PREVAILING_DEF))
344 fatal_error ("multiple prevailing defs for %qE",
345 DECL_NAME (prevailing->decl));
346 return prevailing;
349 /* Find the single non-replaceable prevailing symbol and
350 diagnose ODR violations. */
351 for (e = first; e; e = e->next_sharing_asm_name)
353 if (!lto_symtab_resolve_can_prevail_p (e))
354 continue;
356 /* If we have a non-replaceable definition it prevails. */
357 if (!lto_symtab_resolve_replaceable_p (e))
359 if (prevailing)
361 error_at (DECL_SOURCE_LOCATION (e->decl),
362 "%qD has already been defined", e->decl);
363 inform (DECL_SOURCE_LOCATION (prevailing->decl),
364 "previously defined here");
366 prevailing = e;
369 if (prevailing)
370 return prevailing;
372 /* Do a second round choosing one from the replaceable prevailing decls. */
373 for (e = first; e; e = e->next_sharing_asm_name)
375 if (!lto_symtab_resolve_can_prevail_p (e))
376 continue;
378 /* Choose the first function that can prevail as prevailing. */
379 if (TREE_CODE (e->decl) == FUNCTION_DECL)
381 prevailing = e;
382 break;
385 /* From variables that can prevail choose the largest one. */
386 if (!prevailing
387 || tree_int_cst_lt (DECL_SIZE (prevailing->decl),
388 DECL_SIZE (e->decl))
389 /* When variables are equivalent try to chose one that has useful
390 DECL_INITIAL. This makes sense for keyed vtables that are
391 DECL_EXTERNAL but initialized. In units that do not need them
392 we replace the initializer by error_mark_node to conserve
393 memory.
395 We know that the vtable is keyed outside the LTO unit - otherwise
396 the keyed instance would prevail. We still can preserve useful
397 info in the initializer. */
398 || (DECL_SIZE (prevailing->decl) == DECL_SIZE (e->decl)
399 && (DECL_INITIAL (e->decl)
400 && DECL_INITIAL (e->decl) != error_mark_node)
401 && (!DECL_INITIAL (prevailing->decl)
402 || DECL_INITIAL (prevailing->decl) == error_mark_node)))
403 prevailing = e;
406 return prevailing;
409 /* Merge all decls in the symbol table chain to the prevailing decl and
410 issue diagnostics about type mismatches. If DIAGNOSED_P is true
411 do not issue further diagnostics.*/
413 static void
414 lto_symtab_merge_decls_2 (symtab_node *first, bool diagnosed_p)
416 symtab_node *prevailing;
417 symtab_node *e;
418 vec<tree> mismatches = vNULL;
419 unsigned i;
420 tree decl;
422 /* Nothing to do for a single entry. */
423 prevailing = first;
424 if (!prevailing->next_sharing_asm_name)
425 return;
427 /* Try to merge each entry with the prevailing one. */
428 for (e = prevailing->next_sharing_asm_name;
429 e; e = e->next_sharing_asm_name)
430 if (TREE_PUBLIC (e->decl))
432 if (!lto_symtab_merge (prevailing, e)
433 && !diagnosed_p)
434 mismatches.safe_push (e->decl);
436 if (mismatches.is_empty ())
437 return;
439 /* Diagnose all mismatched re-declarations. */
440 FOR_EACH_VEC_ELT (mismatches, i, decl)
442 if (!types_compatible_p (TREE_TYPE (prevailing->decl),
443 TREE_TYPE (decl)))
444 diagnosed_p |= warning_at (DECL_SOURCE_LOCATION (decl), 0,
445 "type of %qD does not match original "
446 "declaration", decl);
448 else if ((DECL_USER_ALIGN (prevailing->decl)
449 && DECL_USER_ALIGN (decl))
450 && DECL_ALIGN (prevailing->decl) < DECL_ALIGN (decl))
452 diagnosed_p |= warning_at (DECL_SOURCE_LOCATION (decl), 0,
453 "alignment of %qD is bigger than "
454 "original declaration", decl);
457 if (diagnosed_p)
458 inform (DECL_SOURCE_LOCATION (prevailing->decl),
459 "previously declared here");
461 mismatches.release ();
464 /* Helper to process the decl chain for the symbol table entry *SLOT. */
466 static void
467 lto_symtab_merge_decls_1 (symtab_node *first)
469 symtab_node *e;
470 symtab_node *prevailing;
471 bool diagnosed_p = false;
473 if (symtab->dump_file)
475 fprintf (symtab->dump_file, "Merging nodes for %s. Candidates:\n",
476 first->asm_name ());
477 for (e = first; e; e = e->next_sharing_asm_name)
478 if (TREE_PUBLIC (e->decl))
479 e->dump (symtab->dump_file);
482 /* Compute the symbol resolutions. This is a no-op when using the
483 linker plugin and resolution was decided by the linker. */
484 prevailing = lto_symtab_resolve_symbols (first);
486 /* If there's not a prevailing symbol yet it's an external reference.
487 Happens a lot during ltrans. Choose the first symbol with a
488 cgraph or a varpool node. */
489 if (!prevailing)
491 for (prevailing = first;
492 prevailing; prevailing = prevailing->next_sharing_asm_name)
493 if (lto_symtab_symbol_p (prevailing))
494 break;
495 if (!prevailing)
496 return;
497 /* For variables chose with a priority variant with vnode
498 attached (i.e. from unit where external declaration of
499 variable is actually used).
500 When there are multiple variants, chose one with size.
501 This is needed for C++ typeinfos, for example in
502 lto/20081204-1 there are typeifos in both units, just
503 one of them do have size. */
504 if (TREE_CODE (prevailing->decl) == VAR_DECL)
506 for (e = prevailing->next_sharing_asm_name;
507 e; e = e->next_sharing_asm_name)
508 if (!COMPLETE_TYPE_P (TREE_TYPE (prevailing->decl))
509 && COMPLETE_TYPE_P (TREE_TYPE (e->decl))
510 && lto_symtab_symbol_p (e))
511 prevailing = e;
513 /* For variables prefer the non-builtin if one is available. */
514 else if (TREE_CODE (prevailing->decl) == FUNCTION_DECL)
516 for (e = first; e; e = e->next_sharing_asm_name)
517 if (TREE_CODE (e->decl) == FUNCTION_DECL
518 && !DECL_BUILT_IN (e->decl)
519 && lto_symtab_symbol_p (e))
521 prevailing = e;
522 break;
527 symtab->symtab_prevail_in_asm_name_hash (prevailing);
529 /* Diagnose mismatched objects. */
530 for (e = prevailing->next_sharing_asm_name;
531 e; e = e->next_sharing_asm_name)
533 if (TREE_CODE (prevailing->decl)
534 == TREE_CODE (e->decl))
535 continue;
536 if (!lto_symtab_symbol_p (e))
537 continue;
539 switch (TREE_CODE (prevailing->decl))
541 case VAR_DECL:
542 gcc_assert (TREE_CODE (e->decl) == FUNCTION_DECL);
543 error_at (DECL_SOURCE_LOCATION (e->decl),
544 "variable %qD redeclared as function",
545 prevailing->decl);
546 break;
548 case FUNCTION_DECL:
549 gcc_assert (TREE_CODE (e->decl) == VAR_DECL);
550 error_at (DECL_SOURCE_LOCATION (e->decl),
551 "function %qD redeclared as variable",
552 prevailing->decl);
553 break;
555 default:
556 gcc_unreachable ();
559 diagnosed_p = true;
561 if (diagnosed_p)
562 inform (DECL_SOURCE_LOCATION (prevailing->decl),
563 "previously declared here");
565 /* Merge the chain to the single prevailing decl and diagnose
566 mismatches. */
567 lto_symtab_merge_decls_2 (prevailing, diagnosed_p);
569 if (symtab->dump_file)
571 fprintf (symtab->dump_file, "After resolution:\n");
572 for (e = prevailing; e; e = e->next_sharing_asm_name)
573 e->dump (symtab->dump_file);
577 /* Resolve and merge all symbol table chains to a prevailing decl. */
579 void
580 lto_symtab_merge_decls (void)
582 symtab_node *node;
584 /* Populate assembler name hash. */
585 symtab->symtab_initialize_asm_name_hash ();
587 FOR_EACH_SYMBOL (node)
588 if (!node->previous_sharing_asm_name
589 && node->next_sharing_asm_name)
590 lto_symtab_merge_decls_1 (node);
593 /* Helper to process the decl chain for the symbol table entry *SLOT. */
595 static void
596 lto_symtab_merge_symbols_1 (symtab_node *prevailing)
598 symtab_node *e;
599 symtab_node *next;
601 /* Replace the cgraph node of each entry with the prevailing one. */
602 for (e = prevailing->next_sharing_asm_name; e;
603 e = next)
605 next = e->next_sharing_asm_name;
607 if (!lto_symtab_symbol_p (e))
608 continue;
609 cgraph_node *ce = dyn_cast <cgraph_node *> (e);
610 if (ce && !DECL_BUILT_IN (e->decl))
611 lto_cgraph_replace_node (ce, dyn_cast<cgraph_node *> (prevailing));
612 if (varpool_node *ve = dyn_cast <varpool_node *> (e))
613 lto_varpool_replace_node (ve, dyn_cast<varpool_node *> (prevailing));
616 return;
619 /* Merge cgraph nodes according to the symbol merging done by
620 lto_symtab_merge_decls. */
622 void
623 lto_symtab_merge_symbols (void)
625 symtab_node *node;
627 if (!flag_ltrans)
629 symtab->symtab_initialize_asm_name_hash ();
631 /* Do the actual merging.
632 At this point we invalidate hash translating decls into symtab nodes
633 because after removing one of duplicate decls the hash is not correcly
634 updated to the ohter dupliate. */
635 FOR_EACH_SYMBOL (node)
636 if (lto_symtab_symbol_p (node)
637 && node->next_sharing_asm_name
638 && !node->previous_sharing_asm_name)
639 lto_symtab_merge_symbols_1 (node);
641 /* Resolve weakref aliases whose target are now in the compilation unit.
642 also re-populate the hash translating decls into symtab nodes*/
643 FOR_EACH_SYMBOL (node)
645 cgraph_node *cnode, *cnode2;
646 varpool_node *vnode;
647 symtab_node *node2;
649 if (!node->analyzed && node->alias_target)
651 symtab_node *tgt = symtab_node::get_for_asmname (node->alias_target);
652 gcc_assert (node->weakref);
653 if (tgt)
654 node->resolve_alias (tgt);
656 node->aux = NULL;
658 if (!(cnode = dyn_cast <cgraph_node *> (node))
659 || !cnode->clone_of
660 || cnode->clone_of->decl != cnode->decl)
662 /* Builtins are not merged via decl merging. It is however
663 possible that tree merging unified the declaration. We
664 do not want duplicate entries in symbol table. */
665 if (cnode && DECL_BUILT_IN (node->decl)
666 && (cnode2 = cgraph_node::get (node->decl))
667 && cnode2 != cnode)
668 lto_cgraph_replace_node (cnode2, cnode);
670 /* The user defined assembler variables are also not unified by their
671 symbol name (since it is irrelevant), but we need to unify symbol
672 nodes if tree merging occured. */
673 if ((vnode = dyn_cast <varpool_node *> (node))
674 && DECL_HARD_REGISTER (vnode->decl)
675 && (node2 = symtab_node::get (vnode->decl))
676 && node2 != node)
677 lto_varpool_replace_node (dyn_cast <varpool_node *> (node2),
678 vnode);
681 /* Abstract functions may have duplicated cgraph nodes attached;
682 remove them. */
683 else if (cnode && DECL_ABSTRACT_P (cnode->decl)
684 && (cnode2 = cgraph_node::get (node->decl))
685 && cnode2 != cnode)
686 cnode2->remove ();
688 node->decl->decl_with_vis.symtab_node = node;
694 /* Given the decl DECL, return the prevailing decl with the same name. */
696 tree
697 lto_symtab_prevailing_decl (tree decl)
699 symtab_node *ret;
701 /* Builtins and local symbols are their own prevailing decl. */
702 if ((!TREE_PUBLIC (decl) && !DECL_EXTERNAL (decl)) || is_builtin_fn (decl))
703 return decl;
705 /* DECL_ABSTRACT_Ps are their own prevailing decl. */
706 if (TREE_CODE (decl) == FUNCTION_DECL && DECL_ABSTRACT_P (decl))
707 return decl;
709 /* Likewise builtins are their own prevailing decl. This preserves
710 non-builtin vs. builtin uses from compile-time. */
711 if (TREE_CODE (decl) == FUNCTION_DECL && DECL_BUILT_IN (decl))
712 return decl;
714 /* Ensure DECL_ASSEMBLER_NAME will not set assembler name. */
715 gcc_assert (DECL_ASSEMBLER_NAME_SET_P (decl));
717 /* Walk through the list of candidates and return the one we merged to. */
718 ret = symtab_node::get_for_asmname (DECL_ASSEMBLER_NAME (decl));
719 if (!ret)
720 return decl;
722 return ret->decl;