llvm.org GIT mirror llvm / 32811be
Change the `linker_private_weak_def_auto' linkage to `linkonce_odr_auto_hide' to make it more consistent with its intended semantics. The `linker_private_weak_def_auto' linkage type was meant to automatically hide globals which never had their addresses taken. It has nothing to do with the `linker_private' linkage type, which outputs the symbols with a `l' (ell) prefix among other things. The intended semantic is more like the `linkonce_odr' linkage type. Change the name of the linkage type to `linkonce_odr_auto_hide'. And therefore changing the semantics so that it produces the correct output for the linker. Note: The old linkage name `linker_private_weak_def_auto' will still parse but is not a synonym for `linkonce_odr_auto_hide'. This should be removed in 4.0. <rdar://problem/11754934> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162114 91177308-0d34-0410-b5e6-96231b3b80d8 Bill Wendling 8 years ago
17 changed file(s) with 59 addition(s) and 62 deletion(s). Raw diff Collapse all Expand all
2424
  • 'private' Linkage
  • 2525
  • 'linker_private' Linkage
  • 2626
  • 'linker_private_weak' Linkage
  • 27
  • 'linker_private_weak_def_auto' Linkage
  • 2827
  • 'internal' Linkage
  • 2928
  • 'available_externally' Linkage
  • 3029
  • 'linkonce' Linkage
  • 3332
  • 'appending' Linkage
  • 3433
  • 'extern_weak' Linkage
  • 3534
  • 'linkonce_odr' Linkage
  • 35
  • 'linkonce_odr_auto_hide' Linkage
  • 3636
  • 'weak_odr' Linkage
  • 3737
  • 'external' Linkage
  • 3838
  • 'dllimport' Linkage
  • 575575 linker. The symbols are removed by the linker from the final linked image
    576576 (executable or dynamic library).
    577577
    578
    linker_private_weak_def_auto
    579
    Similar to "linker_private_weak", but it's known that the address
    580 of the object is not taken. For instance, functions that had an inline
    581 definition, but the compiler decided not to inline it. Note,
    582 unlike linker_private and linker_private_weak,
    583 linker_private_weak_def_auto may have only default
    584 visibility. The symbols are removed by the linker from the final linked
    585 image (executable or dynamic library).
    586
    587578
    internal
    588579
    Similar to private, but the value shows as a local symbol
    589580 (STB_LOCAL in the case of ELF) in the object file. This
    651642 and weak_odr linkage types to indicate that the global will only
    652643 be merged with equivalent globals. These linkage types are otherwise the
    653644 same as their non-odr versions.
    645
    646
    linkonce_odr_auto_hide
    647
    Similar to "linkonce_odr", but nothing in the translation unit
    648 takes the address of this definition. For instance, functions that had an
    649 inline definition, but the compiler decided not to inline it.
    650 linkonce_odr_auto_hide may have only default visibility.
    651 The symbols are removed by the linker from the final linked image
    652 (executable or dynamic library).
    654653
    655654
    external
    656655
    If none of the above identifiers are used, the global is externally
    3333 AvailableExternallyLinkage, ///< Available for inspection, not emission.
    3434 LinkOnceAnyLinkage, ///< Keep one copy of function when linking (inline)
    3535 LinkOnceODRLinkage, ///< Same, but only replaced by something equivalent.
    36 LinkOnceODRAutoHideLinkage, ///< Like LinkOnceODRLinkage but addr not taken.
    3637 WeakAnyLinkage, ///< Keep one copy of named function when linking (weak)
    3738 WeakODRLinkage, ///< Same, but only replaced by something equivalent.
    3839 AppendingLinkage, ///< Special purpose, only applies to global arrays
    4041 PrivateLinkage, ///< Like Internal, but omit from symbol table.
    4142 LinkerPrivateLinkage, ///< Like Private, but linker removes.
    4243 LinkerPrivateWeakLinkage, ///< Like LinkerPrivate, but weak.
    43 LinkerPrivateWeakDefAutoLinkage, ///< Like LinkerPrivateWeak, but possibly
    44 /// hidden.
    4544 DLLImportLinkage, ///< Function to be imported from DLL
    4645 DLLExportLinkage, ///< Function to be accessible from DLL.
    4746 ExternalWeakLinkage,///< ExternalWeak linkage description.
    122121 return Linkage == AvailableExternallyLinkage;
    123122 }
    124123 static bool isLinkOnceLinkage(LinkageTypes Linkage) {
    125 return Linkage == LinkOnceAnyLinkage || Linkage == LinkOnceODRLinkage;
    124 return Linkage == LinkOnceAnyLinkage ||
    125 Linkage == LinkOnceODRLinkage ||
    126 Linkage == LinkOnceODRAutoHideLinkage;
    127 }
    128 static bool isLinkOnceODRAutoHideLinkage(LinkageTypes Linkage) {
    129 return Linkage == LinkOnceODRAutoHideLinkage;
    126130 }
    127131 static bool isWeakLinkage(LinkageTypes Linkage) {
    128132 return Linkage == WeakAnyLinkage || Linkage == WeakODRLinkage;
    142146 static bool isLinkerPrivateWeakLinkage(LinkageTypes Linkage) {
    143147 return Linkage == LinkerPrivateWeakLinkage;
    144148 }
    145 static bool isLinkerPrivateWeakDefAutoLinkage(LinkageTypes Linkage) {
    146 return Linkage == LinkerPrivateWeakDefAutoLinkage;
    147 }
    148149 static bool isLocalLinkage(LinkageTypes Linkage) {
    149150 return isInternalLinkage(Linkage) || isPrivateLinkage(Linkage) ||
    150 isLinkerPrivateLinkage(Linkage) || isLinkerPrivateWeakLinkage(Linkage) ||
    151 isLinkerPrivateWeakDefAutoLinkage(Linkage);
    151 isLinkerPrivateLinkage(Linkage) || isLinkerPrivateWeakLinkage(Linkage);
    152152 }
    153153 static bool isDLLImportLinkage(LinkageTypes Linkage) {
    154154 return Linkage == DLLImportLinkage;
    177177 Linkage == LinkOnceAnyLinkage ||
    178178 Linkage == CommonLinkage ||
    179179 Linkage == ExternalWeakLinkage ||
    180 Linkage == LinkerPrivateWeakLinkage ||
    181 Linkage == LinkerPrivateWeakDefAutoLinkage;
    180 Linkage == LinkerPrivateWeakLinkage;
    182181 }
    183182
    184183 /// isWeakForLinker - Whether the definition of this global may be replaced at
    191190 Linkage == WeakODRLinkage ||
    192191 Linkage == LinkOnceAnyLinkage ||
    193192 Linkage == LinkOnceODRLinkage ||
    193 Linkage == LinkOnceODRAutoHideLinkage ||
    194194 Linkage == CommonLinkage ||
    195195 Linkage == ExternalWeakLinkage ||
    196 Linkage == LinkerPrivateWeakLinkage ||
    197 Linkage == LinkerPrivateWeakDefAutoLinkage;
    196 Linkage == LinkerPrivateWeakLinkage;
    198197 }
    199198
    200199 bool hasExternalLinkage() const { return isExternalLinkage(Linkage); }
    203202 }
    204203 bool hasLinkOnceLinkage() const {
    205204 return isLinkOnceLinkage(Linkage);
    205 }
    206 bool hasLinkOnceODRAutoHideLinkage() const {
    207 return isLinkOnceODRAutoHideLinkage(Linkage);
    206208 }
    207209 bool hasWeakLinkage() const {
    208210 return isWeakLinkage(Linkage);
    214216 bool hasLinkerPrivateWeakLinkage() const {
    215217 return isLinkerPrivateWeakLinkage(Linkage);
    216218 }
    217 bool hasLinkerPrivateWeakDefAutoLinkage() const {
    218 return isLinkerPrivateWeakDefAutoLinkage(Linkage);
    219 }
    220219 bool hasLocalLinkage() const { return isLocalLinkage(Linkage); }
    221220 bool hasDLLImportLinkage() const { return isDLLImportLinkage(Linkage); }
    222221 bool hasDLLExportLinkage() const { return isDLLExportLinkage(Linkage); }
    281281 LLVMLinkOnceAnyLinkage, /**< Keep one copy of function when linking (inline)*/
    282282 LLVMLinkOnceODRLinkage, /**< Same, but only replaced by something
    283283 equivalent. */
    284 LLVMLinkOnceODRAutoHideLinkage, /**< Like LinkOnceODR, but possibly hidden. */
    284285 LLVMWeakAnyLinkage, /**< Keep one copy of function when linking (weak) */
    285286 LLVMWeakODRLinkage, /**< Same, but only replaced by something
    286287 equivalent. */
    294295 LLVMGhostLinkage, /**< Obsolete */
    295296 LLVMCommonLinkage, /**< Tentative definitions */
    296297 LLVMLinkerPrivateLinkage, /**< Like Private, but linker removes. */
    297 LLVMLinkerPrivateWeakLinkage, /**< Like LinkerPrivate, but is weak. */
    298 LLVMLinkerPrivateWeakDefAutoLinkage /**< Like LinkerPrivateWeak, but possibly
    299 hidden. */
    298 LLVMLinkerPrivateWeakLinkage /**< Like LinkerPrivate, but is weak. */
    300299 } LLVMLinkage;
    301300
    302301 typedef enum {
    455455 KEYWORD(private);
    456456 KEYWORD(linker_private);
    457457 KEYWORD(linker_private_weak);
    458 KEYWORD(linker_private_weak_def_auto);
    458 KEYWORD(linker_private_weak_def_auto); // FIXME: For backwards compatibility.
    459459 KEYWORD(internal);
    460460 KEYWORD(available_externally);
    461461 KEYWORD(linkonce);
    462462 KEYWORD(linkonce_odr);
    463 KEYWORD(linkonce_odr_auto_hide);
    463464 KEYWORD(weak);
    464465 KEYWORD(weak_odr);
    465466 KEYWORD(appending);
    183183 case lltok::kw_private: // OptionalLinkage
    184184 case lltok::kw_linker_private: // OptionalLinkage
    185185 case lltok::kw_linker_private_weak: // OptionalLinkage
    186 case lltok::kw_linker_private_weak_def_auto: // OptionalLinkage
    186 case lltok::kw_linker_private_weak_def_auto: // FIXME: backwards compat.
    187187 case lltok::kw_internal: // OptionalLinkage
    188188 case lltok::kw_weak: // OptionalLinkage
    189189 case lltok::kw_weak_odr: // OptionalLinkage
    190190 case lltok::kw_linkonce: // OptionalLinkage
    191191 case lltok::kw_linkonce_odr: // OptionalLinkage
    192 case lltok::kw_linkonce_odr_auto_hide: // OptionalLinkage
    192193 case lltok::kw_appending: // OptionalLinkage
    193194 case lltok::kw_dllexport: // OptionalLinkage
    194195 case lltok::kw_common: // OptionalLinkage
    575576 Linkage != GlobalValue::InternalLinkage &&
    576577 Linkage != GlobalValue::PrivateLinkage &&
    577578 Linkage != GlobalValue::LinkerPrivateLinkage &&
    578 Linkage != GlobalValue::LinkerPrivateWeakLinkage &&
    579 Linkage != GlobalValue::LinkerPrivateWeakDefAutoLinkage)
    579 Linkage != GlobalValue::LinkerPrivateWeakLinkage)
    580580 return Error(LinkageLoc, "invalid linkage type for alias");
    581581
    582582 Constant *Aliasee;
    989989 /// ::= 'private'
    990990 /// ::= 'linker_private'
    991991 /// ::= 'linker_private_weak'
    992 /// ::= 'linker_private_weak_def_auto'
    993992 /// ::= 'internal'
    994993 /// ::= 'weak'
    995994 /// ::= 'weak_odr'
    996995 /// ::= 'linkonce'
    997996 /// ::= 'linkonce_odr'
    997 /// ::= 'linkonce_odr_auto_hide'
    998998 /// ::= 'available_externally'
    999999 /// ::= 'appending'
    10001000 /// ::= 'dllexport'
    10111011 case lltok::kw_linker_private_weak:
    10121012 Res = GlobalValue::LinkerPrivateWeakLinkage;
    10131013 break;
    1014 case lltok::kw_linker_private_weak_def_auto:
    1015 Res = GlobalValue::LinkerPrivateWeakDefAutoLinkage;
    1016 break;
    10171014 case lltok::kw_internal: Res = GlobalValue::InternalLinkage; break;
    10181015 case lltok::kw_weak: Res = GlobalValue::WeakAnyLinkage; break;
    10191016 case lltok::kw_weak_odr: Res = GlobalValue::WeakODRLinkage; break;
    10201017 case lltok::kw_linkonce: Res = GlobalValue::LinkOnceAnyLinkage; break;
    10211018 case lltok::kw_linkonce_odr: Res = GlobalValue::LinkOnceODRLinkage; break;
    1019 case lltok::kw_linkonce_odr_auto_hide:
    1020 case lltok::kw_linker_private_weak_def_auto: // FIXME: For backwards compat.
    1021 Res = GlobalValue::LinkOnceODRAutoHideLinkage;
    1022 break;
    10221023 case lltok::kw_available_externally:
    10231024 Res = GlobalValue::AvailableExternallyLinkage;
    10241025 break;
    26522653 case GlobalValue::PrivateLinkage:
    26532654 case GlobalValue::LinkerPrivateLinkage:
    26542655 case GlobalValue::LinkerPrivateWeakLinkage:
    2655 case GlobalValue::LinkerPrivateWeakDefAutoLinkage:
    26562656 case GlobalValue::InternalLinkage:
    26572657 case GlobalValue::AvailableExternallyLinkage:
    26582658 case GlobalValue::LinkOnceAnyLinkage:
    26592659 case GlobalValue::LinkOnceODRLinkage:
    2660 case GlobalValue::LinkOnceODRAutoHideLinkage:
    26602661 case GlobalValue::WeakAnyLinkage:
    26612662 case GlobalValue::WeakODRLinkage:
    26622663 case GlobalValue::DLLExportLinkage:
    3636 kw_global, kw_constant,
    3737
    3838 kw_private, kw_linker_private, kw_linker_private_weak,
    39 kw_linker_private_weak_def_auto, kw_internal,
    40 kw_linkonce, kw_linkonce_odr, kw_weak, kw_weak_odr, kw_appending,
    39 kw_linker_private_weak_def_auto, // FIXME: For backwards compatibility.
    40 kw_internal,
    41 kw_linkonce, kw_linkonce_odr, kw_linkonce_odr_auto_hide,
    42 kw_weak, kw_weak_odr, kw_appending,
    4143 kw_dllimport, kw_dllexport, kw_common, kw_available_externally,
    4244 kw_default, kw_hidden, kw_protected,
    4345 kw_unnamed_addr,
    8888 case 12: return GlobalValue::AvailableExternallyLinkage;
    8989 case 13: return GlobalValue::LinkerPrivateLinkage;
    9090 case 14: return GlobalValue::LinkerPrivateWeakLinkage;
    91 case 15: return GlobalValue::LinkerPrivateWeakDefAutoLinkage;
    91 case 15: return GlobalValue::LinkOnceODRAutoHideLinkage;
    9292 }
    9393 }
    9494
    364364 case GlobalValue::AvailableExternallyLinkage: return 12;
    365365 case GlobalValue::LinkerPrivateLinkage: return 13;
    366366 case GlobalValue::LinkerPrivateWeakLinkage: return 14;
    367 case GlobalValue::LinkerPrivateWeakDefAutoLinkage: return 15;
    367 case GlobalValue::LinkOnceODRAutoHideLinkage: return 15;
    368368 }
    369369 llvm_unreachable("Invalid linkage");
    370370 }
    212212 case GlobalValue::CommonLinkage:
    213213 case GlobalValue::LinkOnceAnyLinkage:
    214214 case GlobalValue::LinkOnceODRLinkage:
    215 case GlobalValue::LinkOnceODRAutoHideLinkage:
    215216 case GlobalValue::WeakAnyLinkage:
    216217 case GlobalValue::WeakODRLinkage:
    217218 case GlobalValue::LinkerPrivateWeakLinkage:
    218 case GlobalValue::LinkerPrivateWeakDefAutoLinkage:
    219219 if (MAI->getWeakDefDirective() != 0) {
    220220 // .globl _foo
    221221 OutStreamer.EmitSymbolAttribute(GVSym, MCSA_Global);
    222222
    223223 if ((GlobalValue::LinkageTypes)Linkage !=
    224 GlobalValue::LinkerPrivateWeakDefAutoLinkage)
    224 GlobalValue::LinkOnceODRAutoHideLinkage)
    225225 // .weak_definition _foo
    226226 OutStreamer.EmitSymbolAttribute(GVSym, MCSA_WeakDefinition);
    227227 else
    284284 Out << "GlobalValue::LinkerPrivateLinkage"; break;
    285285 case GlobalValue::LinkerPrivateWeakLinkage:
    286286 Out << "GlobalValue::LinkerPrivateWeakLinkage"; break;
    287 case GlobalValue::LinkerPrivateWeakDefAutoLinkage:
    288 Out << "GlobalValue::LinkerPrivateWeakDefAutoLinkage"; break;
    289287 case GlobalValue::AvailableExternallyLinkage:
    290288 Out << "GlobalValue::AvailableExternallyLinkage "; break;
    291289 case GlobalValue::LinkOnceAnyLinkage:
    292290 Out << "GlobalValue::LinkOnceAnyLinkage "; break;
    293291 case GlobalValue::LinkOnceODRLinkage:
    294292 Out << "GlobalValue::LinkOnceODRLinkage "; break;
    293 case GlobalValue::LinkOnceODRAutoHideLinkage:
    294 Out << "GlobalValue::LinkOnceODRAutoHideLinkage"; break;
    295295 case GlobalValue::WeakAnyLinkage:
    296296 Out << "GlobalValue::WeakAnyLinkage"; break;
    297297 case GlobalValue::WeakODRLinkage:
    182182 ManglerPrefixTy PrefixTy = Mangler::Default;
    183183 if (GV->hasPrivateLinkage() || isImplicitlyPrivate)
    184184 PrefixTy = Mangler::Private;
    185 else if (GV->hasLinkerPrivateLinkage() || GV->hasLinkerPrivateWeakLinkage() ||
    186 GV->hasLinkerPrivateWeakDefAutoLinkage())
    185 else if (GV->hasLinkerPrivateLinkage() || GV->hasLinkerPrivateWeakLinkage())
    187186 PrefixTy = Mangler::LinkerPrivate;
    188187
    189188 // If this global has a name, handle it simply.
    13521352 case GlobalValue::LinkerPrivateWeakLinkage:
    13531353 Out << "linker_private_weak ";
    13541354 break;
    1355 case GlobalValue::LinkerPrivateWeakDefAutoLinkage:
    1356 Out << "linker_private_weak_def_auto ";
    1357 break;
    13581355 case GlobalValue::InternalLinkage: Out << "internal "; break;
    13591356 case GlobalValue::LinkOnceAnyLinkage: Out << "linkonce "; break;
    13601357 case GlobalValue::LinkOnceODRLinkage: Out << "linkonce_odr "; break;
    1358 case GlobalValue::LinkOnceODRAutoHideLinkage:
    1359 Out << "linkonce_odr_auto_hide ";
    1360 break;
    13611361 case GlobalValue::WeakAnyLinkage: Out << "weak "; break;
    13621362 case GlobalValue::WeakODRLinkage: Out << "weak_odr "; break;
    13631363 case GlobalValue::CommonLinkage: Out << "common "; break;
    10831083 return LLVMLinkOnceAnyLinkage;
    10841084 case GlobalValue::LinkOnceODRLinkage:
    10851085 return LLVMLinkOnceODRLinkage;
    1086 case GlobalValue::LinkOnceODRAutoHideLinkage:
    1087 return LLVMLinkOnceODRAutoHideLinkage;
    10861088 case GlobalValue::WeakAnyLinkage:
    10871089 return LLVMWeakAnyLinkage;
    10881090 case GlobalValue::WeakODRLinkage:
    10971099 return LLVMLinkerPrivateLinkage;
    10981100 case GlobalValue::LinkerPrivateWeakLinkage:
    10991101 return LLVMLinkerPrivateWeakLinkage;
    1100 case GlobalValue::LinkerPrivateWeakDefAutoLinkage:
    1101 return LLVMLinkerPrivateWeakDefAutoLinkage;
    11021102 case GlobalValue::DLLImportLinkage:
    11031103 return LLVMDLLImportLinkage;
    11041104 case GlobalValue::DLLExportLinkage:
    11271127 break;
    11281128 case LLVMLinkOnceODRLinkage:
    11291129 GV->setLinkage(GlobalValue::LinkOnceODRLinkage);
    1130 break;
    1131 case LLVMLinkOnceODRAutoHideLinkage:
    1132 GV->setLinkage(GlobalValue::LinkOnceODRAutoHideLinkage);
    11301133 break;
    11311134 case LLVMWeakAnyLinkage:
    11321135 GV->setLinkage(GlobalValue::WeakAnyLinkage);
    11491152 case LLVMLinkerPrivateWeakLinkage:
    11501153 GV->setLinkage(GlobalValue::LinkerPrivateWeakLinkage);
    11511154 break;
    1152 case LLVMLinkerPrivateWeakDefAutoLinkage:
    1153 GV->setLinkage(GlobalValue::LinkerPrivateWeakDefAutoLinkage);
    1154 break;
    11551155 case LLVMDLLImportLinkage:
    11561156 GV->setLinkage(GlobalValue::DLLImportLinkage);
    11571157 break;
    399399 "Only global arrays can have appending linkage!", GVar);
    400400 }
    401401
    402 Assert1(!GV.hasLinkerPrivateWeakDefAutoLinkage() || GV.hasDefaultVisibility(),
    403 "linker_private_weak_def_auto can only have default visibility!",
    402 Assert1(!GV.hasLinkOnceODRAutoHideLinkage() || GV.hasDefaultVisibility(),
    403 "linkonce_odr_auto_hide can only have default visibility!",
    404404 &GV);
    405405 }
    406406
    33
    44 @foo = linker_private hidden global i32 0
    55 @bar = linker_private_weak hidden global i32 0
    6 @qux = linker_private_weak_def_auto global i32 0
    255255 if (GV.hasPrivateLinkage() ||
    256256 GV.hasLinkerPrivateLinkage() ||
    257257 GV.hasLinkerPrivateWeakLinkage() ||
    258 GV.hasLinkerPrivateWeakDefAutoLinkage() ||
    259258 GV.hasAvailableExternallyLinkage())
    260259 return;
    261260 char TypeChar = TypeCharForSymbol(GV);
    486486
    487487 // set definition part
    488488 if (def->hasWeakLinkage() || def->hasLinkOnceLinkage() ||
    489 def->hasLinkerPrivateWeakLinkage() ||
    490 def->hasLinkerPrivateWeakDefAutoLinkage())
    489 def->hasLinkerPrivateWeakLinkage())
    491490 attr |= LTO_SYMBOL_DEFINITION_WEAK;
    492491 else if (def->hasCommonLinkage())
    493492 attr |= LTO_SYMBOL_DEFINITION_TENTATIVE;
    503502 def->hasLinkOnceLinkage() || def->hasCommonLinkage() ||
    504503 def->hasLinkerPrivateWeakLinkage())
    505504 attr |= LTO_SYMBOL_SCOPE_DEFAULT;
    506 else if (def->hasLinkerPrivateWeakDefAutoLinkage())
    505 else if (def->hasLinkOnceODRAutoHideLinkage())
    507506 attr |= LTO_SYMBOL_SCOPE_DEFAULT_CAN_BE_HIDDEN;
    508507 else
    509508 attr |= LTO_SYMBOL_SCOPE_INTERNAL;