Home | History | Annotate | Download | only in RewriteStatepointsForGC
      1 ; RUN: opt %s -rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s
      2 
      3 
      4 ; CHECK: derived %obj_to_consume base %obj_to_consume
      5 
      6 declare void @foo()
      7 declare i64 addrspace(1)* @generate_obj()
      8 declare void @consume_obj(i64 addrspace(1)*)
      9 
     10 define void @test(i32 %condition) gc "statepoint-example" {
     11 entry:
     12   br label %loop
     13 
     14 loop:
     15 ; CHECK: loop:
     16 ; CHECK:  %safepoint_token1 = call i32 (i64, i32, i64 addrspace(1)* ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_p1i64f(i64 0, i32 0, i64 addrspace(1)* ()* @generate_obj, i32 0, i32 0, i32 0, i32 5, i32 0, i32 -1, i32 0, i32 0, i3
     17 ; CHECK-NEXT:  %obj2 = call i64 addrspace(1)* @llvm.experimental.gc.result
     18   %safepoint_token1 = call i32 (i64, i32, i64 addrspace(1)* ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_p1i64f(i64 0, i32 0, i64 addrspace(1)* ()* @generate_obj, i32 0, i32 0, i32 0, i32 5, i32 0, i32 -1, i32 0, i32 0, i32 0)
     19   %obj2 = call i64 addrspace(1)* @llvm.experimental.gc.result.p1i64(i32 %safepoint_token1)
     20   switch i32 %condition, label %dest_a [
     21     i32 0, label %dest_b
     22     i32 1, label %dest_c
     23   ]
     24 
     25 dest_a:
     26   br label %merge
     27 
     28 dest_b:
     29   br label %merge
     30 
     31 dest_c:
     32   br label %merge
     33 
     34 merge:
     35 ; CHECK: merge:
     36 ; CHECK:  %obj_to_consume = phi i64 addrspace(1)* [ %obj2, %dest_a ], [ null, %dest_b ], [ null, %dest_c ]
     37 
     38   %obj_to_consume = phi i64 addrspace(1)* [ %obj2, %dest_a ], [ null, %dest_b ], [ null, %dest_c ]
     39   %safepoint_token3 = call i32 (i64, i32, void (i64 addrspace(1)*)*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidp1i64f(i64 0, i32 0, void (i64 addrspace(1)*)* @consume_obj, i32 1, i32 0, i64 addrspace(1)* %obj_to_consume, i32 0, i32 5, i32 0, i32 -1, i32 0, i32 0, i32 0)
     40   br label %merge.split
     41 
     42 merge.split:                                      ; preds = %merge
     43   %safepoint_token = call i32 (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)
     44   br label %loop
     45 }
     46 
     47 
     48 ; Function Attrs: nounwind
     49 declare i64 addrspace(1)* @llvm.experimental.gc.result.p1i64(i32) #0
     50 declare i32 @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...)
     51 declare i32 @llvm.experimental.gc.statepoint.p0f_p1i64f(i64, i32, i64 addrspace(1)* ()*, i32, i32, ...)
     52 declare i32 @llvm.experimental.gc.statepoint.p0f_isVoidp1i64f(i64, i32, void (i64 addrspace(1)*)*, i32, i32, ...)
     53