diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp --- a/llvm/lib/MC/MCParser/AsmParser.cpp +++ b/llvm/lib/MC/MCParser/AsmParser.cpp @@ -3002,13 +3002,20 @@ } /// parseDirectiveAscii: -/// ::= ( .ascii | .asciz | .string ) [ "string" ( , "string" )* ] +/// ::= .ascii [ "string" ( ( , ) "string" )* ] +/// ::= ( .asciz | .string ) [ "string" ( , "string" )* ] bool AsmParser::parseDirectiveAscii(StringRef IDVal, bool ZeroTerminated) { auto parseOp = [&]() -> bool { std::string Data; - if (checkForValidSection() || parseEscapedString(Data)) + if (checkForValidSection()) return true; - getStreamer().emitBytes(Data); + // Only support spaces as separators for .ascii directive for now. See the + // discusssion at https://reviews.llvm.org/D91460 for more details + do { + if (parseEscapedString(Data)) + return true; + getStreamer().emitBytes(Data); + } while (!ZeroTerminated && getTok().is(AsmToken::String)); if (ZeroTerminated) getStreamer().emitBytes(StringRef("\0", 1)); return false; diff --git a/llvm/test/MC/AsmParser/directive_ascii.s b/llvm/test/MC/AsmParser/directive_ascii.s --- a/llvm/test/MC/AsmParser/directive_ascii.s +++ b/llvm/test/MC/AsmParser/directive_ascii.s @@ -48,3 +48,10 @@ TEST7: .ascii "\x64\Xa6B" .ascii "\xface\x0Fe" + +# CHECK: TEST8: +# CHECK: .byte 65 +# CHECK: .byte 66 +# CHECK: .byte 67 +TEST8: + .ascii "A", "B" "C"