[llvm] 4864893 - [Utils] Do not remove comments in llc test script
Sebastian Neubauer via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 29 04:03:33 PDT 2021
Author: Sebastian Neubauer
Date: 2021-07-29T13:03:05+02:00
New Revision: 486489312743411ce2e25d7763e6d298f672f976
URL: https://github.com/llvm/llvm-project/commit/486489312743411ce2e25d7763e6d298f672f976
DIFF: https://github.com/llvm/llvm-project/commit/486489312743411ce2e25d7763e6d298f672f976.diff
LOG: [Utils] Do not remove comments in llc test script
When checking if two prefixes can be merged for a function,
update_llc_test_checks.py removed IR comments before comparing
llc outputs of different RUN lines.
This means, if one RUN line emited lines starting with ';' and another
RUN line emited the same lines except the ones starting with ';', both
RUNs would be merged (if they share a prefix).
However, CHECK-NEXT lines check the comments, otherwise they fail, so
the script should not merge RUNs if they contain different comments.
Differential Revision: https://reviews.llvm.org/D101312
Added:
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/amdgpu_no_merge_comments.ll
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/amdgpu_no_merge_comments.ll.expected
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/amdgpu-no-merge-comments.test
Modified:
llvm/utils/UpdateTestChecks/common.py
llvm/utils/update_analyze_test_checks.py
llvm/utils/update_cc_test_checks.py
llvm/utils/update_llc_test_checks.py
llvm/utils/update_test_checks.py
Removed:
################################################################################
diff --git a/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/amdgpu_no_merge_comments.ll b/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/amdgpu_no_merge_comments.ll
new file mode 100644
index 0000000000000..21d01f5a1a375
--- /dev/null
+++ b/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/amdgpu_no_merge_comments.ll
@@ -0,0 +1,9 @@
+; RUN: llc -O0 -mtriple=amdgcn- -mcpu=gfx900 < %s | FileCheck -check-prefixes=GCN,GFX9-O0 %s
+; RUN: llc -mtriple=amdgcn- -mcpu=gfx900 < %s | FileCheck -check-prefixes=GCN,GFX9-O3 %s
+
+define hidden i32 @main(i32 %a) {
+ %add = add i32 %a, %a
+ %mul = mul i32 %add, %a
+ %sub = sub i32 %mul, %add
+ ret i32 %sub
+}
diff --git a/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/amdgpu_no_merge_comments.ll.expected b/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/amdgpu_no_merge_comments.ll.expected
new file mode 100644
index 0000000000000..645b5dd7f065c
--- /dev/null
+++ b/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/amdgpu_no_merge_comments.ll.expected
@@ -0,0 +1,27 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -O0 -mtriple=amdgcn- -mcpu=gfx900 < %s | FileCheck -check-prefixes=GCN,GFX9-O0 %s
+; RUN: llc -mtriple=amdgcn- -mcpu=gfx900 < %s | FileCheck -check-prefixes=GCN,GFX9-O3 %s
+
+define hidden i32 @main(i32 %a) {
+; GFX9-O0-LABEL: main:
+; GFX9-O0: ; %bb.0:
+; GFX9-O0-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
+; GFX9-O0-NEXT: v_add_u32_e64 v1, v0, v0
+; GFX9-O0-NEXT: ; implicit-def: $sgpr4
+; GFX9-O0-NEXT: ; implicit-def: $sgpr4
+; GFX9-O0-NEXT: v_mul_lo_u32 v0, v1, v0
+; GFX9-O0-NEXT: v_sub_u32_e64 v0, v0, v1
+; GFX9-O0-NEXT: s_setpc_b64 s[30:31]
+;
+; GFX9-O3-LABEL: main:
+; GFX9-O3: ; %bb.0:
+; GFX9-O3-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
+; GFX9-O3-NEXT: v_add_u32_e32 v1, v0, v0
+; GFX9-O3-NEXT: v_mul_lo_u32 v0, v1, v0
+; GFX9-O3-NEXT: v_sub_u32_e32 v0, v0, v1
+; GFX9-O3-NEXT: s_setpc_b64 s[30:31]
+ %add = add i32 %a, %a
+ %mul = mul i32 %add, %a
+ %sub = sub i32 %mul, %add
+ ret i32 %sub
+}
diff --git a/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/amdgpu-no-merge-comments.test b/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/amdgpu-no-merge-comments.test
new file mode 100644
index 0000000000000..7d078774e8fda
--- /dev/null
+++ b/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/amdgpu-no-merge-comments.test
@@ -0,0 +1,5 @@
+# REQUIRES: amdgpu-registered-target
+## Check that functions with
diff erent IR comments in the output are not merged
+
+# RUN: cp -f %S/Inputs/amdgpu_no_merge_comments.ll %t.ll && %update_llc_test_checks %t.ll
+# RUN:
diff -u %S/Inputs/amdgpu_no_merge_comments.ll.expected %t.ll
diff --git a/llvm/utils/UpdateTestChecks/common.py b/llvm/utils/UpdateTestChecks/common.py
index aa9b845f05fdc..bc4b0738c6ad4 100644
--- a/llvm/utils/UpdateTestChecks/common.py
+++ b/llvm/utils/UpdateTestChecks/common.py
@@ -268,7 +268,7 @@ def __init__(self, string, extra, args_and_sig, attrs):
self.extrascrub = extra
self.args_and_sig = args_and_sig
self.attrs = attrs
- def is_same_except_arg_names(self, extrascrub, args_and_sig, attrs):
+ def is_same_except_arg_names(self, extrascrub, args_and_sig, attrs, is_asm):
arg_names = set()
def drop_arg_names(match):
arg_names.add(match.group(variable_group_in_ir_value_match))
@@ -287,6 +287,11 @@ def repl_arg_names(match):
ans1 = IR_VALUE_RE.sub(drop_arg_names, args_and_sig)
if ans0 != ans1:
return False
+ if is_asm:
+ # Check without replacements, the replacements are not applied to the
+ # body for asm checks.
+ return self.extrascrub == extrascrub
+
es0 = IR_VALUE_RE.sub(repl_arg_names, self.extrascrub)
es1 = IR_VALUE_RE.sub(repl_arg_names, extrascrub)
es0 = SCRUB_IR_COMMENT_RE.sub(r'', es0)
@@ -325,7 +330,7 @@ def func_order(self):
def global_var_dict(self):
return self._global_var_dict
- def process_run_line(self, function_re, scrubber, raw_tool_output, prefixes):
+ def process_run_line(self, function_re, scrubber, raw_tool_output, prefixes, is_asm):
build_global_values_dictionary(self._global_var_dict, raw_tool_output, prefixes)
for m in function_re.finditer(raw_tool_output):
if not m:
@@ -391,7 +396,8 @@ def process_run_line(self, function_re, scrubber, raw_tool_output, prefixes):
self._func_dict[prefix][func].is_same_except_arg_names(
scrubbed_extra,
args_and_sig,
- attrs)):
+ attrs,
+ is_asm)):
self._func_dict[prefix][func].scrub = scrubbed_extra
self._func_dict[prefix][func].args_and_sig = args_and_sig
continue
diff --git a/llvm/utils/update_analyze_test_checks.py b/llvm/utils/update_analyze_test_checks.py
index 6c5bc525b98a6..ca45cd1eeaf00 100755
--- a/llvm/utils/update_analyze_test_checks.py
+++ b/llvm/utils/update_analyze_test_checks.py
@@ -127,7 +127,7 @@ def main():
# Split analysis outputs by "Printing analysis " declarations.
for raw_tool_output in re.split(r'Printing analysis ', raw_tool_outputs):
builder.process_run_line(common.ANALYZE_FUNCTION_RE, common.scrub_body,
- raw_tool_output, prefixes)
+ raw_tool_output, prefixes, False)
func_dict = builder.finish_and_get_func_dict()
is_in_function = False
diff --git a/llvm/utils/update_cc_test_checks.py b/llvm/utils/update_cc_test_checks.py
index e3a9354591f1b..15318e19fd66d 100755
--- a/llvm/utils/update_cc_test_checks.py
+++ b/llvm/utils/update_cc_test_checks.py
@@ -213,7 +213,7 @@ def get_function_body(builder, args, filename, clang_args, extra_commands,
if '-emit-llvm' in clang_args:
builder.process_run_line(
common.OPT_FUNCTION_RE, common.scrub_body, raw_tool_output,
- prefixes)
+ prefixes, False)
else:
print('The clang command line should include -emit-llvm as asm tests '
'are discouraged in Clang testsuite.', file=sys.stderr)
diff --git a/llvm/utils/update_llc_test_checks.py b/llvm/utils/update_llc_test_checks.py
index 7e20a58d6ea4a..a9e86eaa069b3 100755
--- a/llvm/utils/update_llc_test_checks.py
+++ b/llvm/utils/update_llc_test_checks.py
@@ -129,7 +129,7 @@ def main():
triple = asm.get_triple_from_march(march_in_cmd)
scrubber, function_re = asm.get_run_handler(triple)
- builder.process_run_line(function_re, scrubber, raw_tool_output, prefixes)
+ builder.process_run_line(function_re, scrubber, raw_tool_output, prefixes, True)
func_dict = builder.finish_and_get_func_dict()
diff --git a/llvm/utils/update_test_checks.py b/llvm/utils/update_test_checks.py
index 9ac95ccd80cde..d7fce8d931633 100755
--- a/llvm/utils/update_test_checks.py
+++ b/llvm/utils/update_test_checks.py
@@ -124,7 +124,7 @@ def main():
ti.path, preprocess_cmd=preprocess_cmd,
verbose=ti.args.verbose)
builder.process_run_line(common.OPT_FUNCTION_RE, common.scrub_body,
- raw_tool_output, prefixes)
+ raw_tool_output, prefixes, False)
func_dict = builder.finish_and_get_func_dict()
is_in_function = False
More information about the llvm-commits
mailing list