1 ; This is a collection of really basic tests for gc.statepoint rewriting.
2 ; RUN: opt %s -rewrite-statepoints-for-gc -rs4gc-use-deopt-bundles -spp-rematerialization-threshold=0 -S | FileCheck %s
4 ; Trivial relocation over a single call
8 define i8 addrspace(1)* @test1(i8 addrspace(1)* %obj) gc "statepoint-example" {
12 ; CHECK-NEXT: gc.statepoint
13 ; CHECK-NEXT: %obj.relocated = call coldcc i8 addrspace(1)*
14 ; Two safepoints in a row (i.e. consistent liveness)
15 call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
16 ret i8 addrspace(1)* %obj
19 define i8 addrspace(1)* @test2(i8 addrspace(1)* %obj) gc "statepoint-example" {
23 ; CHECK-NEXT: gc.statepoint
24 ; CHECK-NEXT: %obj.relocated = call coldcc i8 addrspace(1)*
25 ; CHECK-NEXT: gc.statepoint
26 ; CHECK-NEXT: %obj.relocated2 = call coldcc i8 addrspace(1)*
27 ; A simple derived pointer
28 call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
29 call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
30 ret i8 addrspace(1)* %obj
33 define i8 @test3(i8 addrspace(1)* %obj) gc "statepoint-example" {
36 ; CHECK-NEXT: getelementptr
37 ; CHECK-NEXT: gc.statepoint
38 ; CHECK-NEXT: %derived.relocated = call coldcc i8 addrspace(1)*
39 ; CHECK-NEXT: %obj.relocated = call coldcc i8 addrspace(1)*
40 ; CHECK-NEXT: load i8, i8 addrspace(1)* %derived.relocated
41 ; CHECK-NEXT: load i8, i8 addrspace(1)* %obj.relocated
42 ; Tests to make sure we visit both the taken and untaken predeccessor
43 ; of merge. This was a bug in the dataflow liveness at one point.
44 %derived = getelementptr i8, i8 addrspace(1)* %obj, i64 10
45 call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
46 %a = load i8, i8 addrspace(1)* %derived
47 %b = load i8, i8 addrspace(1)* %obj
52 define i8 addrspace(1)* @test4(i1 %cmp, i8 addrspace(1)* %obj) gc "statepoint-example" {
54 br i1 %cmp, label %taken, label %untaken
56 taken: ; preds = %entry
58 ; CHECK-NEXT: gc.statepoint
59 ; CHECK-NEXT: %obj.relocated = call coldcc i8 addrspace(1)*
60 call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
63 untaken: ; preds = %entry
64 ; CHECK-LABEL: untaken:
65 ; CHECK-NEXT: gc.statepoint
66 ; CHECK-NEXT: %obj.relocated2 = call coldcc i8 addrspace(1)*
67 call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
70 merge: ; preds = %untaken, %taken
72 ; CHECK-NEXT: %.0 = phi i8 addrspace(1)* [ %obj.relocated, %taken ], [ %obj.relocated2, %untaken ]
73 ; CHECK-NEXT: ret i8 addrspace(1)* %.0
74 ; When run over a function which doesn't opt in, should do nothing!
75 ret i8 addrspace(1)* %obj
78 define i8 addrspace(1)* @test5(i8 addrspace(1)* %obj) gc "ocaml" {
82 ; CHECK-NEXT: gc.statepoint
83 ; CHECK-NOT: %obj.relocated = call coldcc i8 addrspace(1)*
84 %0 = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @foo, i32 0, i32 0, i32 0, i32 5, i32 0, i32 -1, i32 0, i32 0, i32 0)
85 ret i8 addrspace(1)* %obj
88 declare token @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...)