Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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
- Loading branch information
Justin Lebar
committed
Feb 22, 2016
1 parent
f62b165
commit 7bf9187
Showing
4 changed files
with
98 additions
and
56 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
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,33 @@ | ||
; RUN: opt -instcombine -S < %s | FileCheck %s | ||
|
||
declare i32 @k() convergent | ||
declare i32 @f() | ||
|
||
define i32 @extern() { | ||
; Convergent attr shouldn't be removed here; k is convergent. | ||
; CHECK: call i32 @k() [[CONVERGENT_ATTR:#[0-9]+]] | ||
%a = call i32 @k() convergent | ||
ret i32 %a | ||
} | ||
|
||
define i32 @extern_no_attr() { | ||
; Convergent attr shouldn't be added here, even though k is convergent. | ||
; CHECK: call i32 @k(){{$}} | ||
%a = call i32 @k() | ||
ret i32 %a | ||
} | ||
|
||
define i32 @no_extern() { | ||
; Convergent should be removed here, as the target is convergent. | ||
; CHECK: call i32 @f(){{$}} | ||
%a = call i32 @f() convergent | ||
ret i32 %a | ||
} | ||
|
||
define i32 @indirect_call(i32 ()* %f) { | ||
; CHECK call i32 %f() [[CONVERGENT_ATTR]] | ||
%a = call i32 %f() convergent | ||
ret i32 %a | ||
} | ||
|
||
; CHECK: [[CONVERGENT_ATTR]] = { convergent } |