Home | History | Annotate | Download | only in RewriteStatepointsForGC
      1 ; RUN: opt < %s -S -rewrite-statepoints-for-gc | FileCheck %s
      2 
      3 declare i64 addrspace(1)* @some_call(i64 addrspace(1)*)
      4 declare i32 @personality_function()
      5 
      6 define i64 addrspace(1)* @test_basic(i64 addrspace(1)* %obj, i64 addrspace(1)* %obj1) gc "statepoint-example" personality i32 ()* @personality_function {
      7 ; CHECK-LABEL: entry:
      8 entry:
      9   ; CHECK: invoke
     10   ; CHECK: statepoint
     11   ; CHECK: some_call
     12   %ret_val = invoke i64 addrspace(1)* @some_call(i64 addrspace(1)* %obj)
     13                to label %normal_return unwind label %exceptional_return
     14 
     15 ; CHECK-LABEL: normal_return:
     16 ; CHECK: gc.result
     17 ; CHECK: ret i64
     18 
     19 normal_return:
     20   ret i64 addrspace(1)* %ret_val
     21 
     22 ; CHECK-LABEL: exceptional_return:
     23 ; CHECK: landingpad
     24 ; CHECK: ret i64
     25 
     26 exceptional_return:
     27   %landing_pad4 = landingpad token
     28           cleanup
     29   ret i64 addrspace(1)* %obj1
     30 }
     31 
     32 define i64 addrspace(1)* @test_two_invokes(i64 addrspace(1)* %obj, i64 addrspace(1)* %obj1) gc "statepoint-example" personality i32 ()* @personality_function {
     33 ; CHECK-LABEL: entry:
     34 entry:
     35   ; CHECK: invoke 
     36   ; CHECK: statepoint
     37   ; CHECK: some_call
     38   %ret_val1 = invoke i64 addrspace(1)* @some_call(i64 addrspace(1)* %obj)
     39                to label %second_invoke unwind label %exceptional_return
     40 
     41 ; CHECK-LABEL: second_invoke:
     42 second_invoke:
     43   ; CHECK: invoke
     44   ; CHECK: statepoint
     45   ; CHECK: some_call
     46   %ret_val2 = invoke i64 addrspace(1)* @some_call(i64 addrspace(1)* %ret_val1)
     47                 to label %normal_return unwind label %exceptional_return
     48 
     49 ; CHECK-LABEL: normal_return:
     50 normal_return:
     51   ; CHECK: gc.result
     52   ; CHECK: ret i64
     53   ret i64 addrspace(1)* %ret_val2
     54 
     55 ; CHECK: exceptional_return:
     56 ; CHECK: ret i64
     57 
     58 exceptional_return:
     59   %landing_pad4 = landingpad token
     60           cleanup
     61   ret i64 addrspace(1)* %obj1
     62 }
     63 
     64 define i64 addrspace(1)* @test_phi_node(i1 %cond, i64 addrspace(1)* %obj) gc "statepoint-example" personality i32 ()* @personality_function {
     65 ; CHECK-LABEL: @test_phi_node
     66 ; CHECK-LABEL: entry:
     67 entry:
     68   br i1 %cond, label %left, label %right
     69 
     70 left:
     71   %ret_val_left = invoke i64 addrspace(1)* @some_call(i64 addrspace(1)* %obj)
     72                     to label %merge unwind label %exceptional_return
     73 
     74 right:
     75   %ret_val_right = invoke i64 addrspace(1)* @some_call(i64 addrspace(1)* %obj)
     76                      to label %merge unwind label %exceptional_return
     77 
     78 ; CHECK: merge[[A:[0-9]]]:
     79 ; CHECK: gc.result
     80 ; CHECK: br label %[[with_phi:merge[0-9]*]]
     81 
     82 ; CHECK: merge[[B:[0-9]]]:
     83 ; CHECK: gc.result
     84 ; CHECK: br label %[[with_phi]]
     85 
     86 ; CHECK: [[with_phi]]:
     87 ; CHECK: phi
     88 ; CHECK: ret i64 addrspace(1)* %ret_val
     89 merge:
     90   %ret_val = phi i64 addrspace(1)* [%ret_val_left, %left], [%ret_val_right, %right]
     91   ret i64 addrspace(1)* %ret_val
     92 
     93 ; CHECK-LABEL: exceptional_return:
     94 ; CHECK: ret i64 addrspace(1)*
     95 
     96 exceptional_return:
     97   %landing_pad4 = landingpad token
     98           cleanup
     99   ret i64 addrspace(1)* %obj
    100 }
    101 
    102 declare void @do_safepoint()
    103 define void @gc.safepoint_poll() {
    104 ; CHECK-LABEL: gc.safepoint_poll
    105 ; CHECK-LABEL: entry
    106 ; CHECK-NEXT: do_safepoint
    107 ; CHECK-NEXT: ret void 
    108 entry:
    109   call void @do_safepoint()
    110   ret void
    111 }
    112