diff options
author | Yaxun Liu <Yaxun.Liu@amd.com> | 2017-10-14 03:23:18 +0000 |
---|---|---|
committer | Yaxun Liu <Yaxun.Liu@amd.com> | 2017-10-14 03:23:18 +0000 |
commit | adde4e4c01f38f3204be9fe5ff68a0c0a3fe18e1 (patch) | |
tree | 6b9dc18a30e2d30a449f93667183e3f34b2e5aeb /llvm/lib/AsmParser | |
parent | 369e85a9002a368a9a37fec09761724868246296 (diff) | |
download | bcm5719-llvm-adde4e4c01f38f3204be9fe5ff68a0c0a3fe18e1.tar.gz bcm5719-llvm-adde4e4c01f38f3204be9fe5ff68a0c0a3fe18e1.zip |
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
llvm-svn: 315791
Diffstat (limited to 'llvm/lib/AsmParser')
-rw-r--r-- | llvm/lib/AsmParser/LLParser.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp index b9b66ba7b2b..565b1a27daf 100644 --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/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; + } + } } } |