[llvm] r192066 - Add support for aliases with linkonce_odr.
Sean Silva
silvas at purdue.edu
Sun Oct 6 19:12:40 PDT 2013
+The linkgage must be one of ``private``, ``linker_private``
typo: linkgage
On Sun, Oct 6, 2013 at 11:10 AM, Rafael Espindola <
rafael.espindola at gmail.com> wrote:
> Author: rafael
> Date: Sun Oct 6 10:10:43 2013
> New Revision: 192066
>
> URL: http://llvm.org/viewvc/llvm-project?rev=192066&view=rev
> Log:
> Add support for aliases with linkonce_odr.
>
> This will be used to extend constructor aliases in clang.
>
> Modified:
> llvm/trunk/docs/LangRef.rst
> llvm/trunk/lib/AsmParser/LLParser.cpp
> llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
> llvm/trunk/lib/IR/Verifier.cpp
> llvm/trunk/test/CodeGen/X86/aliases.ll
>
> Modified: llvm/trunk/docs/LangRef.rst
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/LangRef.rst?rev=192066&r1=192065&r2=192066&view=diff
>
> ==============================================================================
> --- llvm/trunk/docs/LangRef.rst (original)
> +++ llvm/trunk/docs/LangRef.rst Sun Oct 6 10:10:43 2013
> @@ -614,6 +614,12 @@ Syntax::
>
> @<Name> = alias [Linkage] [Visibility] <AliaseeTy> @<Aliasee>
>
> +The linkgage must be one of ``private``, ``linker_private``,
> +``linker_private_weak``, ``internal``, ``linkonce``, ``weak``,
> +``linkonce_odr``, ``weak_odr``, ``linkonce_odr_auto_hide``, ``external``.
> Note
> +that some system linkers might not correctly handle dropping a weak
> symbol that
> +is aliased by a non weak alias.
> +
> .. _namedmetadatastructure:
>
> Named Metadata
>
> Modified: llvm/trunk/lib/AsmParser/LLParser.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=192066&r1=192065&r2=192066&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/AsmParser/LLParser.cpp (original)
> +++ llvm/trunk/lib/AsmParser/LLParser.cpp Sun Oct 6 10:10:43 2013
> @@ -627,18 +627,17 @@ bool LLParser::ParseAlias(const std::str
> unsigned Visibility) {
> assert(Lex.getKind() == lltok::kw_alias);
> Lex.Lex();
> - unsigned Linkage;
> LocTy LinkageLoc = Lex.getLoc();
> - if (ParseOptionalLinkage(Linkage))
> + unsigned L;
> + if (ParseOptionalLinkage(L))
> return true;
>
> - if (Linkage != GlobalValue::ExternalLinkage &&
> - Linkage != GlobalValue::WeakAnyLinkage &&
> - Linkage != GlobalValue::WeakODRLinkage &&
> - Linkage != GlobalValue::InternalLinkage &&
> - Linkage != GlobalValue::PrivateLinkage &&
> - Linkage != GlobalValue::LinkerPrivateLinkage &&
> - Linkage != GlobalValue::LinkerPrivateWeakLinkage)
> + GlobalValue::LinkageTypes Linkage = (GlobalValue::LinkageTypes) L;
> +
> + if(!GlobalValue::isExternalLinkage(Linkage) &&
> + !GlobalValue::isLocalLinkage(Linkage) &&
> + !GlobalValue::isWeakLinkage(Linkage) &&
> + !GlobalValue::isLinkOnceLinkage(Linkage))
> return Error(LinkageLoc, "invalid linkage type for alias");
>
> Constant *Aliasee;
>
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=192066&r1=192065&r2=192066&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Sun Oct 6 10:10:43
> 2013
> @@ -934,7 +934,7 @@ bool AsmPrinter::doFinalization(Module &
>
> if (I->hasExternalLinkage() || !MAI->getWeakRefDirective())
> OutStreamer.EmitSymbolAttribute(Name, MCSA_Global);
> - else if (I->hasWeakLinkage())
> + else if (I->hasWeakLinkage() || I->hasLinkOnceLinkage())
> OutStreamer.EmitSymbolAttribute(Name, MCSA_WeakReference);
> else
> assert(I->hasLocalLinkage() && "Invalid alias linkage");
>
> Modified: llvm/trunk/lib/IR/Verifier.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Verifier.cpp?rev=192066&r1=192065&r2=192066&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/IR/Verifier.cpp (original)
> +++ llvm/trunk/lib/IR/Verifier.cpp Sun Oct 6 10:10:43 2013
> @@ -530,7 +530,7 @@ void Verifier::visitGlobalAlias(GlobalAl
> Assert1(!GA.getName().empty(),
> "Alias name cannot be empty!", &GA);
> Assert1(GA.hasExternalLinkage() || GA.hasLocalLinkage() ||
> - GA.hasWeakLinkage(),
> + GA.hasWeakLinkage() || GA.hasLinkOnceLinkage(),
> "Alias should have external or external weak linkage!", &GA);
> Assert1(GA.getAliasee(),
> "Aliasee cannot be NULL!", &GA);
>
> Modified: llvm/trunk/test/CodeGen/X86/aliases.ll
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/aliases.ll?rev=192066&r1=192065&r2=192066&view=diff
>
> ==============================================================================
> --- llvm/trunk/test/CodeGen/X86/aliases.ll (original)
> +++ llvm/trunk/test/CodeGen/X86/aliases.ll Sun Oct 6 10:10:43 2013
> @@ -14,6 +14,9 @@ declare i32 @foo_f()
> ; CHECK-DAG: .weak bar_f
> @bar_f = alias weak %FunTy* @foo_f
>
> + at bar_l = alias linkonce_odr i32* @bar
> +; CHECK-DAG: .weak bar_l
> +
> @bar_i = alias internal i32* @bar
>
> ; CHECK-DAG: .globl A
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131006/6a5dc815/attachment.html>
More information about the llvm-commits
mailing list