Skip to content

Commit

Permalink
[FunctionAttrs] Regenerate test checks (NFC)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikic committed Oct 13, 2022
1 parent 5b37768 commit 45e5958
Show file tree
Hide file tree
Showing 3 changed files with 277 additions and 154 deletions.
116 changes: 70 additions & 46 deletions llvm/test/Transforms/FunctionAttrs/convergent.ll
@@ -1,107 +1,131 @@
; RUN: opt -function-attrs -S < %s | FileCheck %s
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes
; RUN: opt -passes=function-attrs -S < %s | FileCheck %s

; CHECK: Function Attrs
; CHECK-NOT: convergent
; CHECK-NEXT: define i32 @nonleaf()
define i32 @nonleaf() convergent {
; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn
; CHECK-LABEL: define {{[^@]+}}@nonleaf
; CHECK-SAME: () #[[ATTR0:[0-9]+]] {
; CHECK-NEXT: [[A:%.*]] = call i32 @leaf()
; CHECK-NEXT: ret i32 [[A]]
;
%a = call i32 @leaf()
ret i32 %a
}

; CHECK: Function Attrs
; CHECK-NOT: convergent
; CHECK-NEXT: define i32 @leaf()
define i32 @leaf() convergent {
; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn
; CHECK-LABEL: define {{[^@]+}}@leaf
; CHECK-SAME: () #[[ATTR0]] {
; CHECK-NEXT: ret i32 0
;
ret i32 0
}

; CHECK: Function Attrs
; CHECK-SAME: convergent
; CHECK-NEXT: declare i32 @k()
declare i32 @k() convergent

; CHECK: Function Attrs
; CHECK-SAME: convergent
; CHECK-NEXT: define i32 @extern()
define i32 @extern() convergent {
; CHECK: Function Attrs: convergent
; CHECK-LABEL: define {{[^@]+}}@extern
; CHECK-SAME: () #[[ATTR1:[0-9]+]] {
; CHECK-NEXT: [[A:%.*]] = call i32 @k() #[[ATTR1]]
; CHECK-NEXT: ret i32 [[A]]
;
%a = call i32 @k() convergent
ret i32 %a
}

; Convergent should not be removed on the function here. Although the call is
; not explicitly convergent, it picks up the convergent attr from the callee.
;
; CHECK: Function Attrs
; CHECK-SAME: convergent
; CHECK-NEXT: define i32 @extern_non_convergent_call()
define i32 @extern_non_convergent_call() convergent {
; CHECK: Function Attrs: convergent
; CHECK-LABEL: define {{[^@]+}}@extern_non_convergent_call
; CHECK-SAME: () #[[ATTR1]] {
; CHECK-NEXT: [[A:%.*]] = call i32 @k()
; CHECK-NEXT: ret i32 [[A]]
;
%a = call i32 @k()
ret i32 %a
}

; CHECK: Function Attrs
; CHECK-SAME: convergent
; CHECK-NEXT: define i32 @indirect_convergent_call(
define i32 @indirect_convergent_call(i32 ()* %f) convergent {
%a = call i32 %f() convergent
ret i32 %a
; CHECK: Function Attrs: convergent
; CHECK-LABEL: define {{[^@]+}}@indirect_convergent_call
; CHECK-SAME: (i32 ()* nocapture readonly [[F:%.*]]) #[[ATTR1]] {
; CHECK-NEXT: [[A:%.*]] = call i32 [[F]]() #[[ATTR1]]
; CHECK-NEXT: ret i32 [[A]]
;
%a = call i32 %f() convergent
ret i32 %a
}
; Give indirect_non_convergent_call the norecurse attribute so we get a
; "Function Attrs" comment in the output.
;
; CHECK: Function Attrs
; CHECK-NOT: convergent
; CHECK-NEXT: define i32 @indirect_non_convergent_call(
define i32 @indirect_non_convergent_call(i32 ()* %f) convergent norecurse {
%a = call i32 %f()
ret i32 %a
; CHECK: Function Attrs: norecurse
; CHECK-LABEL: define {{[^@]+}}@indirect_non_convergent_call
; CHECK-SAME: (i32 ()* nocapture readonly [[F:%.*]]) #[[ATTR2:[0-9]+]] {
; CHECK-NEXT: [[A:%.*]] = call i32 [[F]]()
; CHECK-NEXT: ret i32 [[A]]
;
%a = call i32 %f()
ret i32 %a
}

; CHECK: Function Attrs
; CHECK-SAME: convergent
; CHECK-NEXT: declare void @llvm.nvvm.barrier0()
declare void @llvm.nvvm.barrier0() convergent

; CHECK: Function Attrs
; CHECK-SAME: convergent
; CHECK-NEXT: define i32 @intrinsic()
define i32 @intrinsic() convergent {
; Implicitly convergent, because the intrinsic is convergent.
; CHECK: Function Attrs: convergent nounwind
; CHECK-LABEL: define {{[^@]+}}@intrinsic
; CHECK-SAME: () #[[ATTR4:[0-9]+]] {
; CHECK-NEXT: call void @llvm.nvvm.barrier0()
; CHECK-NEXT: ret i32 0
;
call void @llvm.nvvm.barrier0()
ret i32 0
}

; CHECK: Function Attrs
; CHECK-NOT: convergent
; CHECK-NEXT: define i32 @recursive1()
define i32 @recursive1() convergent {
; CHECK: Function Attrs: nofree nosync nounwind readnone
; CHECK-LABEL: define {{[^@]+}}@recursive1
; CHECK-SAME: () #[[ATTR5:[0-9]+]] {
; CHECK-NEXT: [[A:%.*]] = call i32 @recursive2() #[[ATTR1]]
; CHECK-NEXT: ret i32 [[A]]
;
%a = call i32 @recursive2() convergent
ret i32 %a
}

; CHECK: Function Attrs
; CHECK-NOT: convergent
; CHECK-NEXT: define i32 @recursive2()
define i32 @recursive2() convergent {
; CHECK: Function Attrs: nofree nosync nounwind readnone
; CHECK-LABEL: define {{[^@]+}}@recursive2
; CHECK-SAME: () #[[ATTR5]] {
; CHECK-NEXT: [[A:%.*]] = call i32 @recursive1() #[[ATTR1]]
; CHECK-NEXT: ret i32 [[A]]
;
%a = call i32 @recursive1() convergent
ret i32 %a
}

; CHECK: Function Attrs
; CHECK-SAME: convergent
; CHECK-NEXT: define i32 @noopt()
define i32 @noopt() convergent optnone noinline {
; CHECK: Function Attrs: convergent noinline optnone
; CHECK-LABEL: define {{[^@]+}}@noopt
; CHECK-SAME: () #[[ATTR6:[0-9]+]] {
; CHECK-NEXT: [[A:%.*]] = call i32 @noopt_friend() #[[ATTR1]]
; CHECK-NEXT: ret i32 0
;
%a = call i32 @noopt_friend() convergent
ret i32 0
}

; A function which is mutually-recursive with a convergent, optnone function
; shouldn't have its convergent attribute stripped.
; CHECK: Function Attrs
; CHECK-SAME: convergent
; CHECK-NEXT: define i32 @noopt_friend()
define i32 @noopt_friend() convergent {
; CHECK: Function Attrs: convergent
; CHECK-LABEL: define {{[^@]+}}@noopt_friend
; CHECK-SAME: () #[[ATTR1]] {
; CHECK-NEXT: [[A:%.*]] = call i32 @noopt()
; CHECK-NEXT: ret i32 0
;
%a = call i32 @noopt()
ret i32 0
}

0 comments on commit 45e5958

Please sign in to comment.