[llvm] 1e5f29a - Revert "[MCAsmParser] .rept/.irp/.irpc: remove excess tail EOL in expansion"
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Fri May 17 11:55:26 PDT 2024
Author: Fangrui Song
Date: 2024-05-17T11:55:21-07:00
New Revision: 1e5f29af81a5f6fda308074f6345b9fba4faa71c
URL: https://github.com/llvm/llvm-project/commit/1e5f29af81a5f6fda308074f6345b9fba4faa71c
DIFF: https://github.com/llvm/llvm-project/commit/1e5f29af81a5f6fda308074f6345b9fba4faa71c.diff
LOG: Revert "[MCAsmParser] .rept/.irp/.irpc: remove excess tail EOL in expansion"
This reverts commit c6e787f771d1f9d6a846b2d9b8db6adcd87e8dba.
parseEOL() would remove \n # after .endr, not recognizing the line marker.
```
// reduced from Linux kernel arch/x86/crypto/sha1_avx2_x86_64_asm.S
.rept 1
nop
.endr
# 512 "a.s"
```
Added:
Modified:
llvm/lib/MC/MCParser/AsmParser.cpp
llvm/test/MC/AsmParser/macro-rept.s
Removed:
################################################################################
diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp
index 56da5e2f9a40e..ce155be9c1c70 100644
--- a/llvm/lib/MC/MCParser/AsmParser.cpp
+++ b/llvm/lib/MC/MCParser/AsmParser.cpp
@@ -5624,20 +5624,27 @@ MCAsmMacro *AsmParser::parseMacroLikeBody(SMLoc DirectiveLoc) {
return nullptr;
}
- if (Lexer.is(AsmToken::Identifier)) {
- StringRef Ident = getTok().getIdentifier();
- if (Ident == ".rep" || Ident == ".rept" || Ident == ".irp" ||
- Ident == ".irpc") {
- ++NestLevel;
- } else if (Ident == ".endr") {
- if (NestLevel == 0) {
- EndToken = getTok();
- Lex();
- if (!parseEOL())
- break;
+ if (Lexer.is(AsmToken::Identifier) &&
+ (getTok().getIdentifier() == ".rep" ||
+ getTok().getIdentifier() == ".rept" ||
+ getTok().getIdentifier() == ".irp" ||
+ getTok().getIdentifier() == ".irpc")) {
+ ++NestLevel;
+ }
+
+ // Otherwise, check whether we have reached the .endr.
+ if (Lexer.is(AsmToken::Identifier) && getTok().getIdentifier() == ".endr") {
+ if (NestLevel == 0) {
+ EndToken = getTok();
+ Lex();
+ if (Lexer.isNot(AsmToken::EndOfStatement)) {
+ printError(getTok().getLoc(),
+ "unexpected token in '.endr' directive");
+ return nullptr;
}
- --NestLevel;
+ break;
}
+ --NestLevel;
}
// Otherwise, scan till the end of the statement.
diff --git a/llvm/test/MC/AsmParser/macro-rept.s b/llvm/test/MC/AsmParser/macro-rept.s
index 2a6a4070bff59..1dc8060e1d871 100644
--- a/llvm/test/MC/AsmParser/macro-rept.s
+++ b/llvm/test/MC/AsmParser/macro-rept.s
@@ -13,10 +13,10 @@
// CHECK: .long 1
// CHECK: .long 1
-// CHECK: .long 0
-// CHECK-NEXT: .long 0
-// CHECK-NEXT: .long 0
-// CHECK-NEXT: .long 0
-// CHECK-NEXT: .long 0
-// CHECK-NEXT: .long 0
-// CHECK-EMPTY:
+// CHECK: .long 0
+// CHECK: .long 0
+// CHECK: .long 0
+
+// CHECK: .long 0
+// CHECK: .long 0
+// CHECK: .long 0
More information about the llvm-commits
mailing list