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 @@ -2611,6 +2611,7 @@ continue; } } + if (SpaceEaten) break; } @@ -2629,6 +2630,15 @@ // Append the token to the current argument list. MA.push_back(getTok()); Lexer.Lex(); + + // If the token is a directive, append all the following arguments if there is any + AsmToken &Tok = MA.back(); + if (Tok.is(AsmToken::Identifier) && Tok.getString().startswith(".")) { + while (!Lexer.is(AsmToken::Comma) && !Lexer.is(AsmToken::EndOfStatement)) { + MA.push_back(getTok()); + Lexer.Lex(); + } + } } if (ParenLevel != 0) diff --git a/llvm/test/MC/X86/expand-macro-directive-arguments.s b/llvm/test/MC/X86/expand-macro-directive-arguments.s new file mode 100644 --- /dev/null +++ b/llvm/test/MC/X86/expand-macro-directive-arguments.s @@ -0,0 +1,10 @@ +# RUN: llvm-mc -filetype=obj -triple=i386 %s -o - | llvm-readelf --sections | FileCheck %s + +.macro alternative_insn insn1, insn2 +# CHECK: .foo PROGBITS 00000000 000034 000000 00 0 0 1 +\insn1 +# CHECK: .bar PROGBITS 00000000 000034 000000 00 0 0 1 +\insn2 +.endm + +alternative_insn .section .foo, .section .bar