[llvm] 2b58458 - [MIRLexer][RISCV] Eat a space after the Machine comment (#115365)

via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 11 11:48:34 PST 2024


Author: Michael Maitland
Date: 2024-11-11T14:48:31-05:00
New Revision: 2b58458225fb0f9cce6dabce7e4451f86c8c73a5

URL: https://github.com/llvm/llvm-project/commit/2b58458225fb0f9cce6dabce7e4451f86c8c73a5
DIFF: https://github.com/llvm/llvm-project/commit/2b58458225fb0f9cce6dabce7e4451f86c8c73a5.diff

LOG: [MIRLexer][RISCV] Eat a space after the Machine comment (#115365)

The MIRPrinter emits ` :: ` at the start of a MMO. The MIRLexer eats all
the white space after the operand and before the `::` when there is no
comment. We need to eat the space after the comment to allow MIRLexer to
parse comments on a MMO.

Added: 
    llvm/test/CodeGen/MIR/skip-mir-comment-trailing-whitespace.mir

Modified: 
    llvm/lib/CodeGen/MIRParser/MILexer.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/MIRParser/MILexer.cpp b/llvm/lib/CodeGen/MIRParser/MILexer.cpp
index 1c450b05f49e93..7153902fe2e7a6 100644
--- a/llvm/lib/CodeGen/MIRParser/MILexer.cpp
+++ b/llvm/lib/CodeGen/MIRParser/MILexer.cpp
@@ -726,7 +726,7 @@ StringRef llvm::lexMIToken(StringRef Source, MIToken &Token,
     return C.remaining();
   }
 
-  C = skipMachineOperandComment(C);
+  C = skipWhitespace(skipMachineOperandComment(C));
 
   if (Cursor R = maybeLexMachineBasicBlock(C, Token, ErrorCallback))
     return R.remaining();

diff  --git a/llvm/test/CodeGen/MIR/skip-mir-comment-trailing-whitespace.mir b/llvm/test/CodeGen/MIR/skip-mir-comment-trailing-whitespace.mir
new file mode 100644
index 00000000000000..4fcdd0ec2ef8ce
--- /dev/null
+++ b/llvm/test/CodeGen/MIR/skip-mir-comment-trailing-whitespace.mir
@@ -0,0 +1,17 @@
+# RUN: llc %s -mtriple=riscv64 -mattr=+v -run-pass=none -o - | FileCheck %s
+
+---
+name:            test_vse8
+tracksRegLiveness: true
+body:             |
+  bb.0:
+    ; CHECK-LABEL: name: test_vse8{{$}}
+    ; CHECK: PseudoVSE8_V_MF8 %1, %2, %0, 3 /* e8 */ :: (store unknown-size, align 1)
+    liveins: $x10, $v8, $x11
+
+    %0:gprnox0 = COPY $x11
+    %1:vr = COPY $v8
+    %2:gpr = COPY $x10
+    PseudoVSE8_V_MF8 %1, %2, %0, 3 /* e8 */ :: (store unknown-size, align 1)
+    PseudoRET
+...


        


More information about the llvm-commits mailing list