2018-03-24 05:46:16 +08:00
|
|
|
; FIXME: convert CHECK-INDIRECT into CHECK (and remove -check-prefixes) as soon
|
|
|
|
; FIXME: as new-pass-manager's handling of indirect_non_convergent_call is fixed
|
|
|
|
;
|
|
|
|
; RUN: opt -functionattrs -S < %s | FileCheck %s --check-prefixes=CHECK,CHECK-INDIRECT
|
|
|
|
; RUN: opt -passes=function-attrs -S < %s | FileCheck %s
|
2016-02-10 07:03:22 +08:00
|
|
|
|
|
|
|
; CHECK: Function Attrs
|
|
|
|
; CHECK-NOT: convergent
|
|
|
|
; CHECK-NEXT: define i32 @nonleaf()
|
|
|
|
define i32 @nonleaf() convergent {
|
|
|
|
%a = call i32 @leaf()
|
|
|
|
ret i32 %a
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK: Function Attrs
|
|
|
|
; CHECK-NOT: convergent
|
|
|
|
; CHECK-NEXT: define i32 @leaf()
|
|
|
|
define i32 @leaf() convergent {
|
|
|
|
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 {
|
2016-03-15 04:18:54 +08:00
|
|
|
%a = call i32 @k() convergent
|
2016-02-10 07:03:22 +08:00
|
|
|
ret i32 %a
|
|
|
|
}
|
|
|
|
|
2016-03-15 04:18:54 +08:00
|
|
|
; 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.
|
|
|
|
;
|
2016-02-23 01:51:35 +08:00
|
|
|
; CHECK: Function Attrs
|
|
|
|
; CHECK-SAME: convergent
|
2016-03-15 04:18:54 +08:00
|
|
|
; CHECK-NEXT: define i32 @extern_non_convergent_call()
|
|
|
|
define i32 @extern_non_convergent_call() convergent {
|
|
|
|
%a = call i32 @k()
|
2016-02-23 02:24:43 +08:00
|
|
|
ret i32 %a
|
2016-02-23 01:51:35 +08:00
|
|
|
}
|
|
|
|
|
2016-03-15 04:18:54 +08:00
|
|
|
; 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
|
|
|
|
}
|
|
|
|
; Give indirect_non_convergent_call the norecurse attribute so we get a
|
|
|
|
; "Function Attrs" comment in the output.
|
|
|
|
;
|
|
|
|
; CHECK: Function Attrs
|
2018-03-24 05:46:16 +08:00
|
|
|
; CHECK-INDIRECT-NOT: convergent
|
|
|
|
; CHECK-INDIRECT-NEXT: define i32 @indirect_non_convergent_call(
|
2016-03-15 04:18:54 +08:00
|
|
|
define i32 @indirect_non_convergent_call(i32 ()* %f) convergent norecurse {
|
|
|
|
%a = call i32 %f()
|
|
|
|
ret i32 %a
|
|
|
|
}
|
|
|
|
|
2016-02-10 07:03:22 +08:00
|
|
|
; CHECK: Function Attrs
|
|
|
|
; CHECK-SAME: convergent
|
2016-07-07 04:02:45 +08:00
|
|
|
; CHECK-NEXT: declare void @llvm.nvvm.barrier0()
|
|
|
|
declare void @llvm.nvvm.barrier0() convergent
|
2016-02-10 07:03:22 +08:00
|
|
|
|
|
|
|
; CHECK: Function Attrs
|
|
|
|
; CHECK-SAME: convergent
|
|
|
|
; CHECK-NEXT: define i32 @intrinsic()
|
|
|
|
define i32 @intrinsic() convergent {
|
2016-03-15 04:18:54 +08:00
|
|
|
; Implicitly convergent, because the intrinsic is convergent.
|
2016-07-07 04:02:45 +08:00
|
|
|
call void @llvm.nvvm.barrier0()
|
2016-02-10 07:03:22 +08:00
|
|
|
ret i32 0
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK: Function Attrs
|
|
|
|
; CHECK-NOT: convergent
|
|
|
|
; CHECK-NEXT: define i32 @recursive1()
|
|
|
|
define i32 @recursive1() convergent {
|
2016-03-15 04:18:54 +08:00
|
|
|
%a = call i32 @recursive2() convergent
|
2016-02-10 07:03:22 +08:00
|
|
|
ret i32 %a
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK: Function Attrs
|
|
|
|
; CHECK-NOT: convergent
|
|
|
|
; CHECK-NEXT: define i32 @recursive2()
|
|
|
|
define i32 @recursive2() convergent {
|
2016-03-15 04:18:54 +08:00
|
|
|
%a = call i32 @recursive1() convergent
|
2016-02-10 07:03:22 +08:00
|
|
|
ret i32 %a
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK: Function Attrs
|
|
|
|
; CHECK-SAME: convergent
|
|
|
|
; CHECK-NEXT: define i32 @noopt()
|
|
|
|
define i32 @noopt() convergent optnone noinline {
|
2016-03-15 04:18:54 +08:00
|
|
|
%a = call i32 @noopt_friend() convergent
|
2016-02-10 07:03:22 +08:00
|
|
|
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 {
|
|
|
|
%a = call i32 @noopt()
|
|
|
|
ret i32 0
|
|
|
|
}
|