forked from jeremyhu/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.
Add convergent-removing bits to FunctionAttrs pass.
Summary: Remove the convergent attribute on any functions which provably do not contain or invoke any convergent functions. After this change, we'll be able to modify clang to conservatively add 'convergent' to all functions when compiling CUDA. Reviewers: jingyue, joker.eph Subscribers: llvm-commits, tra, jhen, hfinkel, resistor, chandlerc, arsenm Differential Revision: http://reviews.llvm.org/D17013 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@260319 91177308-0d34-0410-b5e6-96231b3b80d8
- Loading branch information
Justin Lebar
committed
Feb 9, 2016
1 parent
96d6052
commit c4f6eb8
Showing
3 changed files
with
160 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
; RUN: opt < %s -basicaa -functionattrs -rpo-functionattrs -S | FileCheck %s | ||
|
||
; 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 { | ||
%a = call i32 @k() | ||
ret i32 %a | ||
} | ||
|
||
; CHECK: Function Attrs | ||
; CHECK-SAME: convergent | ||
; CHECK-NEXT: define i32 @call_extern() | ||
define i32 @call_extern() convergent { | ||
%a = call i32 @extern() | ||
ret i32 %a | ||
} | ||
|
||
; CHECK: Function Attrs | ||
; CHECK-SAME: convergent | ||
; CHECK-NEXT: declare void @llvm.cuda.syncthreads() | ||
declare void @llvm.cuda.syncthreads() convergent | ||
|
||
; CHECK: Function Attrs | ||
; CHECK-SAME: convergent | ||
; CHECK-NEXT: define i32 @intrinsic() | ||
define i32 @intrinsic() 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() | ||
ret i32 %a | ||
} | ||
|
||
; CHECK: Function Attrs | ||
; CHECK-NOT: convergent | ||
; CHECK-NEXT: define i32 @recursive2() | ||
define i32 @recursive2() convergent { | ||
%a = call i32 @recursive1() | ||
ret i32 %a | ||
} | ||
|
||
; CHECK: Function Attrs | ||
; CHECK-SAME: convergent | ||
; CHECK-NEXT: define i32 @noopt() | ||
define i32 @noopt() convergent optnone noinline { | ||
%a = call i32 @noopt_friend() | ||
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 | ||
} |