blob: 39567b122274b9d38737d13931413f7090cf9383 [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
Sanjoy Das89c54912015-05-11 18:49:34 +000016; CHECK-NEXT: bitcast
17; CHECK-NEXT: @consume(i64 addrspace(1)* %obj.relocated.casted)
18; CHECK-NEXT: @consume(i64 addrspace(1)* %obj.relocated.casted)
Philip Reames85b36a82015-04-10 22:07:04 +000019 %obj2 = phi i64 addrspace(1)* [ %obj, %entry ]
Pat Gavlincc0431d2015-05-08 18:07:42 +000020 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 +000021 call void (...) @consume(i64 addrspace(1)* %obj2)
22 call void (...) @consume(i64 addrspace(1)* %obj)
Philip Reames85b36a82015-04-10 22:07:04 +000023 ret void
24}
25
26declare void @some_call(i64 addrspace(1)*)
27
28; Need to delete unreachable gc.statepoint call
29define void @test7() gc "statepoint-example" {
30; CHECK-LABEL: test7
31; CHECK-NOT: gc.statepoint
32 ret void
33
34unreached:
35 %obj = phi i64 addrspace(1)* [null, %unreached]
Pat Gavlincc0431d2015-05-08 18:07:42 +000036 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 +000037 call void (...) @consume(i64 addrspace(1)* %obj)
Philip Reames85b36a82015-04-10 22:07:04 +000038 br label %unreached
39}
40
41; Need to delete unreachable gc.statepoint invoke - tested seperately given
42; a correct implementation could only remove the instructions, not the block
43define void @test8() gc "statepoint-example" {
44; CHECK-LABEL: test8
45; CHECK-NOT: gc.statepoint
46 ret void
47
48unreached:
Pat Gavlincc0431d2015-05-08 18:07:42 +000049 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 +000050 to label %normal_return unwind label %exceptional_return
51
52normal_return: ; preds = %entry
53 ret void
54
55exceptional_return: ; preds = %entry
56 %landing_pad4 = landingpad { i8*, i32 } personality i32 ()* undef
57 cleanup
58 ret void
59}
60
61declare void @foo()
62; Bound the last check-not
63; CHECK-LABEL: @foo
64
65declare i32 @llvm.experimental.gc.statepoint.p0f_isVoidf(void ()*, i32, i32, ...)
66