[llvm-branch-commits] [llvm] 9260a99 - [MC][AMDGPU] Consume EndOfStatement in asm parser
Scott Linder via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Dec 9 13:51:05 PST 2020
Author: Scott Linder
Date: 2020-12-09T21:45:55Z
New Revision: 9260a999990cd8ee877e1cb9b517166579eca4f3
URL: https://github.com/llvm/llvm-project/commit/9260a999990cd8ee877e1cb9b517166579eca4f3
DIFF: https://github.com/llvm/llvm-project/commit/9260a999990cd8ee877e1cb9b517166579eca4f3.diff
LOG: [MC][AMDGPU] Consume EndOfStatement in asm parser
Avoids spurious newlines showing up in the output when emitting assembly
via MC.
Reviewed By: MaskRay, arsenm
Differential Revision: https://reviews.llvm.org/D92690
Added:
llvm/test/MC/AMDGPU/round-trip.s
Modified:
llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
index 8bf6566d40dd..22c32400ecbf 100644
--- a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
+++ b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
@@ -5020,9 +5020,11 @@ bool AMDGPUAsmParser::ParseInstruction(ParseInstructionInfo &Info,
while (!getLexer().is(AsmToken::EndOfStatement)) {
Parser.Lex();
}
+ Parser.Lex();
return true;
}
}
+ Parser.Lex();
return false;
}
diff --git a/llvm/test/MC/AMDGPU/round-trip.s b/llvm/test/MC/AMDGPU/round-trip.s
new file mode 100644
index 000000000000..eb355ea544e0
--- /dev/null
+++ b/llvm/test/MC/AMDGPU/round-trip.s
@@ -0,0 +1,13 @@
+# RUN: llvm-mc -preserve-comments -triple amdgcn-amd-amdhsa %s >%t-1.s
+# RUN: llvm-mc -preserve-comments -triple amdgcn-amd-amdhsa %t-1.s >%t-2.s
+# RUN:
diff %t-1.s %t-2.s
+
+# Test that AMDGPU assembly round-trips when run through MC; the first
+# transition from hand-written to "canonical" output may introduce some small
+#
diff erences, so we don't include the initial input in the comparison.
+
+.text
+
+# The AMDGPU asm parser didn't consume the end of statement
+# consistently, which led to extra empty lines in the output.
+s_nop 0
More information about the llvm-branch-commits
mailing list