mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 03:02:36 +01:00
c60ad3e1fe
Summary: This patch changes gc.statepoint intrinsic's return type to token type instead of i32 type. Using token types could prevent LLVM to merge different gc.statepoint nodes into PHI nodes and cause further problems with gc relocations. The patch also changes the way on how gc.relocate and gc.result look for their corresponding gc.statepoint on unwind path. The current implementation uses the selector value extracted from a { i8*, i32 } landingpad as a hook to find the gc.statepoint, while the patch directly uses a token type landingpad (http://reviews.llvm.org/D15405) to find the gc.statepoint. Reviewers: sanjoy, JosephTremoulet, pgavlin, igor-laevsky, mjacob Subscribers: reames, mjacob, sanjoy, llvm-commits Differential Revision: http://reviews.llvm.org/D15662 llvm-svn: 256443
75 lines
2.3 KiB
LLVM
75 lines
2.3 KiB
LLVM
; RUN: opt -rewrite-statepoints-for-gc -S < %s | FileCheck %s
|
|
|
|
; A null test of a single value
|
|
define i1 @test(i8 addrspace(1)* %p, i1 %rare) gc "statepoint-example" {
|
|
; CHECK-LABEL: @test
|
|
entry:
|
|
%cond = icmp eq i8 addrspace(1)* %p, null
|
|
br i1 %rare, label %safepoint, label %continue, !prof !0
|
|
safepoint:
|
|
call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* @safepoint, i32 0, i32 0, i32 0, i32 0)
|
|
br label %continue
|
|
continue:
|
|
; CHECK-LABEL: continue:
|
|
; CHECK: phi
|
|
; CHECK-DAG: [ %p.relocated, %safepoint ]
|
|
; CHECK-DAG: [ %p, %entry ]
|
|
; CHECK: %cond = icmp
|
|
; CHECK: br i1 %cond
|
|
br i1 %cond, label %taken, label %untaken
|
|
taken:
|
|
ret i1 true
|
|
untaken:
|
|
ret i1 false
|
|
}
|
|
|
|
; Comparing two pointers
|
|
define i1 @test2(i8 addrspace(1)* %p, i8 addrspace(1)* %q, i1 %rare)
|
|
gc "statepoint-example" {
|
|
; CHECK-LABEL: @test2
|
|
entry:
|
|
%cond = icmp eq i8 addrspace(1)* %p, %q
|
|
br i1 %rare, label %safepoint, label %continue, !prof !0
|
|
safepoint:
|
|
call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* @safepoint, i32 0, i32 0, i32 0, i32 0)
|
|
br label %continue
|
|
continue:
|
|
; CHECK-LABEL: continue:
|
|
; CHECK: phi
|
|
; CHECK-DAG: [ %q.relocated, %safepoint ]
|
|
; CHECK-DAG: [ %q, %entry ]
|
|
; CHECK: phi
|
|
; CHECK-DAG: [ %p.relocated, %safepoint ]
|
|
; CHECK-DAG: [ %p, %entry ]
|
|
; CHECK: %cond = icmp
|
|
; CHECK: br i1 %cond
|
|
br i1 %cond, label %taken, label %untaken
|
|
taken:
|
|
ret i1 true
|
|
untaken:
|
|
ret i1 false
|
|
}
|
|
|
|
; Sanity check that nothing bad happens if already last instruction
|
|
; before terminator
|
|
define i1 @test3(i8 addrspace(1)* %p, i8 addrspace(1)* %q, i1 %rare)
|
|
gc "statepoint-example" {
|
|
; CHECK-LABEL: @test3
|
|
entry:
|
|
call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* @safepoint, i32 0, i32 0, i32 0, i32 0)
|
|
; CHECK: gc.statepoint
|
|
; CHECK: %cond = icmp
|
|
; CHECK: br i1 %cond
|
|
%cond = icmp eq i8 addrspace(1)* %p, %q
|
|
br i1 %cond, label %taken, label %untaken
|
|
taken:
|
|
ret i1 true
|
|
untaken:
|
|
ret i1 false
|
|
}
|
|
|
|
declare void @safepoint()
|
|
declare token @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...)
|
|
|
|
!0 = !{!"branch_weights", i32 1, i32 10000}
|