diff options
author | Pawel Wodnicki <pawel@32bitmicro.com> | 2012-11-21 16:40:23 +0000 |
---|---|---|
committer | Pawel Wodnicki <pawel@32bitmicro.com> | 2012-11-21 16:40:23 +0000 |
commit | 00dace859e62c85379021f727c9aeade734f5154 (patch) | |
tree | 5b68624e81c63404b619b1fd19c7a3a635c5f327 | |
parent | 50a66acf1b7920e26618939882701be0e0574ca2 (diff) | |
download | llvm-00dace859e62c85379021f727c9aeade734f5154.tar.gz llvm-00dace859e62c85379021f727c9aeade734f5154.tar.bz2 llvm-00dace859e62c85379021f727c9aeade734f5154.tar.xz |
Merging r168197: into 3.2 release branch
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_32@168435 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/AsmParser/LLParser.cpp | 4 | ||||
-rw-r--r-- | test/Assembler/global-addrspace-forwardref.ll | 8 |
2 files changed, 11 insertions, 1 deletions
diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp index ac803c5783..e8e6e27725 100644 --- a/lib/AsmParser/LLParser.cpp +++ b/lib/AsmParser/LLParser.cpp @@ -779,7 +779,9 @@ GlobalValue *LLParser::GetGlobalVal(const std::string &Name, Type *Ty, 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; diff --git a/test/Assembler/global-addrspace-forwardref.ll b/test/Assembler/global-addrspace-forwardref.ll new file mode 100644 index 0000000000..f0f094a224 --- /dev/null +++ b/test/Assembler/global-addrspace-forwardref.ll @@ -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 +@a2 = global i8 addrspace(1)* @a +@a = addrspace(1) global i8 0 |