forked from intel/llvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Utils] Check function attributes in update_test_checks
Summary: This introduces new flag to the update_test_checks and update_cc_test_checks that allows for function attributes to be checked in a check-line. If the flag is not set, the behavior should remain the same. Reviewers: jdoerfert Subscribers: arichardson, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D83629
- Loading branch information
sstefan1
committed
Jul 19, 2020
1 parent
f7a5715
commit 937bad3
Showing
13 changed files
with
183 additions
and
19 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp
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,15 @@ | ||
// RUN: %clang_cc1 -triple=x86_64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s | ||
struct RT { | ||
char A; | ||
int B[10][20]; | ||
char C; | ||
}; | ||
struct ST { | ||
int X; | ||
double Y; | ||
struct RT Z; | ||
}; | ||
|
||
int *foo(struct ST *s) { | ||
return &s[1].Z.B[5][13]; | ||
} |
29 changes: 29 additions & 0 deletions
29
clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp.funcattrs.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,29 @@ | ||
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --check-attributes | ||
// RUN: %clang_cc1 -triple=x86_64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s | ||
struct RT { | ||
char A; | ||
int B[10][20]; | ||
char C; | ||
}; | ||
struct ST { | ||
int X; | ||
double Y; | ||
struct RT Z; | ||
}; | ||
|
||
// CHECK: Function Attrs: noinline nounwind optnone; | ||
// CHECK-LABEL: @_Z3fooP2ST( | ||
// CHECK-NEXT: entry: | ||
// CHECK-NEXT: [[S_ADDR:%.*]] = alloca %struct.ST*, align 8 | ||
// CHECK-NEXT: store %struct.ST* [[S:%.*]], %struct.ST** [[S_ADDR]], align 8 | ||
// CHECK-NEXT: [[TMP0:%.*]] = load %struct.ST*, %struct.ST** [[S_ADDR]], align 8 | ||
// CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds [[STRUCT_ST:%.*]], %struct.ST* [[TMP0]], i64 1 | ||
// CHECK-NEXT: [[Z:%.*]] = getelementptr inbounds [[STRUCT_ST]], %struct.ST* [[ARRAYIDX]], i32 0, i32 2 | ||
// CHECK-NEXT: [[B:%.*]] = getelementptr inbounds [[STRUCT_RT:%.*]], %struct.RT* [[Z]], i32 0, i32 1 | ||
// CHECK-NEXT: [[ARRAYIDX1:%.*]] = getelementptr inbounds [10 x [20 x i32]], [10 x [20 x i32]]* [[B]], i64 0, i64 5 | ||
// CHECK-NEXT: [[ARRAYIDX2:%.*]] = getelementptr inbounds [20 x i32], [20 x i32]* [[ARRAYIDX1]], i64 0, i64 13 | ||
// CHECK-NEXT: ret i32* [[ARRAYIDX2]] | ||
// | ||
int *foo(struct ST *s) { | ||
return &s[1].Z.B[5][13]; | ||
} |
28 changes: 28 additions & 0 deletions
28
clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp.plain.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,28 @@ | ||
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py | ||
// RUN: %clang_cc1 -triple=x86_64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s | ||
struct RT { | ||
char A; | ||
int B[10][20]; | ||
char C; | ||
}; | ||
struct ST { | ||
int X; | ||
double Y; | ||
struct RT Z; | ||
}; | ||
|
||
// CHECK-LABEL: @_Z3fooP2ST( | ||
// CHECK-NEXT: entry: | ||
// CHECK-NEXT: [[S_ADDR:%.*]] = alloca %struct.ST*, align 8 | ||
// CHECK-NEXT: store %struct.ST* [[S:%.*]], %struct.ST** [[S_ADDR]], align 8 | ||
// CHECK-NEXT: [[TMP0:%.*]] = load %struct.ST*, %struct.ST** [[S_ADDR]], align 8 | ||
// CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds [[STRUCT_ST:%.*]], %struct.ST* [[TMP0]], i64 1 | ||
// CHECK-NEXT: [[Z:%.*]] = getelementptr inbounds [[STRUCT_ST]], %struct.ST* [[ARRAYIDX]], i32 0, i32 2 | ||
// CHECK-NEXT: [[B:%.*]] = getelementptr inbounds [[STRUCT_RT:%.*]], %struct.RT* [[Z]], i32 0, i32 1 | ||
// CHECK-NEXT: [[ARRAYIDX1:%.*]] = getelementptr inbounds [10 x [20 x i32]], [10 x [20 x i32]]* [[B]], i64 0, i64 5 | ||
// CHECK-NEXT: [[ARRAYIDX2:%.*]] = getelementptr inbounds [20 x i32], [20 x i32]* [[ARRAYIDX1]], i64 0, i64 13 | ||
// CHECK-NEXT: ret i32* [[ARRAYIDX2]] | ||
// | ||
int *foo(struct ST *s) { | ||
return &s[1].Z.B[5][13]; | ||
} |
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 as expected without --check-attributes | ||
# RUN: cp %S/Inputs/check-attributes.cpp %t.cpp && %update_cc_test_checks %t.cpp | ||
# RUN: diff -u %S/Inputs/check-attributes.cpp.plain.expected %t.cpp | ||
## Test with --check-attributes flag. | ||
# RUN: cp %S/Inputs/check-attributes.cpp %t.cpp && %update_cc_test_checks %t.cpp --check-attributes | ||
# RUN: diff -u %S/Inputs/check-attributes.cpp.funcattrs.expected %t.cpp | ||
## Check that re-running update_cc_test_checks doesn't change the output | ||
# RUN: %update_cc_test_checks %t.cpp | ||
# RUN: diff -u %S/Inputs/check-attributes.cpp.funcattrs.expected %t.cpp |
13 changes: 13 additions & 0 deletions
13
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/check_attrs.ll
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,13 @@ | ||
; RUN: opt -attributor -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_CGSCC_NPM,NOT_CGSCC_OPM,NOT_TUNIT_NPM,IS__TUNIT____,IS________OPM,IS__TUNIT_OPM | ||
; RUN: opt -aa-pipeline=basic-aa -passes=attributor -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_CGSCC_OPM,NOT_CGSCC_NPM,NOT_TUNIT_OPM,IS__TUNIT____,IS________NPM,IS__TUNIT_NPM | ||
; RUN: opt -attributor-cgscc -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_TUNIT_NPM,NOT_TUNIT_OPM,NOT_CGSCC_NPM,IS__CGSCC____,IS________OPM,IS__CGSCC_OPM | ||
; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_TUNIT_NPM,NOT_TUNIT_OPM,NOT_CGSCC_OPM,IS__CGSCC____,IS________NPM,IS__CGSCC_NPM | ||
|
||
%struct.RT = type { i8, [10 x [20 x i32]], i8 } | ||
%struct.ST = type { i32, double, %struct.RT } | ||
|
||
define i32* @foo(%struct.ST* %s) nounwind uwtable readnone optsize ssp { | ||
entry: | ||
%arrayidx = getelementptr inbounds %struct.ST, %struct.ST* %s, i64 1, i32 2, i32 1, i64 5, i64 13 | ||
ret i32* %arrayidx | ||
} |
28 changes: 28 additions & 0 deletions
28
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/check_attrs.ll.funcattrs.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,28 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes | ||
; RUN: opt -attributor -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_CGSCC_NPM,NOT_CGSCC_OPM,NOT_TUNIT_NPM,IS__TUNIT____,IS________OPM,IS__TUNIT_OPM | ||
; RUN: opt -aa-pipeline=basic-aa -passes=attributor -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_CGSCC_OPM,NOT_CGSCC_NPM,NOT_TUNIT_OPM,IS__TUNIT____,IS________NPM,IS__TUNIT_NPM | ||
; RUN: opt -attributor-cgscc -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_TUNIT_NPM,NOT_TUNIT_OPM,NOT_CGSCC_NPM,IS__CGSCC____,IS________OPM,IS__CGSCC_OPM | ||
; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_TUNIT_NPM,NOT_TUNIT_OPM,NOT_CGSCC_OPM,IS__CGSCC____,IS________NPM,IS__CGSCC_NPM | ||
|
||
%struct.RT = type { i8, [10 x [20 x i32]], i8 } | ||
%struct.ST = type { i32, double, %struct.RT } | ||
|
||
define i32* @foo(%struct.ST* %s) nounwind uwtable readnone optsize ssp { | ||
; IS__TUNIT____: Function Attrs: nofree nosync nounwind optsize readnone ssp uwtable willreturn; | ||
; IS__TUNIT____-LABEL: define {{[^@]+}}@foo | ||
; IS__TUNIT____-SAME: (%struct.ST* nofree readnone [[S:%.*]]) #0 | ||
; IS__TUNIT____-NEXT: entry: | ||
; IS__TUNIT____-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds [[STRUCT_ST:%.*]], %struct.ST* [[S]], i64 1, i32 2, i32 1, i64 5, i64 13 | ||
; IS__TUNIT____-NEXT: ret i32* [[ARRAYIDX]] | ||
; | ||
; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind optsize readnone ssp uwtable willreturn; | ||
; IS__CGSCC____-LABEL: define {{[^@]+}}@foo | ||
; IS__CGSCC____-SAME: (%struct.ST* nofree readnone [[S:%.*]]) #0 | ||
; IS__CGSCC____-NEXT: entry: | ||
; IS__CGSCC____-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds [[STRUCT_ST:%.*]], %struct.ST* [[S]], i64 1, i32 2, i32 1, i64 5, i64 13 | ||
; IS__CGSCC____-NEXT: ret i32* [[ARRAYIDX]] | ||
; | ||
entry: | ||
%arrayidx = getelementptr inbounds %struct.ST, %struct.ST* %s, i64 1, i32 2, i32 1, i64 5, i64 13 | ||
ret i32* %arrayidx | ||
} |
20 changes: 20 additions & 0 deletions
20
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/check_attrs.ll.plain.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,20 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature | ||
; RUN: opt -attributor -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_CGSCC_NPM,NOT_CGSCC_OPM,NOT_TUNIT_NPM,IS__TUNIT____,IS________OPM,IS__TUNIT_OPM | ||
; RUN: opt -aa-pipeline=basic-aa -passes=attributor -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_CGSCC_OPM,NOT_CGSCC_NPM,NOT_TUNIT_OPM,IS__TUNIT____,IS________NPM,IS__TUNIT_NPM | ||
; RUN: opt -attributor-cgscc -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_TUNIT_NPM,NOT_TUNIT_OPM,NOT_CGSCC_NPM,IS__CGSCC____,IS________OPM,IS__CGSCC_OPM | ||
; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_TUNIT_NPM,NOT_TUNIT_OPM,NOT_CGSCC_OPM,IS__CGSCC____,IS________NPM,IS__CGSCC_NPM | ||
|
||
%struct.RT = type { i8, [10 x [20 x i32]], i8 } | ||
%struct.ST = type { i32, double, %struct.RT } | ||
|
||
define i32* @foo(%struct.ST* %s) nounwind uwtable readnone optsize ssp { | ||
; CHECK-LABEL: define {{[^@]+}}@foo | ||
; CHECK-SAME: (%struct.ST* nofree readnone [[S:%.*]]) #0 | ||
; CHECK-NEXT: entry: | ||
; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds [[STRUCT_ST:%.*]], %struct.ST* [[S]], i64 1, i32 2, i32 1, i64 5, i64 13 | ||
; CHECK-NEXT: ret i32* [[ARRAYIDX]] | ||
; | ||
entry: | ||
%arrayidx = getelementptr inbounds %struct.ST, %struct.ST* %s, i64 1, i32 2, i32 1, i64 5, i64 13 | ||
ret i32* %arrayidx | ||
} |
9 changes: 9 additions & 0 deletions
9
llvm/test/tools/UpdateTestChecks/update_test_checks/check_attrs.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 @@ | ||
## check_attrs test checking that update_test_checks.py works correctly | ||
# RUN: cp -f %S/Inputs/check_attrs.ll %t.ll && %update_test_checks %t.ll --function-signature | ||
# RUN: diff -u %t.ll %S/Inputs/check_attrs.ll.plain.expected | ||
## Also try the --check-attributes flag | ||
# RUN: %update_test_checks %t.ll --check-attributes --function-signature | ||
# RUN: diff -u %t.ll %S/Inputs/check_attrs.ll.funcattrs.expected | ||
## Check that running the script again does not change the result: | ||
# RUN: %update_test_checks %t.ll | ||
# RUN: diff -u %t.ll %S/Inputs/check_attrs.ll.funcattrs.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
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
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
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
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