diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp index 4b7c7f07fed990..bf3061ad541e34 100644 --- a/llvm/lib/MC/MCParser/AsmParser.cpp +++ b/llvm/lib/MC/MCParser/AsmParser.cpp @@ -2528,6 +2528,8 @@ bool AsmParser::expandMacro(raw_svector_ostream &OS, MCAsmMacro &Macro, while (I != End && isIdentifierChar(Body[I])) ++I; StringRef Argument(Body.data() + Pos, I - Pos); + if (AltMacroMode && I != End && Body[I] == '&') + ++I; unsigned Index = 0; for (; Index < NParameters; ++Index) if (Parameters[Index].Name == Argument) diff --git a/llvm/test/MC/AsmParser/altmacro_expression.s b/llvm/test/MC/AsmParser/altmacro_expression.s index 58d8b486cf85dd..cee0a6872541a9 100644 --- a/llvm/test/MC/AsmParser/altmacro_expression.s +++ b/llvm/test/MC/AsmParser/altmacro_expression.s @@ -3,10 +3,12 @@ # Checking that the '%' was evaluated as a string first # In a fail scenario: The asmprint will print: addl $%(1+4), %eax -# CHECK: addl $5, %eax +# CHECK: addl $5, %eax +# CHECK-NEXT: addl $5, %eax .altmacro .macro percent_expr arg addl $\arg, %eax + addl $\arg&, %eax .endm percent_expr %(1+4)