Skip to content

Commit

Permalink
[UpdateTestChecks] include { in function signature check line
Browse files Browse the repository at this point in the history
After D85099, if we have attribute group in the function signature that hasn't
been seen before, and later a callsite with the same attribute group, filecheck will evaluate
the first attribute group to for example '#0 {'. We now include { in the args_and_sig group to avoid this.

Differential Revision: https://reviews.llvm.org/D86769
  • Loading branch information
sstefan1 committed Aug 28, 2020
1 parent 031554e commit 7128e64
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 22 deletions.
Expand Up @@ -3,7 +3,7 @@
// RUN: %clang_cc1 -triple=x86_64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s

// CHECK-LABEL: define {{[^@]+}}@test
// CHECK-SAME: (i64 [[A:%.*]], i32 [[B:%.*]]) [[ATTR0:#.*]]
// CHECK-SAME: (i64 [[A:%.*]], i32 [[B:%.*]]) [[ATTR0:#.*]] {
// CHECK-NEXT: entry:
// CHECK-NEXT: [[A_ADDR:%.*]] = alloca i64, align 8
// CHECK-NEXT: [[B_ADDR:%.*]] = alloca i32, align 4
Expand All @@ -21,7 +21,7 @@ long test(long a, int b) {

// A function with a mangled name
// CHECK-LABEL: define {{[^@]+}}@_Z4testlii
// CHECK-SAME: (i64 [[A:%.*]], i32 [[B:%.*]], i32 [[C:%.*]]) [[ATTR0]]
// CHECK-SAME: (i64 [[A:%.*]], i32 [[B:%.*]], i32 [[C:%.*]]) [[ATTR0]] {
// CHECK-NEXT: entry:
// CHECK-NEXT: [[A_ADDR:%.*]] = alloca i64, align 8
// CHECK-NEXT: [[B_ADDR:%.*]] = alloca i32, align 4
Expand Down
Expand Up @@ -3,7 +3,7 @@

define i32 @reuse_arg_names(i32 %X, i32 %Y) {
; CHECK-LABEL: define {{[^@]+}}@reuse_arg_names
; CHECK-SAME: (i32 [[X:%.*]], i32 [[Y:%.*]])
; CHECK-SAME: (i32 [[X:%.*]], i32 [[Y:%.*]]) {
; CHECK-NEXT: [[Z:%.*]] = sub i32 [[X]], [[Y]]
; CHECK-NEXT: [[Q:%.*]] = add i32 [[Z]], [[Y]]
; CHECK-NEXT: ret i32 [[Q]]
Expand Down
Expand Up @@ -4,7 +4,7 @@

define i32 @common_sub_operand(i32 %X, i32 %Y) {
; CHECK-LABEL: define {{[^@]+}}@common_sub_operand
; CHECK-SAME: (i32 [[X:%.*]], i32 [[Y:%.*]])
; CHECK-SAME: (i32 [[X:%.*]], i32 [[Y:%.*]]) {
; CHECK-NEXT: ret i32 [[X]]
;
%Z = sub i32 %X, %Y
Expand All @@ -14,7 +14,7 @@ define i32 @common_sub_operand(i32 %X, i32 %Y) {

define i32 @negated_operand(i32 %x) {
; CHECK-LABEL: define {{[^@]+}}@negated_operand
; CHECK-SAME: (i32 [[X:%.*]])
; CHECK-SAME: (i32 [[X:%.*]]) {
; CHECK-NEXT: ret i32 0
;
%negx = sub i32 0, %x
Expand All @@ -24,7 +24,7 @@ define i32 @negated_operand(i32 %x) {

define <2 x i32> @negated_operand_commute_vec(<2 x i32> %x) {
; CHECK-LABEL: define {{[^@]+}}@negated_operand_commute_vec
; CHECK-SAME: (<2 x i32> [[X:%.*]])
; CHECK-SAME: (<2 x i32> [[X:%.*]]) {
; CHECK-NEXT: ret <2 x i32> zeroinitializer
;
%negx = sub <2 x i32> zeroinitializer, %x
Expand All @@ -34,7 +34,7 @@ define <2 x i32> @negated_operand_commute_vec(<2 x i32> %x) {

define i8 @knownnegation(i8 %x, i8 %y) {
; CHECK-LABEL: define {{[^@]+}}@knownnegation
; CHECK-SAME: (i8 [[X:%.*]], i8 [[Y:%.*]])
; CHECK-SAME: (i8 [[X:%.*]], i8 [[Y:%.*]]) {
; CHECK-NEXT: ret i8 0
;
%xy = sub i8 %x, %y
Expand All @@ -45,7 +45,7 @@ define i8 @knownnegation(i8 %x, i8 %y) {

define <2 x i8> @knownnegation_commute_vec(<2 x i8> %x, <2 x i8> %y) {
; CHECK-LABEL: define {{[^@]+}}@knownnegation_commute_vec
; CHECK-SAME: (<2 x i8> [[X:%.*]], <2 x i8> [[Y:%.*]])
; CHECK-SAME: (<2 x i8> [[X:%.*]], <2 x i8> [[Y:%.*]]) {
; CHECK-NEXT: ret <2 x i8> zeroinitializer
;
%xy = sub <2 x i8> %x, %y
Expand All @@ -56,7 +56,7 @@ define <2 x i8> @knownnegation_commute_vec(<2 x i8> %x, <2 x i8> %y) {

define i32 @nameless_value(i32 %X) {
; CHECK-LABEL: define {{[^@]+}}@nameless_value
; CHECK-SAME: (i32 [[X:%.*]])
; CHECK-SAME: (i32 [[X:%.*]]) {
; CHECK-NEXT: [[TMP1:%.*]] = sub i32 42, [[X]]
; CHECK-NEXT: ret i32 [[TMP1]]
;
Expand Down
Expand Up @@ -10,14 +10,14 @@
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:%.*]]) [[ATTR0:#.*]]
; IS__TUNIT____-SAME: (%struct.ST* nofree readnone [[S:%.*]]) [[ATTR0:#.*]] {
; 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:%.*]]) [[ATTR0:#.*]]
; IS__CGSCC____-SAME: (%struct.ST* nofree readnone [[S:%.*]]) [[ATTR0:#.*]] {
; 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]]
Expand Down
Expand Up @@ -9,7 +9,7 @@

define i32* @foo(%struct.ST* %s) nounwind uwtable readnone optsize ssp {
; CHECK-LABEL: define {{[^@]+}}@foo
; CHECK-SAME: (%struct.ST* nofree readnone [[S:%.*]]) [[ATTR0:#.*]]
; CHECK-SAME: (%struct.ST* nofree readnone [[S:%.*]]) [[ATTR0:#.*]] {
; 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]]
Expand Down
Expand Up @@ -4,7 +4,7 @@
declare void @foo()

define void @check_lines_1() {
; CHECK-LABEL: define {{[^@]+}}@check_lines_1()
; CHECK-LABEL: define {{[^@]+}}@check_lines_1() {
; CHECK-NEXT: ret void
;
ret void
Expand All @@ -21,14 +21,14 @@ define void @no_check_lines() {
; UTC_ARGS: --enable

define void @check_lines_2() {
; CHECK-LABEL: define {{[^@]+}}@check_lines_2()
; CHECK-LABEL: define {{[^@]+}}@check_lines_2() {
; CHECK-NEXT: ret void
;
ret void
}

define void @scrub() {
; CHECK-LABEL: define {{[^@]+}}@scrub()
; CHECK-LABEL: define {{[^@]+}}@scrub() {
; CHECK-NEXT: call void @foo()
; CHECK-NEXT: ret void
;
Expand All @@ -38,7 +38,7 @@ define void @scrub() {

define i32 @signature(i32 %arg) {
; CHECK-LABEL: define {{[^@]+}}@signature
; CHECK-SAME: (i32 [[ARG:%.*]])
; CHECK-SAME: (i32 [[ARG:%.*]]) {
; CHECK-NEXT: ret i32 [[ARG]]
;
ret i32 %arg
Expand Down
Expand Up @@ -18,14 +18,14 @@ define void @no_check_lines() {
; UTC_ARGS: --enable

define void @check_lines_2() {
; CHECK-LABEL: define {{[^@]+}}@check_lines_2()
; CHECK-LABEL: define {{[^@]+}}@check_lines_2() {
; CHECK-NEXT: ret void
;
ret void
}

define void @scrub() {
; CHECK-LABEL: define {{[^@]+}}@scrub()
; CHECK-LABEL: define {{[^@]+}}@scrub() {
; CHECK-NEXT: call void @foo()
; CHECK-NEXT: ret void
;
Expand All @@ -35,7 +35,7 @@ define void @scrub() {

define i32 @signature(i32 %arg) {
; CHECK-LABEL: define {{[^@]+}}@signature
; CHECK-SAME: (i32 [[ARG:%.*]])
; CHECK-SAME: (i32 [[ARG:%.*]]) {
; CHECK-NEXT: ret i32 [[ARG]]
;
ret i32 %arg
Expand Down
Expand Up @@ -10,7 +10,7 @@ target triple = "x86_64-unknown-linux-gnu"
; Function Attrs: nounwind uwtable
define dso_local void @foo(i32* %A) #0 !dbg !7 {
; CHECK-LABEL: define {{[^@]+}}@foo
; CHECK-SAME: (i32* [[A:%.*]]) [[ATTR0:#.*]] [[DBG7:!dbg !.*]]
; CHECK-SAME: (i32* [[A:%.*]]) [[ATTR0:#.*]] [[DBG7:!dbg !.*]] {
; CHECK-NEXT: entry:
; CHECK-NEXT: [[A_ADDR:%.*]] = alloca i32*, align 8
; CHECK-NEXT: [[I:%.*]] = alloca i32, align 4
Expand Down Expand Up @@ -99,7 +99,7 @@ declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #2
; Function Attrs: nounwind uwtable
define dso_local void @bar(i32* %A) #0 !dbg !39 {
; CHECK-LABEL: define {{[^@]+}}@bar
; CHECK-SAME: (i32* [[A:%.*]]) [[ATTR0]] [[DBG39:!dbg !.*]]
; CHECK-SAME: (i32* [[A:%.*]]) [[ATTR0]] [[DBG39:!dbg !.*]] {
; CHECK-NEXT: entry:
; CHECK-NEXT: [[A_ADDR:%.*]] = alloca i32*, align 8
; CHECK-NEXT: [[I:%.*]] = alloca i32, align 4
Expand Down
2 changes: 1 addition & 1 deletion llvm/utils/UpdateTestChecks/common.py
Expand Up @@ -146,7 +146,7 @@ def invoke_tool(exe, cmd_args, ir):

OPT_FUNCTION_RE = re.compile(
r'^(\s*;\s*Function\sAttrs:\s(?P<attrs>[\w\s]+?))?\s*define\s+(?:internal\s+)?[^@]*@(?P<func>[\w.-]+?)\s*'
r'(?P<args_and_sig>\((\)|(.*?[\w.-]+?)\))[^{]*)\{\n(?P<body>.*?)^\}$',
r'(?P<args_and_sig>\((\)|(.*?[\w.-]+?)\))[^{]*\{)\n(?P<body>.*?)^\}$',
flags=(re.M | re.S))

ANALYZE_FUNCTION_RE = re.compile(
Expand Down

0 comments on commit 7128e64

Please sign in to comment.