aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorYaxun Liu <Yaxun.Liu@amd.com>2017-10-14 03:23:18 +0000
committerYaxun Liu <Yaxun.Liu@amd.com>2017-10-14 03:23:18 +0000
commit7581146f5703cb4428d7be14c2bce8ba01e06289 (patch)
tree17b1586b70eccf14d0eb4cf6dfd7bef38d611f13 /lib
parenta1b8a235837c5a62ee2c33e987a9820bd7a01bb5 (diff)
downloadllvm-7581146f5703cb4428d7be14c2bce8ba01e06289.tar.gz
Fix assembler for alloca of multiple elements in non-zero addr space
Currently llvm assembler emits parsing error for valid IR assembly alloca i32, i32 9, addrspace(5) when alloca addr space is 5. This patch fixes that. Differential Revision: https://reviews.llvm.org/D38713 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@315791 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/AsmParser/LLParser.cpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp
index b9b66ba7b2b..565b1a27daf 100644
--- a/lib/AsmParser/LLParser.cpp
+++ b/lib/AsmParser/LLParser.cpp
@@ -6074,7 +6074,7 @@ bool LLParser::ParseCall(Instruction *&Inst, PerFunctionState &PFS,
/// ParseAlloc
/// ::= 'alloca' 'inalloca'? 'swifterror'? Type (',' TypeAndValue)?
-/// (',' 'align' i32)?
+/// (',' 'align' i32)? (',', 'addrspace(n))?
int LLParser::ParseAlloc(Instruction *&Inst, PerFunctionState &PFS) {
Value *Size = nullptr;
LocTy SizeLoc, TyLoc, ASLoc;
@@ -6104,11 +6104,22 @@ int LLParser::ParseAlloc(Instruction *&Inst, PerFunctionState &PFS) {
} else if (Lex.getKind() == lltok::MetadataVar) {
AteExtraComma = true;
} else {
- if (ParseTypeAndValue(Size, SizeLoc, PFS) ||
- ParseOptionalCommaAlign(Alignment, AteExtraComma) ||
- (!AteExtraComma &&
- ParseOptionalCommaAddrSpace(AddrSpace, ASLoc, AteExtraComma)))
+ if (ParseTypeAndValue(Size, SizeLoc, PFS))
return true;
+ if (EatIfPresent(lltok::comma)) {
+ if (Lex.getKind() == lltok::kw_align) {
+ if (ParseOptionalAlignment(Alignment))
+ return true;
+ if (ParseOptionalCommaAddrSpace(AddrSpace, ASLoc, AteExtraComma))
+ return true;
+ } else if (Lex.getKind() == lltok::kw_addrspace) {
+ ASLoc = Lex.getLoc();
+ if (ParseOptionalAddrSpace(AddrSpace))
+ return true;
+ } else if (Lex.getKind() == lltok::MetadataVar) {
+ AteExtraComma = true;
+ }
+ }
}
}