Home | History | Annotate | Download | only in deopt-bundles
      1 ; RUN: opt %s -rewrite-statepoints-for-gc -rs4gc-use-deopt-bundles -S 2>&1 | FileCheck %s
      2 
      3 
      4 declare void @use_obj16(i16 addrspace(1)*) "gc-leaf-function"
      5 declare void @use_obj32(i32 addrspace(1)*) "gc-leaf-function"
      6 declare void @use_obj64(i64 addrspace(1)*) "gc-leaf-function"
      7 
      8 declare void @do_safepoint()
      9 
     10 define void @test_gep_const(i32 addrspace(1)* %base) gc "statepoint-example" {
     11 ; CHECK-LABEL: test_gep_const
     12 entry:
     13   %ptr = getelementptr i32, i32 addrspace(1)* %base, i32 15
     14   call void @do_safepoint() [ "deopt"() ]
     15   call void @use_obj32(i32 addrspace(1)* %base)
     16   call void @use_obj32(i32 addrspace(1)* %ptr)
     17   ret void
     18 }
     19 
     20 define void @test_gep_idx(i32 addrspace(1)* %base, i32 %idx) gc "statepoint-example" {
     21 ; CHECK-LABEL: test_gep_idx
     22 entry:
     23   %ptr = getelementptr i32, i32 addrspace(1)* %base, i32 %idx
     24   call void @do_safepoint() [ "deopt"() ]
     25   call void @use_obj32(i32 addrspace(1)* %base)
     26   call void @use_obj32(i32 addrspace(1)* %ptr)
     27   ret void
     28 }
     29 
     30 define void @test_bitcast(i32 addrspace(1)* %base) gc "statepoint-example" {
     31 ; CHECK-LABEL: test_bitcast
     32 entry:
     33   %ptr = bitcast i32 addrspace(1)* %base to i64 addrspace(1)*
     34   call void @do_safepoint() [ "deopt"() ]
     35   call void @use_obj32(i32 addrspace(1)* %base)
     36   call void @use_obj64(i64 addrspace(1)* %ptr)
     37   ret void
     38 }
     39 
     40 define void @test_bitcast_gep(i32 addrspace(1)* %base) gc "statepoint-example" {
     41 ; CHECK-LABEL: test_bitcast_gep
     42 entry:
     43   %ptr.gep = getelementptr i32, i32 addrspace(1)* %base, i32 15
     44   %ptr.cast = bitcast i32 addrspace(1)* %ptr.gep to i64 addrspace(1)*
     45   call void @do_safepoint() [ "deopt"() ]
     46   call void @use_obj32(i32 addrspace(1)* %base)
     47   call void @use_obj64(i64 addrspace(1)* %ptr.cast)
     48   ret void
     49 }
     50 
     51 define void @test_intersecting_chains(i32 addrspace(1)* %base, i32 %idx) gc "statepoint-example" {
     52 ; CHECK-LABEL: test_intersecting_chains
     53 entry:
     54   %ptr.gep = getelementptr i32, i32 addrspace(1)* %base, i32 15
     55   %ptr.cast = bitcast i32 addrspace(1)* %ptr.gep to i64 addrspace(1)*
     56   %ptr.cast2 = bitcast i32 addrspace(1)* %ptr.gep to i16 addrspace(1)*
     57   call void @do_safepoint() [ "deopt"() ]
     58   call void @use_obj64(i64 addrspace(1)* %ptr.cast)
     59   call void @use_obj16(i16 addrspace(1)* %ptr.cast2)
     60   ret void
     61 }
     62 
     63 define void @test_cost_threshold(i32 addrspace(1)* %base, i32 %idx1, i32 %idx2, i32 %idx3) gc "statepoint-example" {
     64 ; CHECK-LABEL: test_cost_threshold
     65 entry:
     66   %ptr.gep = getelementptr i32, i32 addrspace(1)* %base, i32 15
     67   %ptr.gep2 = getelementptr i32, i32 addrspace(1)* %ptr.gep, i32 %idx1
     68   %ptr.gep3 = getelementptr i32, i32 addrspace(1)* %ptr.gep2, i32 %idx2
     69   %ptr.gep4 = getelementptr i32, i32 addrspace(1)* %ptr.gep3, i32 %idx3
     70   %ptr.cast = bitcast i32 addrspace(1)* %ptr.gep4 to i64 addrspace(1)*
     71   call void @do_safepoint() [ "deopt"() ]
     72   call void @use_obj64(i64 addrspace(1)* %ptr.cast)
     73   ret void
     74 }
     75 
     76 define void @test_two_derived(i32 addrspace(1)* %base) gc "statepoint-example" {
     77 ; CHECK-LABEL: test_two_derived
     78 entry:
     79   %ptr = getelementptr i32, i32 addrspace(1)* %base, i32 15
     80   %ptr2 = getelementptr i32, i32 addrspace(1)* %base, i32 12
     81   call void @do_safepoint() [ "deopt"() ]
     82   call void @use_obj32(i32 addrspace(1)* %ptr)
     83   call void @use_obj32(i32 addrspace(1)* %ptr2)
     84   ret void
     85 }
     86 
     87 define void @test_gep_smallint_array([3 x i32] addrspace(1)* %base) gc "statepoint-example" {
     88 ; CHECK-LABEL: test_gep_smallint_array
     89 entry:
     90   %ptr = getelementptr [3 x i32], [3 x i32] addrspace(1)* %base, i32 0, i32 2
     91   call void @do_safepoint() [ "deopt"() ]
     92   call void @use_obj32(i32 addrspace(1)* %ptr)
     93   ret void
     94 }
     95 
     96 declare i32 @fake_personality_function()
     97 
     98 define void @test_invoke(i32 addrspace(1)* %base) gc "statepoint-example" personality i32 ()* @fake_personality_function {
     99 ; CHECK-LABEL: test_invoke
    100 entry:
    101   %ptr.gep = getelementptr i32, i32 addrspace(1)* %base, i32 15
    102   %ptr.cast = bitcast i32 addrspace(1)* %ptr.gep to i64 addrspace(1)*
    103   %ptr.cast2 = bitcast i32 addrspace(1)* %ptr.gep to i16 addrspace(1)*
    104   invoke void @do_safepoint() [ "deopt"() ]
    105           to label %normal unwind label %exception
    106 
    107 normal:                                           ; preds = %entry
    108   call void @use_obj64(i64 addrspace(1)* %ptr.cast)
    109   call void @use_obj16(i16 addrspace(1)* %ptr.cast2)
    110   ret void
    111 
    112 exception:                                        ; preds = %entry
    113   %landing_pad4 = landingpad { i8*, i32 }
    114           cleanup
    115   call void @use_obj64(i64 addrspace(1)* %ptr.cast)
    116   call void @use_obj16(i16 addrspace(1)* %ptr.cast2)
    117   ret void
    118 }
    119 
    120 define void @test_loop(i32 addrspace(1)* %base) gc "statepoint-example" {
    121 ; CHECK-LABEL: test_loop
    122 entry:
    123   %ptr.gep = getelementptr i32, i32 addrspace(1)* %base, i32 15
    124   br label %loop
    125 
    126 loop:                                             ; preds = %loop, %entry
    127   call void @use_obj32(i32 addrspace(1)* %ptr.gep)
    128   call void @do_safepoint() [ "deopt"() ]
    129   br label %loop
    130 }
    131 
    132 define void @test_too_long(i32 addrspace(1)* %base) gc "statepoint-example" {
    133 ; CHECK-LABEL: test_too_long
    134 entry:
    135   %ptr.gep = getelementptr i32, i32 addrspace(1)* %base, i32 15
    136   %ptr.gep1 = getelementptr i32, i32 addrspace(1)* %ptr.gep, i32 15
    137   %ptr.gep2 = getelementptr i32, i32 addrspace(1)* %ptr.gep1, i32 15
    138   %ptr.gep3 = getelementptr i32, i32 addrspace(1)* %ptr.gep2, i32 15
    139   %ptr.gep4 = getelementptr i32, i32 addrspace(1)* %ptr.gep3, i32 15
    140   %ptr.gep5 = getelementptr i32, i32 addrspace(1)* %ptr.gep4, i32 15
    141   %ptr.gep6 = getelementptr i32, i32 addrspace(1)* %ptr.gep5, i32 15
    142   %ptr.gep7 = getelementptr i32, i32 addrspace(1)* %ptr.gep6, i32 15
    143   %ptr.gep8 = getelementptr i32, i32 addrspace(1)* %ptr.gep7, i32 15
    144   %ptr.gep9 = getelementptr i32, i32 addrspace(1)* %ptr.gep8, i32 15
    145   %ptr.gep10 = getelementptr i32, i32 addrspace(1)* %ptr.gep9, i32 15
    146   %ptr.gep11 = getelementptr i32, i32 addrspace(1)* %ptr.gep10, i32 15
    147   call void @do_safepoint() [ "deopt"() ]
    148   call void @use_obj32(i32 addrspace(1)* %ptr.gep11)
    149   ret void
    150 }
    151