[RS4GC] Add some missing tests and CHECK: lines

I missed porting these in rL259129.

llvm-svn: 259203
This commit is contained in:
Sanjoy Das 2016-01-29 16:32:25 +00:00
parent d474ef3a3b
commit f3a4ee7542
2 changed files with 159 additions and 2 deletions

View File

@ -49,3 +49,49 @@ entry:
%res = load i8, i8 addrspace(1)* @G, align 1
ret i8 %res
}
; Even for source languages without constant references, we can
; see constants can show up along paths where the value is dead.
; This is particular relevant when computing bases of PHIs.
define i8 addrspace(1)* @test4(i8 addrspace(1)* %p) gc "statepoint-example" {
; CHECK-LABEL: @test4
entry:
%is_null = icmp eq i8 addrspace(1)* %p, null
br i1 %is_null, label %split, label %join
split:
call void @foo()
%arg_value_addr.i = getelementptr inbounds i8, i8 addrspace(1)* %p, i64 8
%arg_value_addr_casted.i = bitcast i8 addrspace(1)* %arg_value_addr.i to i8 addrspace(1)* addrspace(1)*
br label %join
join:
; CHECK-LABEL: join
; CHECK: %addr2.base =
%addr2 = phi i8 addrspace(1)* addrspace(1)* [ %arg_value_addr_casted.i, %split ], [ inttoptr (i64 8 to i8 addrspace(1)* addrspace(1)*), %entry ]
;; NOTE: This particular example can be jump-threaded, but in general,
;; we can't, and have to deal with the resulting IR.
br i1 %is_null, label %early-exit, label %use
early-exit:
ret i8 addrspace(1)* null
use:
; CHECK-LABEL: use:
; CHECK: gc.statepoint
; CHECK: gc.relocate
call void @foo()
%res = load i8 addrspace(1)*, i8 addrspace(1)* addrspace(1)* %addr2, align 1
ret i8 addrspace(1)* %res
}
; Globals don't move and thus don't get relocated
define i8 addrspace(1)* @test5(i1 %always_true) gc "statepoint-example" {
; CHECK-LABEL: @test5
; CHECK: gc.statepoint
; CHECK-NEXT: %res = extractelement <2 x i8 addrspace(1)*> <i8 addrspace(1)* @G, i8 addrspace(1)* @G>, i32 0
entry:
call void @foo()
%res = extractelement <2 x i8 addrspace(1)*> <i8 addrspace(1)* @G, i8 addrspace(1)* @G>, i32 0
ret i8 addrspace(1)* %res
}

View File

@ -11,7 +11,11 @@ define void @test_gep_const(i32 addrspace(1)* %base) gc "statepoint-example" {
; CHECK-LABEL: test_gep_const
entry:
%ptr = getelementptr i32, i32 addrspace(1)* %base, i32 15
; CHECK: getelementptr i32, i32 addrspace(1)* %base, i32 15
call void @do_safepoint() [ "deopt"() ]
; CHECK: %base.relocated = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token %statepoint_token, i32 7, i32 7)
; CHECK: bitcast i8 addrspace(1)* %base.relocated to i32 addrspace(1)*
; CHECK: getelementptr i32, i32 addrspace(1)* %base.relocated.casted, i32 15
call void @use_obj32(i32 addrspace(1)* %base)
call void @use_obj32(i32 addrspace(1)* %ptr)
ret void
@ -21,7 +25,11 @@ define void @test_gep_idx(i32 addrspace(1)* %base, i32 %idx) gc "statepoint-exam
; CHECK-LABEL: test_gep_idx
entry:
%ptr = getelementptr i32, i32 addrspace(1)* %base, i32 %idx
; CHECK: getelementptr
call void @do_safepoint() [ "deopt"() ]
; CHECK: %base.relocated = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token %statepoint_token, i32 7, i32 7)
; CHECK: %base.relocated.casted = bitcast i8 addrspace(1)* %base.relocated to i32 addrspace(1)*
; CHECK: getelementptr i32, i32 addrspace(1)* %base.relocated.casted, i32 %idx
call void @use_obj32(i32 addrspace(1)* %base)
call void @use_obj32(i32 addrspace(1)* %ptr)
ret void
@ -31,18 +39,65 @@ define void @test_bitcast(i32 addrspace(1)* %base) gc "statepoint-example" {
; CHECK-LABEL: test_bitcast
entry:
%ptr = bitcast i32 addrspace(1)* %base to i64 addrspace(1)*
; CHECK: bitcast i32 addrspace(1)* %base to i64 addrspace(1)*
call void @do_safepoint() [ "deopt"() ]
; CHECK: %base.relocated = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token %statepoint_token, i32 7, i32 7)
; CHECK: %base.relocated.casted = bitcast i8 addrspace(1)* %base.relocated to i32 addrspace(1)*
; CHECK: bitcast i32 addrspace(1)* %base.relocated.casted to i64 addrspace(1)*
call void @use_obj32(i32 addrspace(1)* %base)
call void @use_obj64(i64 addrspace(1)* %ptr)
ret void
}
define void @test_bitcast_bitcast(i32 addrspace(1)* %base) gc "statepoint-example" {
; CHECK-LABEL: test_bitcast_bitcast
entry:
%ptr1 = bitcast i32 addrspace(1)* %base to i64 addrspace(1)*
%ptr2 = bitcast i64 addrspace(1)* %ptr1 to i16 addrspace(1)*
; CHECK: bitcast i32 addrspace(1)* %base to i64 addrspace(1)*
; CHECK: bitcast i64 addrspace(1)* %ptr1 to i16 addrspace(1)*
call void @do_safepoint() [ "deopt"() ]
; CHECK: %base.relocated = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token %statepoint_token, i32 7, i32 7)
; CHECK: %base.relocated.casted = bitcast i8 addrspace(1)* %base.relocated to i32 addrspace(1)*
; CHECK: bitcast i32 addrspace(1)* %base.relocated.casted to i64 addrspace(1)*
; CHECK: bitcast i64 addrspace(1)* %ptr1.remat to i16 addrspace(1)*
call void @use_obj32(i32 addrspace(1)* %base)
call void @use_obj16(i16 addrspace(1)* %ptr2)
ret void
}
define void @test_addrspacecast_addrspacecast(i32 addrspace(1)* %base) gc "statepoint-example" {
; CHECK-LABEL: test_addrspacecast_addrspacecast
entry:
%ptr1 = addrspacecast i32 addrspace(1)* %base to i32*
%ptr2 = addrspacecast i32* %ptr1 to i32 addrspace(1)*
; CHECK: addrspacecast i32 addrspace(1)* %base to i32*
; CHECK: addrspacecast i32* %ptr1 to i32 addrspace(1)*
call void @do_safepoint() [ "deopt"() ]
; CHECK: %base.relocated = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token %statepoint_token, i32 7, i32 7)
; CHECK: %base.relocated.casted = bitcast i8 addrspace(1)* %base.relocated to i32 addrspace(1)*
; CHECK: %ptr2.relocated = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token %statepoint_token, i32 7, i32 8)
; CHECK: %ptr2.relocated.casted = bitcast i8 addrspace(1)* %ptr2.relocated to i32 addrspace(1)*
call void @use_obj32(i32 addrspace(1)* %base)
call void @use_obj32(i32 addrspace(1)* %ptr2)
ret void
}
define void @test_bitcast_gep(i32 addrspace(1)* %base) gc "statepoint-example" {
; CHECK-LABEL: test_bitcast_gep
entry:
%ptr.gep = getelementptr i32, i32 addrspace(1)* %base, i32 15
; CHECK: getelementptr
; CHECK: bitcast i32 addrspace(1)* %ptr.gep to i64 addrspace(1)*
%ptr.cast = bitcast i32 addrspace(1)* %ptr.gep to i64 addrspace(1)*
call void @do_safepoint() [ "deopt"() ]
; CHECK: gc.relocate
; CHECK: bitcast
; CHECK: getelementptr
; CHECK: bitcast
call void @use_obj32(i32 addrspace(1)* %base)
call void @use_obj64(i64 addrspace(1)* %ptr.cast)
ret void
@ -52,9 +107,17 @@ define void @test_intersecting_chains(i32 addrspace(1)* %base, i32 %idx) gc "sta
; CHECK-LABEL: test_intersecting_chains
entry:
%ptr.gep = getelementptr i32, i32 addrspace(1)* %base, i32 15
; CHECK: getelementptr
%ptr.cast = bitcast i32 addrspace(1)* %ptr.gep to i64 addrspace(1)*
; CHECK: bitcast
%ptr.cast2 = bitcast i32 addrspace(1)* %ptr.gep to i16 addrspace(1)*
; CHECK: bitcast
call void @do_safepoint() [ "deopt"() ]
; CHECK: getelementptr
; CHECK: bitcast
; CHECK: getelementptr
; CHECK: bitcast
call void @use_obj64(i64 addrspace(1)* %ptr.cast)
call void @use_obj16(i16 addrspace(1)* %ptr.cast2)
ret void
@ -64,11 +127,20 @@ define void @test_cost_threshold(i32 addrspace(1)* %base, i32 %idx1, i32 %idx2,
; CHECK-LABEL: test_cost_threshold
entry:
%ptr.gep = getelementptr i32, i32 addrspace(1)* %base, i32 15
; CHECK: getelementptr
%ptr.gep2 = getelementptr i32, i32 addrspace(1)* %ptr.gep, i32 %idx1
; CHECK: getelementptr
%ptr.gep3 = getelementptr i32, i32 addrspace(1)* %ptr.gep2, i32 %idx2
; CHECK: getelementptr
%ptr.gep4 = getelementptr i32, i32 addrspace(1)* %ptr.gep3, i32 %idx3
; CHECK: getelementptr
%ptr.cast = bitcast i32 addrspace(1)* %ptr.gep4 to i64 addrspace(1)*
call void @do_safepoint() [ "deopt"() ]
; CHECK: gc.relocate
; CHECK: bitcast
; CHECK: gc.relocate
; CHECK: bitcast
call void @use_obj64(i64 addrspace(1)* %ptr.cast)
ret void
}
@ -78,7 +150,14 @@ define void @test_two_derived(i32 addrspace(1)* %base) gc "statepoint-example" {
entry:
%ptr = getelementptr i32, i32 addrspace(1)* %base, i32 15
%ptr2 = getelementptr i32, i32 addrspace(1)* %base, i32 12
; CHECK: getelementptr
; CHECK: getelementptr
call void @do_safepoint() [ "deopt"() ]
; CHECK: gc.relocate
; CHECK: bitcast
; CHECK: getelementptr
; CHECK: getelementptr
call void @use_obj32(i32 addrspace(1)* %ptr)
call void @use_obj32(i32 addrspace(1)* %ptr2)
ret void
@ -88,7 +167,12 @@ define void @test_gep_smallint_array([3 x i32] addrspace(1)* %base) gc "statepoi
; CHECK-LABEL: test_gep_smallint_array
entry:
%ptr = getelementptr [3 x i32], [3 x i32] addrspace(1)* %base, i32 0, i32 2
; CHECK: getelementptr
call void @do_safepoint() [ "deopt"() ]
; CHECK: gc.relocate
; CHECK: bitcast
; CHECK: getelementptr
call void @use_obj32(i32 addrspace(1)* %ptr)
ret void
}
@ -99,19 +183,36 @@ define void @test_invoke(i32 addrspace(1)* %base) gc "statepoint-example" person
; CHECK-LABEL: test_invoke
entry:
%ptr.gep = getelementptr i32, i32 addrspace(1)* %base, i32 15
; CHECK: getelementptr
%ptr.cast = bitcast i32 addrspace(1)* %ptr.gep to i64 addrspace(1)*
; CHECK: bitcast
%ptr.cast2 = bitcast i32 addrspace(1)* %ptr.gep to i16 addrspace(1)*
; CHECK: bitcast
invoke void @do_safepoint() [ "deopt"() ]
to label %normal unwind label %exception
normal: ; preds = %entry
normal:
; CHECK: normal:
; CHECK: gc.relocate
; CHECK: bitcast
; CHECK: getelementptr
; CHECK: bitcast
; CHECK: getelementptr
; CHECK: bitcast
call void @use_obj64(i64 addrspace(1)* %ptr.cast)
call void @use_obj16(i16 addrspace(1)* %ptr.cast2)
ret void
exception: ; preds = %entry
exception:
; CHECK: exception:
%landing_pad4 = landingpad token
cleanup
; CHECK: gc.relocate
; CHECK: bitcast
; CHECK: getelementptr
; CHECK: bitcast
; CHECK: getelementptr
; CHECK: bitcast
call void @use_obj64(i64 addrspace(1)* %ptr.cast)
call void @use_obj16(i16 addrspace(1)* %ptr.cast2)
ret void
@ -121,11 +222,17 @@ define void @test_loop(i32 addrspace(1)* %base) gc "statepoint-example" {
; CHECK-LABEL: test_loop
entry:
%ptr.gep = getelementptr i32, i32 addrspace(1)* %base, i32 15
; CHECK: getelementptr
br label %loop
loop: ; preds = %loop, %entry
; CHECK: phi i32 addrspace(1)* [ %ptr.gep, %entry ], [ %ptr.gep.remat, %loop ]
; CHECK: phi i32 addrspace(1)* [ %base, %entry ], [ %base.relocated.casted, %loop ]
call void @use_obj32(i32 addrspace(1)* %ptr.gep)
call void @do_safepoint() [ "deopt"() ]
; CHECK: gc.relocate
; CHECK: bitcast
; CHECK: getelementptr
br label %loop
}
@ -145,6 +252,10 @@ entry:
%ptr.gep10 = getelementptr i32, i32 addrspace(1)* %ptr.gep9, i32 15
%ptr.gep11 = getelementptr i32, i32 addrspace(1)* %ptr.gep10, i32 15
call void @do_safepoint() [ "deopt"() ]
; CHECK: gc.relocate
; CHECK: bitcast
; CHECK: gc.relocate
; CHECK: bitcast
call void @use_obj32(i32 addrspace(1)* %ptr.gep11)
ret void
}