mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
Teach the IR Sink pass to (conservatively) respect convergent annotations.
llvm-svn: 238762
This commit is contained in:
parent
342dea971f
commit
b86a7d7ea4
@ -172,6 +172,12 @@ static bool isSafeToMove(Instruction *Inst, AliasAnalysis *AA,
|
||||
if (isa<TerminatorInst>(Inst) || isa<PHINode>(Inst))
|
||||
return false;
|
||||
|
||||
// Convergent operations can only be moved to control equivalent blocks.
|
||||
if (auto CS = CallSite(Inst)) {
|
||||
if (CS.hasFnAttr(Attribute::Convergent))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
24
test/Transforms/Sink/convergent.ll
Normal file
24
test/Transforms/Sink/convergent.ll
Normal file
@ -0,0 +1,24 @@
|
||||
; RUN: opt -sink -S < %s | FileCheck %s
|
||||
|
||||
; Verify that IR sinking does not move convergent operations to
|
||||
; blocks that are not control equivalent.
|
||||
|
||||
; CHECK: define i32 @foo
|
||||
; CHECK: entry
|
||||
; CHECK-NEXT: call i32 @bar
|
||||
; CHECK-NEXT: br i1 %arg
|
||||
|
||||
define i32 @foo(i1 %arg) {
|
||||
entry:
|
||||
%c = call i32 @bar() readonly convergent
|
||||
br i1 %arg, label %then, label %end
|
||||
|
||||
then:
|
||||
ret i32 %c
|
||||
|
||||
end:
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
declare i32 @bar() readonly convergent
|
||||
|
Loading…
x
Reference in New Issue
Block a user