summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/FunctionAttrs
diff options
context:
space:
mode:
authorJustin Lebar <jlebar@google.com>2016-02-22 17:51:35 +0000
committerJustin Lebar <jlebar@google.com>2016-02-22 17:51:35 +0000
commit7bf9187abbdbe5c789528bc4961a56baed2eb303 (patch)
tree8c176fadbfe52f6d854c4edb03fc9dfa8112164e /llvm/test/Transforms/FunctionAttrs
parentf62b165a0403434999cf77e265ce3dafce8dddcc (diff)
downloadbcm5719-llvm-7bf9187abbdbe5c789528bc4961a56baed2eb303.tar.gz
bcm5719-llvm-7bf9187abbdbe5c789528bc4961a56baed2eb303.zip
[attrs] Handle convergent CallSites.
Summary: Previously we had a notion of convergent functions but not of convergent calls. This is insufficient to correctly analyze calls where the target is unknown, e.g. indirect calls. Now a call is convergent if it targets a known-convergent function, or if it's explicitly marked as convergent. As usual, we can remove convergent where we can prove that no convergent operations are performed in the call. Reviewers: chandlerc, jingyue Subscribers: hfinkel, jhen, tra, llvm-commits Differential Revision: http://reviews.llvm.org/D17317 llvm-svn: 261544
Diffstat (limited to 'llvm/test/Transforms/FunctionAttrs')
-rw-r--r--llvm/test/Transforms/FunctionAttrs/convergent.ll48
1 files changed, 30 insertions, 18 deletions
diff --git a/llvm/test/Transforms/FunctionAttrs/convergent.ll b/llvm/test/Transforms/FunctionAttrs/convergent.ll
index 46370d7bf30..bc21d85ec22 100644
--- a/llvm/test/Transforms/FunctionAttrs/convergent.ll
+++ b/llvm/test/Transforms/FunctionAttrs/convergent.ll
@@ -1,4 +1,4 @@
-; RUN: opt < %s -basicaa -functionattrs -rpo-functionattrs -S | FileCheck %s
+; RUN: opt -functionattrs -S < %s | FileCheck %s
; CHECK: Function Attrs
; CHECK-NOT: convergent
@@ -24,20 +24,41 @@ declare i32 @k() convergent
; CHECK-SAME: convergent
; CHECK-NEXT: define i32 @extern()
define i32 @extern() convergent {
- %a = call i32 @k()
+ %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 @call_extern()
-define i32 @call_extern() convergent {
- %a = call i32 @extern()
+; CHECK-NEXT: define i32 @extern_non_convergent_call()
+define i32 @extern_non_convergent_call() convergent {
+ %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
+}
+; 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
+; CHECK-SAME: convergent
; CHECK-NEXT: declare void @llvm.cuda.syncthreads()
declare void @llvm.cuda.syncthreads() convergent
@@ -45,25 +66,16 @@ declare void @llvm.cuda.syncthreads() convergent
; CHECK-SAME: convergent
; CHECK-NEXT: define i32 @intrinsic()
define i32 @intrinsic() convergent {
+ ; Implicitly convergent, because the intrinsic is convergent.
call void @llvm.cuda.syncthreads()
ret i32 0
}
-@xyz = global i32 ()* null
-; CHECK: Function Attrs
-; CHECK-SAME: convergent
-; CHECK-NEXT: define i32 @functionptr()
-define i32 @functionptr() convergent {
- %1 = load i32 ()*, i32 ()** @xyz
- %2 = call i32 %1()
- ret i32 %2
-}
-
; CHECK: Function Attrs
; CHECK-NOT: convergent
; CHECK-NEXT: define i32 @recursive1()
define i32 @recursive1() convergent {
- %a = call i32 @recursive2()
+ %a = call i32 @recursive2() convergent
ret i32 %a
}
@@ -71,7 +83,7 @@ define i32 @recursive1() convergent {
; CHECK-NOT: convergent
; CHECK-NEXT: define i32 @recursive2()
define i32 @recursive2() convergent {
- %a = call i32 @recursive1()
+ %a = call i32 @recursive1() convergent
ret i32 %a
}
@@ -79,7 +91,7 @@ define i32 @recursive2() convergent {
; CHECK-SAME: convergent
; CHECK-NEXT: define i32 @noopt()
define i32 @noopt() convergent optnone noinline {
- %a = call i32 @noopt_friend()
+ %a = call i32 @noopt_friend() convergent
ret i32 0
}
OpenPOWER on IntegriCloud