llvm.org GIT mirror llvm / 19794da
Remove linkonce_odr_auto_hide. linkonce_odr_auto_hide was in incomplete attempt to implement a way for the linker to hide symbols that are known to be available in every TU and whose addresses are not relevant for a particular DSO. It was redundant in that it all its uses are equivalent to linkonce_odr+unnamed_addr. Unlike those, it has never been connected to clang or llvm's optimizers, so it was effectively dead. Given that nothing produces it, this patch just nukes it (other than the llvm-c enum value). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193865 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 5 years ago
16 changed file(s) with 13 addition(s) and 59 deletion(s). Raw diff Collapse all Expand all
266266 ``linkonce_odr`` and ``weak_odr`` linkage types to indicate that the
267267 global will only be merged with equivalent globals. These linkage
268268 types are otherwise the same as their non-``odr`` versions.
269 ``linkonce_odr_auto_hide``
270 Similar to "``linkonce_odr``", but nothing in the translation unit
271 takes the address of this definition. For instance, functions that
272 had an inline definition, but the compiler decided not to inline it.
273 ``linkonce_odr_auto_hide`` may have only ``default`` visibility. The
274 symbols are removed by the linker from the final linked image
275 (executable or dynamic library).
276269 ``external``
277270 If none of the above identifiers are used, the global is externally
278271 visible, meaning that it participates in linkage and can be used to
621614
622615 The linkage must be one of ``private``, ``linker_private``,
623616 ``linker_private_weak``, ``internal``, ``linkonce``, ``weak``,
624 ``linkonce_odr``, ``weak_odr``, ``linkonce_odr_auto_hide``, ``external``. Note
625 that some system linkers might not correctly handle dropping a weak symbol that
626 is aliased by a non weak alias.
617 ``linkonce_odr``, ``weak_odr``, ``external``. Note that some system linkers
618 might not correctly handle dropping a weak symbol that is aliased by a non weak
619 alias.
627620
628621 .. _namedmetadatastructure:
629622
3434 AvailableExternallyLinkage, ///< Available for inspection, not emission.
3535 LinkOnceAnyLinkage, ///< Keep one copy of function when linking (inline)
3636 LinkOnceODRLinkage, ///< Same, but only replaced by something equivalent.
37 LinkOnceODRAutoHideLinkage, ///< Like LinkOnceODRLinkage but addr not taken.
3837 WeakAnyLinkage, ///< Keep one copy of named function when linking (weak)
3938 WeakODRLinkage, ///< Same, but only replaced by something equivalent.
4039 AppendingLinkage, ///< Special purpose, only applies to global arrays
122121 return Linkage == AvailableExternallyLinkage;
123122 }
124123 static bool isLinkOnceLinkage(LinkageTypes Linkage) {
125 return Linkage == LinkOnceAnyLinkage ||
126 Linkage == LinkOnceODRLinkage ||
127 Linkage == LinkOnceODRAutoHideLinkage;
128 }
129 static bool isLinkOnceODRAutoHideLinkage(LinkageTypes Linkage) {
130 return Linkage == LinkOnceODRAutoHideLinkage;
124 return Linkage == LinkOnceAnyLinkage || Linkage == LinkOnceODRLinkage;
131125 }
132126 static bool isWeakLinkage(LinkageTypes Linkage) {
133127 return Linkage == WeakAnyLinkage || Linkage == WeakODRLinkage;
191185 Linkage == WeakODRLinkage ||
192186 Linkage == LinkOnceAnyLinkage ||
193187 Linkage == LinkOnceODRLinkage ||
194 Linkage == LinkOnceODRAutoHideLinkage ||
195188 Linkage == CommonLinkage ||
196189 Linkage == ExternalWeakLinkage ||
197190 Linkage == LinkerPrivateWeakLinkage;
203196 }
204197 bool hasLinkOnceLinkage() const {
205198 return isLinkOnceLinkage(Linkage);
206 }
207 bool hasLinkOnceODRAutoHideLinkage() const {
208 return isLinkOnceODRAutoHideLinkage(Linkage);
209199 }
210200 bool hasWeakLinkage() const {
211201 return isWeakLinkage(Linkage);
273273 LLVMLinkOnceAnyLinkage, /**< Keep one copy of function when linking (inline)*/
274274 LLVMLinkOnceODRLinkage, /**< Same, but only replaced by something
275275 equivalent. */
276 LLVMLinkOnceODRAutoHideLinkage, /**< Like LinkOnceODR, but possibly hidden. */
276 LLVMLinkOnceODRAutoHideLinkage, /**< Obsolete */
277277 LLVMWeakAnyLinkage, /**< Keep one copy of function when linking (weak) */
278278 LLVMWeakODRLinkage, /**< Same, but only replaced by something
279279 equivalent. */
477477 KEYWORD(private);
478478 KEYWORD(linker_private);
479479 KEYWORD(linker_private_weak);
480 KEYWORD(linker_private_weak_def_auto); // FIXME: For backwards compatibility.
481480 KEYWORD(internal);
482481 KEYWORD(available_externally);
483482 KEYWORD(linkonce);
484483 KEYWORD(linkonce_odr);
485 KEYWORD(linkonce_odr_auto_hide);
486484 KEYWORD(weak);
487485 KEYWORD(weak_odr);
488486 KEYWORD(appending);
245245 case lltok::kw_private: // OptionalLinkage
246246 case lltok::kw_linker_private: // OptionalLinkage
247247 case lltok::kw_linker_private_weak: // OptionalLinkage
248 case lltok::kw_linker_private_weak_def_auto: // FIXME: backwards compat.
249248 case lltok::kw_internal: // OptionalLinkage
250249 case lltok::kw_weak: // OptionalLinkage
251250 case lltok::kw_weak_odr: // OptionalLinkage
252251 case lltok::kw_linkonce: // OptionalLinkage
253252 case lltok::kw_linkonce_odr: // OptionalLinkage
254 case lltok::kw_linkonce_odr_auto_hide: // OptionalLinkage
255253 case lltok::kw_appending: // OptionalLinkage
256254 case lltok::kw_dllexport: // OptionalLinkage
257255 case lltok::kw_common: // OptionalLinkage
12711269 /// ::= 'weak_odr'
12721270 /// ::= 'linkonce'
12731271 /// ::= 'linkonce_odr'
1274 /// ::= 'linkonce_odr_auto_hide'
12751272 /// ::= 'available_externally'
12761273 /// ::= 'appending'
12771274 /// ::= 'dllexport'
12931290 case lltok::kw_weak_odr: Res = GlobalValue::WeakODRLinkage; break;
12941291 case lltok::kw_linkonce: Res = GlobalValue::LinkOnceAnyLinkage; break;
12951292 case lltok::kw_linkonce_odr: Res = GlobalValue::LinkOnceODRLinkage; break;
1296 case lltok::kw_linkonce_odr_auto_hide:
1297 case lltok::kw_linker_private_weak_def_auto: // FIXME: For backwards compat.
1298 Res = GlobalValue::LinkOnceODRAutoHideLinkage;
1299 break;
13001293 case lltok::kw_available_externally:
13011294 Res = GlobalValue::AvailableExternallyLinkage;
13021295 break;
29592952 case GlobalValue::AvailableExternallyLinkage:
29602953 case GlobalValue::LinkOnceAnyLinkage:
29612954 case GlobalValue::LinkOnceODRLinkage:
2962 case GlobalValue::LinkOnceODRAutoHideLinkage:
29632955 case GlobalValue::WeakAnyLinkage:
29642956 case GlobalValue::WeakODRLinkage:
29652957 case GlobalValue::DLLExportLinkage:
3737 kw_global, kw_constant,
3838
3939 kw_private, kw_linker_private, kw_linker_private_weak,
40 kw_linker_private_weak_def_auto, // FIXME: For backwards compatibility.
4140 kw_internal,
42 kw_linkonce, kw_linkonce_odr, kw_linkonce_odr_auto_hide,
41 kw_linkonce, kw_linkonce_odr,
4342 kw_weak, kw_weak_odr, kw_appending,
4443 kw_dllimport, kw_dllexport, kw_common, kw_available_externally,
4544 kw_default, kw_hidden, kw_protected,
8989 case 12: return GlobalValue::AvailableExternallyLinkage;
9090 case 13: return GlobalValue::LinkerPrivateLinkage;
9191 case 14: return GlobalValue::LinkerPrivateWeakLinkage;
92 case 15: return GlobalValue::LinkOnceODRAutoHideLinkage;
9392 }
9493 }
9594
488488 case GlobalValue::AvailableExternallyLinkage: return 12;
489489 case GlobalValue::LinkerPrivateLinkage: return 13;
490490 case GlobalValue::LinkerPrivateWeakLinkage: return 14;
491 case GlobalValue::LinkOnceODRAutoHideLinkage: return 15;
492491 }
493492 llvm_unreachable("Invalid linkage");
494493 }
218218 case GlobalValue::CommonLinkage:
219219 case GlobalValue::LinkOnceAnyLinkage:
220220 case GlobalValue::LinkOnceODRLinkage:
221 case GlobalValue::LinkOnceODRAutoHideLinkage:
222221 case GlobalValue::WeakAnyLinkage:
223222 case GlobalValue::WeakODRLinkage:
224223 case GlobalValue::LinkerPrivateWeakLinkage:
226225 // .globl _foo
227226 OutStreamer.EmitSymbolAttribute(GVSym, MCSA_Global);
228227
229
230 bool CanBeHidden = Linkage == GlobalValue::LinkOnceODRAutoHideLinkage;
231
232 if (!CanBeHidden && Linkage == GlobalValue::LinkOnceODRLinkage) {
228 bool CanBeHidden = false;
229
230 if (Linkage == GlobalValue::LinkOnceODRLinkage) {
233231 if (GV->hasUnnamedAddr()) {
234232 CanBeHidden = true;
235233 } else {
13931393 case GlobalValue::InternalLinkage: Out << "internal "; break;
13941394 case GlobalValue::LinkOnceAnyLinkage: Out << "linkonce "; break;
13951395 case GlobalValue::LinkOnceODRLinkage: Out << "linkonce_odr "; break;
1396 case GlobalValue::LinkOnceODRAutoHideLinkage:
1397 Out << "linkonce_odr_auto_hide ";
1398 break;
13991396 case GlobalValue::WeakAnyLinkage: Out << "weak "; break;
14001397 case GlobalValue::WeakODRLinkage: Out << "weak_odr "; break;
14011398 case GlobalValue::CommonLinkage: Out << "common "; break;
11331133 return LLVMLinkOnceAnyLinkage;
11341134 case GlobalValue::LinkOnceODRLinkage:
11351135 return LLVMLinkOnceODRLinkage;
1136 case GlobalValue::LinkOnceODRAutoHideLinkage:
1137 return LLVMLinkOnceODRAutoHideLinkage;
11381136 case GlobalValue::WeakAnyLinkage:
11391137 return LLVMWeakAnyLinkage;
11401138 case GlobalValue::WeakODRLinkage:
11791177 GV->setLinkage(GlobalValue::LinkOnceODRLinkage);
11801178 break;
11811179 case LLVMLinkOnceODRAutoHideLinkage:
1182 GV->setLinkage(GlobalValue::LinkOnceODRAutoHideLinkage);
1180 DEBUG(errs() << "LLVMSetLinkage(): LLVMLinkOnceODRAutoHideLinkage is no "
1181 "longer supported.");
11831182 break;
11841183 case LLVMWeakAnyLinkage:
11851184 GV->setLinkage(GlobalValue::WeakAnyLinkage);
432432 Assert1(GVar && GVar->getType()->getElementType()->isArrayTy(),
433433 "Only global arrays can have appending linkage!", GVar);
434434 }
435
436 Assert1(!GV.hasLinkOnceODRAutoHideLinkage() || GV.hasDefaultVisibility(),
437 "linkonce_odr_auto_hide can only have default visibility!",
438 &GV);
439435 }
440436
441437 void Verifier::visitGlobalVariable(GlobalVariable &GV) {
337337
338338 static bool canBeHidden(const GlobalValue *GV) {
339339 GlobalValue::LinkageTypes L = GV->getLinkage();
340
341 if (L == GlobalValue::LinkOnceODRAutoHideLinkage)
342 return true;
343340
344341 if (L != GlobalValue::LinkOnceODRLinkage)
345342 return false;
291291 Out << "GlobalValue::LinkOnceAnyLinkage "; break;
292292 case GlobalValue::LinkOnceODRLinkage:
293293 Out << "GlobalValue::LinkOnceODRLinkage "; break;
294 case GlobalValue::LinkOnceODRAutoHideLinkage:
295 Out << "GlobalValue::LinkOnceODRAutoHideLinkage"; break;
296294 case GlobalValue::WeakAnyLinkage:
297295 Out << "GlobalValue::WeakAnyLinkage"; break;
298296 case GlobalValue::WeakODRLinkage:
4040 private
4141 linker_private
4242 linker_private_weak
43 linker_private_weak_def_auto
4443 internal
4544 available_externally
4645 linkonce
4242 syn keyword llvmKeyword dllexport dllimport except extern_weak external fastcc
4343 syn keyword llvmKeyword filter gc global hidden initialexec inlinehint inreg
4444 syn keyword llvmKeyword intel_ocl_bicc inteldialect internal linker_private
45 syn keyword llvmKeyword linker_private_weak linker_private_weak_def_auto
46 syn keyword llvmKeyword linkonce linkonce_odr linkonce_odr_auto_hide
45 syn keyword llvmKeyword linker_private_weak
46 syn keyword llvmKeyword linkonce linkonce_odr
4747 syn keyword llvmKeyword localdynamic localexec minsize module monotonic
4848 syn keyword llvmKeyword msp430_intrcc naked nest noalias nocapture
4949 syn keyword llvmKeyword noimplicitfloat noinline nonlazybind noredzone noreturn