1 ; This is a collection of really basic tests for gc.statepoint rewriting.
2 ; RUN: opt < %s -rewrite-statepoints-for-gc -spp-rematerialization-threshold=0 -S | FileCheck %s
3 ; RUN: opt < %s -passes=rewrite-statepoints-for-gc -spp-rematerialization-threshold=0 -S | FileCheck %s
5 ; Trivial relocation over a single call
9 define i8 addrspace(1)* @test1(i8 addrspace(1)* %obj) gc "statepoint-example" {
13 ; CHECK-NEXT: gc.statepoint
14 ; CHECK-NEXT: %obj.relocated = call coldcc i8 addrspace(1)*
15 ; Two safepoints in a row (i.e. consistent liveness)
16 call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
17 ret i8 addrspace(1)* %obj
20 define i8 addrspace(1)* @test2(i8 addrspace(1)* %obj) gc "statepoint-example" {
24 ; CHECK-NEXT: gc.statepoint
25 ; CHECK-NEXT: %obj.relocated = call coldcc i8 addrspace(1)*
26 ; CHECK-NEXT: gc.statepoint
27 ; CHECK-NEXT: %obj.relocated2 = call coldcc i8 addrspace(1)*
28 ; A simple derived pointer
29 call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
30 call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
31 ret i8 addrspace(1)* %obj
34 define i8 @test3(i8 addrspace(1)* %obj) gc "statepoint-example" {
37 ; CHECK-NEXT: getelementptr
38 ; CHECK-NEXT: gc.statepoint
39 ; CHECK-NEXT: %obj.relocated = call coldcc i8 addrspace(1)*
40 ; CHECK-NEXT: %derived.relocated = call coldcc i8 addrspace(1)*
41 ; CHECK-NEXT: load i8, i8 addrspace(1)* %derived.relocated
42 ; CHECK-NEXT: load i8, i8 addrspace(1)* %obj.relocated
43 ; Tests to make sure we visit both the taken and untaken predeccessor
44 ; of merge. This was a bug in the dataflow liveness at one point.
45 %derived = getelementptr i8, i8 addrspace(1)* %obj, i64 10
46 call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
47 %a = load i8, i8 addrspace(1)* %derived
48 %b = load i8, i8 addrspace(1)* %obj
53 define i8 addrspace(1)* @test4(i1 %cmp, i8 addrspace(1)* %obj) gc "statepoint-example" {
55 br i1 %cmp, label %taken, label %untaken
57 taken: ; preds = %entry
59 ; CHECK-NEXT: gc.statepoint
60 ; CHECK-NEXT: %obj.relocated = call coldcc i8 addrspace(1)*
61 call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
64 untaken: ; preds = %entry
65 ; CHECK-LABEL: untaken:
66 ; CHECK-NEXT: gc.statepoint
67 ; CHECK-NEXT: %obj.relocated2 = call coldcc i8 addrspace(1)*
68 call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
71 merge: ; preds = %untaken, %taken
73 ; CHECK-NEXT: %.0 = phi i8 addrspace(1)* [ %obj.relocated, %taken ], [ %obj.relocated2, %untaken ]
74 ; CHECK-NEXT: ret i8 addrspace(1)* %.0
75 ; When run over a function which doesn't opt in, should do nothing!
76 ret i8 addrspace(1)* %obj
79 define i8 addrspace(1)* @test5(i8 addrspace(1)* %obj) gc "ocaml" {
83 ; CHECK-NEXT: gc.statepoint
84 ; CHECK-NOT: %obj.relocated = call coldcc i8 addrspace(1)*
85 %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 0) ["deopt" (i32 0, i32 -1, i32 0, i32 0, i32 0)]
86 ret i8 addrspace(1)* %obj
89 declare token @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...)