[PATCH] D92690: [MC][AMDGPU] Consume EndOfStatement in asm parser

Scott Linder via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 4 14:11:03 PST 2020


scott.linder created this revision.
Herald added subscribers: kerbowa, hiraditya, t-tye, tpr, dstuttard, yaxunl, nhaehnle, jvesely, kzhuravl, arsenm.
scott.linder requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.

Avoids spurious newlines showing up in the output when emitting assembly
via MC.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92690

Files:
  llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
  llvm/test/MC/AMDGPU/round-trip.s


Index: llvm/test/MC/AMDGPU/round-trip.s
===================================================================
--- /dev/null
+++ 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
+# differences, 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
Index: llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
+++ llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
@@ -5013,9 +5013,11 @@
       while (!getLexer().is(AsmToken::EndOfStatement)) {
         Parser.Lex();
       }
+      Parser.Lex();
       return true;
     }
   }
+  Parser.Lex();
 
   return false;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92690.309651.patch
Type: text/x-patch
Size: 1168 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201204/684dec1b/attachment.bin>


More information about the llvm-commits mailing list