-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace func name with regex in update_cc_test_checks
The patch adds an argument to update_cc_test_checks for replacing a function name matching a regex. This functionality is needed to match generated function signatures that include file hashes. Example: The function signature for the following function: `__omp_offloading_50_b84c41e__Z9ftemplateIiET_i_l30_worker` with `--replace-function-regex "__omp_offloading_[0-9]+_[a-z0-9]+_(.*)"` will become: `CHECK-LABEL: @{{__omp_offloading_[0-9]+_[a-z0-9]+__Z9ftemplateIiET_i_l30_worker}}(` Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D97107
- Loading branch information
1 parent
6a291ed
commit bf58d6a
Showing
4 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
clang/test/utils/update_cc_test_checks/Inputs/generated-funcs-regex.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fopenmp %s -emit-llvm -o - | FileCheck %s | ||
|
||
void __test_offloading_42_abcdef_bar_l123(); | ||
void use(int); | ||
|
||
void foo(int a) | ||
{ | ||
#pragma omp target | ||
use(a); | ||
|
||
__test_offloading_42_abcdef_bar_l123(); | ||
} |
36 changes: 36 additions & 0 deletions
36
clang/test/utils/update_cc_test_checks/Inputs/generated-funcs-regex.c.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --include-generated-funcs --replace-function-regex "__([a-z]+)_offloading_[a-z0-9]+_[a-z0-9]+_(.*)_l[0-9]+" | ||
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fopenmp %s -emit-llvm -o - | FileCheck %s | ||
|
||
void __test_offloading_42_abcdef_bar_l123(); | ||
void use(int); | ||
|
||
void foo(int a) | ||
{ | ||
#pragma omp target | ||
use(a); | ||
|
||
__test_offloading_42_abcdef_bar_l123(); | ||
} | ||
// CHECK-LABEL: @foo( | ||
// CHECK-NEXT: entry: | ||
// CHECK-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4 | ||
// CHECK-NEXT: [[A_CASTED:%.*]] = alloca i64, align 8 | ||
// CHECK-NEXT: store i32 [[A:%.*]], i32* [[A_ADDR]], align 4 | ||
// CHECK-NEXT: [[TMP0:%.*]] = load i32, i32* [[A_ADDR]], align 4 | ||
// CHECK-NEXT: [[CONV:%.*]] = bitcast i64* [[A_CASTED]] to i32* | ||
// CHECK-NEXT: store i32 [[TMP0]], i32* [[CONV]], align 4 | ||
// CHECK-NEXT: [[TMP1:%.*]] = load i64, i64* [[A_CASTED]], align 8 | ||
// CHECK-NEXT: call void @{{__omp_offloading_[a-z0-9]+_[a-z0-9]+_foo_l[0-9]+}}(i64 [[TMP1]]) [[ATTR3:#.*]] | ||
// CHECK-NEXT: call void (...) @{{__test_offloading_[a-z0-9]+_[a-z0-9]+_bar_l[0-9]+}}() | ||
// CHECK-NEXT: ret void | ||
// | ||
// | ||
// CHECK-LABEL: @{{__omp_offloading_[a-z0-9]+_[a-z0-9]+_foo_l[0-9]+}}( | ||
// CHECK-NEXT: entry: | ||
// CHECK-NEXT: [[A_ADDR:%.*]] = alloca i64, align 8 | ||
// CHECK-NEXT: store i64 [[A:%.*]], i64* [[A_ADDR]], align 8 | ||
// CHECK-NEXT: [[CONV:%.*]] = bitcast i64* [[A_ADDR]] to i32* | ||
// CHECK-NEXT: [[TMP0:%.*]] = load i32, i32* [[CONV]], align 8 | ||
// CHECK-NEXT: call void @use(i32 [[TMP0]]) | ||
// CHECK-NEXT: ret void | ||
// |
9 changes: 9 additions & 0 deletions
9
clang/test/utils/update_cc_test_checks/generated-funcs-regex.test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
## Test that CHECK lines are generated for clang-generated functions replaced | ||
## by regex | ||
|
||
## RUN: cp %S/Inputs/generated-funcs-regex.c %t-generated-funcs-regex.c && %update_cc_test_checks --include-generated-funcs --replace-function-regex "__([a-z]+)_offloading_[a-z0-9]+_[a-z0-9]+_(.*)_l[0-9]+" -- %t-generated-funcs-regex.c | ||
# RUN: diff -u %S/Inputs/generated-funcs-regex.c.expected %t-generated-funcs-regex.c | ||
|
||
## Check that re-running update_cc_test_checks doesn't change the output | ||
# RUN: %update_cc_test_checks %t-generated-funcs-regex.c | ||
# RUN: diff -u %S/Inputs/generated-funcs-regex.c.expected %t-generated-funcs-regex.c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters