[llvm] [AMDGPU][test]added remove duplicate options for update_mc_test_check script (PR #111769)

Brox Chen via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 16 16:58:58 PDT 2024


================
@@ -298,23 +316,58 @@ def main():
                     else:
                         gen_prefix += getStdCheckLine(prefix, o, mc_mode)
 
-            generated_prefixes.append(gen_prefix.rstrip("\n"))
+            generated_prefixes[input_line] = gen_prefix.rstrip("\n")
 
         # write output
-        prefix_id = 0
+        written_lines = set()
         for input_info in ti.iterlines(output_lines):
             input_line = input_info.line
-            if isTestLine(input_line, mc_mode):
+            if input_line in testlines:
+                if ti.args.remove_duplicate:
+                    if input_line in written_lines:
+                        common.debug("Duplicated line skipped: ", input_line)
+                        continue
+                    else:
+                        written_lines.add(input_line)
                 output_lines.append(input_line)
-                output_lines.append(generated_prefixes[prefix_id])
-                prefix_id += 1
+                output_lines.append(generated_prefixes[input_line])
 
             elif should_add_line_to_output(input_line, prefix_set, mc_mode):
                 output_lines.append(input_line)
 
             elif input_line in ti.run_lines or input_line == "":
                 output_lines.append(input_line)
 
+        # sort
+        if ti.args.sort:
+            # split with double newlines
+            lines = "\n".join(output_lines)
+            lines = lines.split("\n\n")
+
+            def compare(l1, l2):
+                # if contains multiple lines, just compare first line
----------------
broxigarchen wrote:

added. Now comment line are skipped

https://github.com/llvm/llvm-project/pull/111769


More information about the llvm-commits mailing list