blob: ffdfe5be350a64a6c87b831036fcf035ee37b45a [file] [log] [blame]
Philip Reames85b36a82015-04-10 22:07:04 +00001; RUN: opt -rewrite-statepoints-for-gc -S < %s | FileCheck %s
2
3declare void @consume(...)
4
5; Test to make sure we destroy LCSSA's single entry phi nodes before
6; running liveness
7define void @test6(i64 addrspace(1)* %obj) gc "statepoint-example" {
8; CHECK-LABEL: @test6
9entry:
10 br label %next
11
12next:
13; CHECK-LABEL: next:
14; CHECK-NEXT: gc.statepoint
15; CHECK-NEXT: gc.relocate
16; CHECK-NEXT: @consume(i64 addrspace(1)* %obj.relocated)
17; CHECK-NEXT: @consume(i64 addrspace(1)* %obj.relocated)
18 %obj2 = phi i64 addrspace(1)* [ %obj, %entry ]
Pat Gavlincc0431d2015-05-08 18:07:42 +000019 call i32 (void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(void ()* @foo, i32 0, i32 0, i32 0, i32 0)
David Blaikie23af6482015-04-16 23:24:18 +000020 call void (...) @consume(i64 addrspace(1)* %obj2)
21 call void (...) @consume(i64 addrspace(1)* %obj)
Philip Reames85b36a82015-04-10 22:07:04 +000022 ret void
23}
24
25declare void @some_call(i64 addrspace(1)*)
26
27; Need to delete unreachable gc.statepoint call
28define void @test7() gc "statepoint-example" {
29; CHECK-LABEL: test7
30; CHECK-NOT: gc.statepoint
31 ret void
32
33unreached:
34 %obj = phi i64 addrspace(1)* [null, %unreached]
Pat Gavlincc0431d2015-05-08 18:07:42 +000035 call i32 (void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(void ()* @foo, i32 0, i32 0, i32 0, i32 0)
David Blaikie23af6482015-04-16 23:24:18 +000036 call void (...) @consume(i64 addrspace(1)* %obj)
Philip Reames85b36a82015-04-10 22:07:04 +000037 br label %unreached
38}
39
40; Need to delete unreachable gc.statepoint invoke - tested seperately given
41; a correct implementation could only remove the instructions, not the block
42define void @test8() gc "statepoint-example" {
43; CHECK-LABEL: test8
44; CHECK-NOT: gc.statepoint
45 ret void
46
47unreached:
Pat Gavlincc0431d2015-05-08 18:07:42 +000048 invoke i32 (void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(void ()* @foo, i32 0, i32 0, i32 0, i32 0)
Philip Reames85b36a82015-04-10 22:07:04 +000049 to label %normal_return unwind label %exceptional_return
50
51normal_return: ; preds = %entry
52 ret void
53
54exceptional_return: ; preds = %entry
55 %landing_pad4 = landingpad { i8*, i32 } personality i32 ()* undef
56 cleanup
57 ret void
58}
59
60declare void @foo()
61; Bound the last check-not
62; CHECK-LABEL: @foo
63
64declare i32 @llvm.experimental.gc.statepoint.p0f_isVoidf(void ()*, i32, i32, ...)
65