[llvm] r239921 - Allow aliases to be unnamed.
Sean Silva
chisophugis at gmail.com
Wed Jun 17 22:13:06 PDT 2015
Does this need a LangRef update?
-- Sean Silva
On Wed, Jun 17, 2015 at 10:53 AM, Rafael Espindola <
rafael.espindola at gmail.com> wrote:
> Author: rafael
> Date: Wed Jun 17 12:53:31 2015
> New Revision: 239921
>
> URL: http://llvm.org/viewvc/llvm-project?rev=239921&view=rev
> Log:
> Allow aliases to be unnamed.
>
> If globals can be unnamed, there is no reason for aliases to be different.
>
> The restriction was there since the original implementation in r36435. I
> can only guess it was there because of the old bison parser for the old
> alias syntax.
>
> Added:
> llvm/trunk/test/Assembler/unnamed-alias.ll
> Modified:
> llvm/trunk/lib/AsmParser/LLParser.cpp
> llvm/trunk/lib/IR/AsmWriter.cpp
> llvm/trunk/lib/IR/Verifier.cpp
>
> Modified: llvm/trunk/lib/AsmParser/LLParser.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=239921&r1=239920&r2=239921&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/AsmParser/LLParser.cpp (original)
> +++ llvm/trunk/lib/AsmParser/LLParser.cpp Wed Jun 17 12:53:31 2015
> @@ -670,6 +670,9 @@ bool LLParser::ParseAlias(const std::str
>
> GA->setDLLStorageClass((GlobalValue::DLLStorageClassTypes)DLLStorageClass);
> GA->setUnnamedAddr(UnnamedAddr);
>
> + if (Name.empty())
> + NumberedVals.push_back(GA.get());
> +
> // See if this value already exists in the symbol table. If so, it is
> either
> // a redefinition or a definition of a forward reference.
> if (GlobalValue *Val = M->getNamedValue(Name)) {
>
> Modified: llvm/trunk/lib/IR/AsmWriter.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/AsmWriter.cpp?rev=239921&r1=239920&r2=239921&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/IR/AsmWriter.cpp (original)
> +++ llvm/trunk/lib/IR/AsmWriter.cpp Wed Jun 17 12:53:31 2015
> @@ -730,6 +730,11 @@ void SlotTracker::processModule() {
> CreateModuleSlot(&Var);
> }
>
> + for (const GlobalAlias &A : TheModule->aliases()) {
> + if (!A.hasName())
> + CreateModuleSlot(&A);
> + }
> +
> // Add metadata used by named metadata.
> for (const NamedMDNode &NMD : TheModule->named_metadata()) {
> for (unsigned i = 0, e = NMD.getNumOperands(); i != e; ++i)
> @@ -2356,13 +2361,9 @@ void AssemblyWriter::printAlias(const Gl
> if (GA->isMaterializable())
> Out << "; Materializable\n";
>
> - // Don't crash when dumping partially built GA
> - if (!GA->hasName())
> - Out << "<<nameless>> = ";
> - else {
> - PrintLLVMName(Out, GA);
> - Out << " = ";
> - }
> + WriteAsOperandInternal(Out, GA, &TypePrinter, &Machine,
> GA->getParent());
> + Out << " = ";
> +
> PrintLinkage(GA->getLinkage(), Out);
> PrintVisibility(GA->getVisibility(), Out);
> PrintDLLStorageClass(GA->getDLLStorageClass(), Out);
>
> Modified: llvm/trunk/lib/IR/Verifier.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Verifier.cpp?rev=239921&r1=239920&r2=239921&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/IR/Verifier.cpp (original)
> +++ llvm/trunk/lib/IR/Verifier.cpp Wed Jun 17 12:53:31 2015
> @@ -584,7 +584,6 @@ void Verifier::visitAliaseeSubExpr(Small
> }
>
> void Verifier::visitGlobalAlias(const GlobalAlias &GA) {
> - Assert(!GA.getName().empty(), "Alias name cannot be empty!", &GA);
> Assert(GlobalAlias::isValidLinkage(GA.getLinkage()),
> "Alias should have private, internal, linkonce, weak,
> linkonce_odr, "
> "weak_odr, or external linkage!",
>
> Added: llvm/trunk/test/Assembler/unnamed-alias.ll
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/unnamed-alias.ll?rev=239921&view=auto
>
> ==============================================================================
> --- llvm/trunk/test/Assembler/unnamed-alias.ll (added)
> +++ llvm/trunk/test/Assembler/unnamed-alias.ll Wed Jun 17 12:53:31 2015
> @@ -0,0 +1,11 @@
> +; RUN: llvm-as < %s | llvm-dis | FileCheck %s
> +
> + at 0 = private constant i32 0
> +; CHECK: @0 = private constant i32 0
> + at 1 = private constant i32 1
> +; CHECK: @1 = private constant i32 1
> +
> + at 2 = private alias i32* @0
> +; CHECK: @2 = private alias i32* @0
> + at 3 = private alias i32* @1
> +; CHECK: @3 = private alias i32* @1
>
>
> _______________________________________________
> 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/20150617/004188e8/attachment.html>
More information about the llvm-commits
mailing list