[llvm] b8e5307 - update_mir_test_checks: keep comment embedded in MIR (#140016)

via llvm-commits llvm-commits at lists.llvm.org
Mon May 19 18:55:21 PDT 2025


Author: Ruiling, Song
Date: 2025-05-20T09:55:18+08:00
New Revision: b8e5307031e4b12207fa5f6c4b540d997bf34556

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

LOG: update_mir_test_checks: keep comment embedded in MIR (#140016)

We often add inline comment in mir. It is useful to keep them.

Added: 
    

Modified: 
    llvm/test/tools/UpdateTestChecks/update_mir_test_checks/Inputs/x86-dead-def.mir
    llvm/test/tools/UpdateTestChecks/update_mir_test_checks/Inputs/x86-dead-def.mir.expected
    llvm/utils/update_mir_test_checks.py

Removed: 
    


################################################################################
diff  --git a/llvm/test/tools/UpdateTestChecks/update_mir_test_checks/Inputs/x86-dead-def.mir b/llvm/test/tools/UpdateTestChecks/update_mir_test_checks/Inputs/x86-dead-def.mir
index 6666a6f29fe76..f8c568f670ec6 100644
--- a/llvm/test/tools/UpdateTestChecks/update_mir_test_checks/Inputs/x86-dead-def.mir
+++ b/llvm/test/tools/UpdateTestChecks/update_mir_test_checks/Inputs/x86-dead-def.mir
@@ -14,5 +14,6 @@ body:             |
   bb.1:
     dead %0:gr32(s32) = G_CONSTANT i32 0
     dead undef %1.sub_32bit:gr64(s32) = G_CONSTANT i32 1
+    ; Keep meaningful comment.
     undef %2.sub_32bit:gr64(s32) = G_CONSTANT i32 2
 ...

diff  --git a/llvm/test/tools/UpdateTestChecks/update_mir_test_checks/Inputs/x86-dead-def.mir.expected b/llvm/test/tools/UpdateTestChecks/update_mir_test_checks/Inputs/x86-dead-def.mir.expected
index c4e497fe83ab0..ab59edf85f4fc 100644
--- a/llvm/test/tools/UpdateTestChecks/update_mir_test_checks/Inputs/x86-dead-def.mir.expected
+++ b/llvm/test/tools/UpdateTestChecks/update_mir_test_checks/Inputs/x86-dead-def.mir.expected
@@ -18,5 +18,6 @@ body:             |
     ; CHECK-NEXT: undef [[C2:%[0-9]+]].sub_32bit:gr64(s32) = G_CONSTANT i32 2
     dead %0:gr32(s32) = G_CONSTANT i32 0
     dead undef %1.sub_32bit:gr64(s32) = G_CONSTANT i32 1
+    ; Keep meaningful comment.
     undef %2.sub_32bit:gr64(s32) = G_CONSTANT i32 2
 ...

diff  --git a/llvm/utils/update_mir_test_checks.py b/llvm/utils/update_mir_test_checks.py
index 86147034d946b..8deaec74f2777 100755
--- a/llvm/utils/update_mir_test_checks.py
+++ b/llvm/utils/update_mir_test_checks.py
@@ -339,9 +339,9 @@ def mangle_vreg(opcode, current_names):
 
 
 def should_add_line_to_output(input_line, prefix_set):
-    # Skip any check lines that we're handling as well as comments
+    # Skip any check lines that we're handling as well as blank comment.
     m = common.CHECK_RE.match(input_line)
-    if (m and m.group(1) in prefix_set) or re.search("^[ \t]*;", input_line):
+    if (m and m.group(1) in prefix_set) or input_line.strip() == ";":
         return False
     return True
 


        


More information about the llvm-commits mailing list