[clang] 92f2c39 - [Utils] Run non-filecheck runlines in-order in update_cc_test_checks
Giorgis Georgakoudis via cfe-commits
cfe-commits at lists.llvm.org
Tue May 4 12:06:13 PDT 2021
Author: Giorgis Georgakoudis
Date: 2021-05-04T12:06:03-07:00
New Revision: 92f2c39f915adc8f71be02d2604df4916069c9d4
URL: https://github.com/llvm/llvm-project/commit/92f2c39f915adc8f71be02d2604df4916069c9d4
DIFF: https://github.com/llvm/llvm-project/commit/92f2c39f915adc8f71be02d2604df4916069c9d4.diff
LOG: [Utils] Run non-filecheck runlines in-order in update_cc_test_checks
The script update_cc_test_checks runs all non-filechecked runlines before the filechecked ones. This creates problems since outputs of those non-filechecked runlines may conflict and that will fail the execution of update_cc_test_checks. This patch executes non-filechecked in the order specified in the test file to avoid this issue.
Reviewed By: jdoerfert
Differential Revision: https://reviews.llvm.org/D101683
Added:
Modified:
clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c
clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c.expected
llvm/utils/update_cc_test_checks.py
Removed:
################################################################################
diff --git a/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c b/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c
index e0dfc42c4bd6..60d608b8cadd 100644
--- a/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c
+++ b/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c
@@ -2,10 +2,20 @@
// RUN: cp %s %S/Output/execute-all-runlines.copy.c
// RUN: cp %S/Output/execute-all-runlines.copy.c %s.copy.c
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fopenmp %s.copy.c -emit-llvm-bc -o %t-host.bc
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fopenmp -fopenmp-host-ir-file-path %t-host.bc %s.copy.c -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fopenmp -fopenmp-host-ir-file-path %t-host.bc %s.copy.c -emit-llvm -o - | FileCheck %s --check-prefix=CHECK1
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-pch %s -o %t
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -include-pch %t %s.copy.c -emit-llvm -o - | FileCheck %s --check-prefix=CHECK2
+// RUN: %clang_cc1 -triple powerpc64le-unknown-linux-gnu -emit-pch %s -o %t
+// RUN: %clang_cc1 -triple powerpc64le-unknown-linux-gnu -include-pch %t %s.copy.c -emit-llvm -o - | FileCheck %s --check-prefix=CHECK3
+
+
+#ifndef HEADER
+#define HEADER
void use(int);
void test(int a)
{
}
+
+#endif
diff --git a/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c.expected b/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c.expected
index ae9745fa9b1e..cebd3846b2d9 100644
--- a/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c.expected
+++ b/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c.expected
@@ -3,16 +3,38 @@
// RUN: cp %s %S/Output/execute-all-runlines.copy.c
// RUN: cp %S/Output/execute-all-runlines.copy.c %s.copy.c
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fopenmp %s.copy.c -emit-llvm-bc -o %t-host.bc
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fopenmp -fopenmp-host-ir-file-path %t-host.bc %s.copy.c -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fopenmp -fopenmp-host-ir-file-path %t-host.bc %s.copy.c -emit-llvm -o - | FileCheck %s --check-prefix=CHECK1
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-pch %s -o %t
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -include-pch %t %s.copy.c -emit-llvm -o - | FileCheck %s --check-prefix=CHECK2
+// RUN: %clang_cc1 -triple powerpc64le-unknown-linux-gnu -emit-pch %s -o %t
+// RUN: %clang_cc1 -triple powerpc64le-unknown-linux-gnu -include-pch %t %s.copy.c -emit-llvm -o - | FileCheck %s --check-prefix=CHECK3
+
+
+#ifndef HEADER
+#define HEADER
void use(int);
-// CHECK-LABEL: @test(
-// CHECK-NEXT: entry:
-// CHECK-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4
-// CHECK-NEXT: store i32 [[A:%.*]], i32* [[A_ADDR]], align 4
-// CHECK-NEXT: ret void
+// CHECK1-LABEL: @test(
+// CHECK1-NEXT: entry:
+// CHECK1-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4
+// CHECK1-NEXT: store i32 [[A:%.*]], i32* [[A_ADDR]], align 4
+// CHECK1-NEXT: ret void
+//
+// CHECK2-LABEL: @test(
+// CHECK2-NEXT: entry:
+// CHECK2-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4
+// CHECK2-NEXT: store i32 [[A:%.*]], i32* [[A_ADDR]], align 4
+// CHECK2-NEXT: ret void
+//
+// CHECK3-LABEL: @test(
+// CHECK3-NEXT: entry:
+// CHECK3-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4
+// CHECK3-NEXT: store i32 [[A:%.*]], i32* [[A_ADDR]], align 4
+// CHECK3-NEXT: ret void
//
void test(int a)
{
}
+
+#endif
diff --git a/llvm/utils/update_cc_test_checks.py b/llvm/utils/update_cc_test_checks.py
index d3af5308ac6a..cbe58765f9fc 100755
--- a/llvm/utils/update_cc_test_checks.py
+++ b/llvm/utils/update_cc_test_checks.py
@@ -218,7 +218,7 @@ def main():
for ti in common.itertests(initial_args.tests, parser, 'utils/' + script_name,
comment_prefix='//', argparse_callback=infer_dependent_args):
- # Build a list of clang command lines and check prefixes from RUN lines.
+ # Build a list of filechecked and non-filechecked RUN lines.
run_list = []
line2spell_and_mangled_list = collections.defaultdict(list)
@@ -240,11 +240,10 @@ def main():
exec_args = shlex.split(commands[0])
# Execute non-clang runline.
if exec_args[0] not in SUBST:
- print('NOTE: Executing non-clang RUN line: ' + l, file=sys.stderr)
# Do lit-like substitutions.
for s in subs:
exec_args = [i.replace(s, subs[s]) if s in i else i for i in exec_args]
- exec_run_line(exec_args)
+ run_list.append((None, exec_args, None, None))
continue
# This is a clang runline, apply %clang substitution rule, do lit-like substitutions,
# and append args.clang_args
@@ -258,10 +257,9 @@ def main():
filecheck_cmd = commands[-1]
common.verify_filecheck_prefixes(filecheck_cmd)
if not filecheck_cmd.startswith('FileCheck '):
- print('NOTE: Executing non-FileChecked clang RUN line: ' + l, file=sys.stderr)
# Execute non-filechecked clang runline.
exe = [ti.args.clang] + clang_args
- exec_run_line(exe)
+ run_list.append((None, exe, None, None))
continue
check_prefixes = [item for m in common.CHECK_PREFIX_RE.finditer(filecheck_cmd)
@@ -272,12 +270,21 @@ def main():
# Execute clang, generate LLVM IR, and extract functions.
+ # Store only filechecked runlines.
+ filecheck_run_list = [i for i in run_list if i[0]]
builder = common.FunctionTestBuilder(
- run_list=run_list,
+ run_list=filecheck_run_list,
flags=ti.args,
scrubber_args=[])
- for prefixes, clang_args, extra_commands, triple_in_cmd in run_list:
+ for prefixes, args, extra_commands, triple_in_cmd in run_list:
+ # Execute non-filechecked runline.
+ if not prefixes:
+ print('NOTE: Executing non-FileChecked RUN line: ' + ' '.join(args), file=sys.stderr)
+ exec_run_line(args)
+ continue
+
+ clang_args = args
common.debug('Extracted clang cmd: clang {}'.format(clang_args))
common.debug('Extracted FileCheck prefixes: {}'.format(prefixes))
@@ -291,7 +298,7 @@ def main():
func_dict = builder.finish_and_get_func_dict()
global_vars_seen_dict = {}
- prefix_set = set([prefix for p in run_list for prefix in p[0]])
+ prefix_set = set([prefix for p in filecheck_run_list for prefix in p[0]])
output_lines = []
include_generated_funcs = common.find_arg_in_test(ti,
@@ -325,7 +332,7 @@ def check_generator(my_output_lines, prefixes, func):
prefixes,
func_dict, func)
- common.add_checks_at_end(output_lines, run_list, builder.func_order(),
+ common.add_checks_at_end(output_lines, filecheck_run_list, builder.func_order(),
'//', lambda my_output_lines, prefixes, func:
check_generator(my_output_lines,
prefixes, func))
@@ -359,7 +366,7 @@ def check_generator(my_output_lines, prefixes, func):
if added:
output_lines.append('//')
added.add(mangled)
- common.add_ir_checks(output_lines, '//', run_list, func_dict, mangled,
+ common.add_ir_checks(output_lines, '//', filecheck_run_list, func_dict, mangled,
False, args.function_signature, global_vars_seen_dict)
if line.rstrip('\n') == '//':
include_line = False
More information about the cfe-commits
mailing list