[llvm-commits] [llvm] r168197 - in /llvm/trunk: lib/AsmParser/LLParser.cpp test/Assembler/global-addrspace-forwardref.ll

Justin Holewinski jholewinski at nvidia.com
Fri Nov 16 13:03:47 PST 2012


Author: jholewinski
Date: Fri Nov 16 15:03:47 2012
New Revision: 168197

URL: http://llvm.org/viewvc/llvm-project?rev=168197&view=rev
Log:
Preserve address space of forward-referenced global variables in the LL parser

Before, the parser would assert on the following code:

@a2 = global i8 addrspace(1)* @a
@a = addrspace(1) global i8 0

because the type of @a was "i8*" instead of "i8 addrspace(1)*" when parsing
the initializer for @a2.

Added:
    llvm/trunk/test/Assembler/global-addrspace-forwardref.ll
Modified:
    llvm/trunk/lib/AsmParser/LLParser.cpp

Modified: llvm/trunk/lib/AsmParser/LLParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=168197&r1=168196&r2=168197&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/LLParser.cpp (original)
+++ llvm/trunk/lib/AsmParser/LLParser.cpp Fri Nov 16 15:03:47 2012
@@ -779,7 +779,9 @@
     FwdVal = Function::Create(FT, GlobalValue::ExternalWeakLinkage, Name, M);
   else
     FwdVal = new GlobalVariable(*M, PTy->getElementType(), false,
-                                GlobalValue::ExternalWeakLinkage, 0, Name);
+                                GlobalValue::ExternalWeakLinkage, 0, Name,
+                                0, GlobalVariable::NotThreadLocal,
+                                PTy->getAddressSpace());
 
   ForwardRefVals[Name] = std::make_pair(FwdVal, Loc);
   return FwdVal;

Added: llvm/trunk/test/Assembler/global-addrspace-forwardref.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/global-addrspace-forwardref.ll?rev=168197&view=auto
==============================================================================
--- llvm/trunk/test/Assembler/global-addrspace-forwardref.ll (added)
+++ llvm/trunk/test/Assembler/global-addrspace-forwardref.ll Fri Nov 16 15:03:47 2012
@@ -0,0 +1,8 @@
+; RUN: llvm-as < %s | llvm-dis | FileCheck %s
+
+; Make sure the address space of forward decls is preserved
+
+; CHECK: @a2 = global i8 addrspace(1)* @a
+; CHECK: @a = addrspace(1) global i8 0
+ at a2 = global i8 addrspace(1)* @a
+ at a = addrspace(1) global i8 0





More information about the llvm-commits mailing list