You've already forked linux-packaging-mono
Imported Upstream version 5.18.0.167
Former-commit-id: 289509151e0fee68a1b591a20c9f109c3c789d3a
This commit is contained in:
parent
e19d552987
commit
b084638f15
@ -1,26 +0,0 @@
|
||||
; RUN: opt < %s -rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s
|
||||
; RUN: opt < %s -passes=rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s
|
||||
|
||||
; CHECK: derived %merged_value base %merged_value.base
|
||||
|
||||
declare void @site_for_call_safpeoint()
|
||||
|
||||
define i64 addrspace(1)* @test(i64 addrspace(1)* %base_obj_x, i64 addrspace(1)* %base_obj_y, i1 %runtime_condition) gc "statepoint-example" {
|
||||
entry:
|
||||
br i1 %runtime_condition, label %here, label %there
|
||||
|
||||
here: ; preds = %entry
|
||||
%x = getelementptr i64, i64 addrspace(1)* %base_obj_x, i32 1
|
||||
br label %merge
|
||||
|
||||
there: ; preds = %entry
|
||||
%y = getelementptr i64, i64 addrspace(1)* %base_obj_y, i32 1
|
||||
br label %merge
|
||||
|
||||
merge: ; preds = %there, %here
|
||||
; CHECK-LABEL: merge:
|
||||
; CHECK: %merged_value.base = phi i64 addrspace(1)* [ %base_obj_x, %here ], [ %base_obj_y, %there ]
|
||||
%merged_value = phi i64 addrspace(1)* [ %x, %here ], [ %y, %there ]
|
||||
call void @site_for_call_safpeoint() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
|
||||
ret i64 addrspace(1)* %merged_value
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
; RUN: opt < %s -rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s
|
||||
; RUN: opt < %s -passes=rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s
|
||||
|
||||
|
||||
declare i1 @runtime_value() "gc-leaf-function"
|
||||
|
||||
declare void @do_safepoint()
|
||||
|
||||
define void @select_of_phi(i64 addrspace(1)* %base_obj_x, i64 addrspace(1)* %base_obj_y) gc "statepoint-example" {
|
||||
entry:
|
||||
br label %loop
|
||||
|
||||
loop: ; preds = %merge, %entry
|
||||
%current_x = phi i64 addrspace(1)* [ %base_obj_x, %entry ], [ %next_x, %merge ]
|
||||
%current_y = phi i64 addrspace(1)* [ %base_obj_y, %entry ], [ %next_y, %merge ]
|
||||
%current = phi i64 addrspace(1)* [ null, %entry ], [ %next, %merge ]
|
||||
%condition = call i1 @runtime_value()
|
||||
%next_x = getelementptr i64, i64 addrspace(1)* %current_x, i32 1
|
||||
%next_y = getelementptr i64, i64 addrspace(1)* %current_y, i32 1
|
||||
br i1 %condition, label %true, label %false
|
||||
|
||||
true: ; preds = %loop
|
||||
br label %merge
|
||||
|
||||
false: ; preds = %loop
|
||||
br label %merge
|
||||
|
||||
merge: ; preds = %false, %true
|
||||
%next = phi i64 addrspace(1)* [ %next_x, %true ], [ %next_y, %false ]
|
||||
call void @do_safepoint() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
|
||||
br label %loop
|
||||
}
|
||||
; CHECK: Base Pairs (w/o Relocation):
|
||||
; CHECK-DAG: derived %next base %next.base
|
||||
; CHECK-DAG: derived %next_x base %base_obj_x
|
||||
; CHECK-DAG: derived %next_y base %base_obj_y
|
@ -1,25 +0,0 @@
|
||||
; RUN: opt < %s -rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s
|
||||
; RUN: opt < %s -passes=rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s
|
||||
|
||||
; CHECK: derived %next base %base_obj
|
||||
|
||||
declare void @do_safepoint()
|
||||
|
||||
define void @test(i64 addrspace(1)* %base_obj) gc "statepoint-example" {
|
||||
entry:
|
||||
%obj = getelementptr i64, i64 addrspace(1)* %base_obj, i32 1
|
||||
br label %loop
|
||||
|
||||
loop: ; preds = %loop, %entry
|
||||
; CHECK-LABEL: loop:
|
||||
; CHECK: phi i64 addrspace(1)*
|
||||
; CHECK-DAG: [ %base_obj.relocated.casted, %loop ]
|
||||
; CHECK-DAG: [ %base_obj, %entry ]
|
||||
; CHECK: %current = phi i64 addrspace(1)*
|
||||
; CHECK-DAG: [ %obj, %entry ]
|
||||
; CHECK-DAG: [ %next.relocated.casted, %loop ]
|
||||
%current = phi i64 addrspace(1)* [ %obj, %entry ], [ %next, %loop ]
|
||||
%next = getelementptr i64, i64 addrspace(1)* %current, i32 1
|
||||
call void @do_safepoint() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
|
||||
br label %loop
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
; RUN: opt < %s -rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s
|
||||
; RUN: opt < %s -passes=rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s
|
||||
|
||||
; CHECK: derived %select base null
|
||||
|
||||
@global = external addrspace(1) global i8
|
||||
|
||||
define i8 @test(i1 %cond) gc "statepoint-example" {
|
||||
%derived1 = getelementptr i8, i8 addrspace(1)* @global, i64 1
|
||||
%derived2 = getelementptr i8, i8 addrspace(1)* @global, i64 2
|
||||
%select = select i1 %cond, i8 addrspace(1)* %derived1, i8 addrspace(1)* %derived2
|
||||
call void @extern()
|
||||
; CHECK-NOT: relocate
|
||||
; CHECK: %load = load i8, i8 addrspace(1)* %select
|
||||
%load = load i8, i8 addrspace(1)* %select
|
||||
ret i8 %load
|
||||
}
|
||||
|
||||
declare void @extern() gc "statepoint-example"
|
||||
|
||||
declare token @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...)
|
@ -1,20 +0,0 @@
|
||||
; RUN: opt < %s -rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s
|
||||
; RUN: opt < %s -passes=rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s
|
||||
|
||||
; CHECK: derived %derived base null
|
||||
|
||||
@global = external addrspace(1) global i8
|
||||
|
||||
define i8 @test(i64 %offset) gc "statepoint-example" {
|
||||
%derived = getelementptr i8, i8 addrspace(1)* @global, i64 %offset
|
||||
call void @extern()
|
||||
; CHECK-NOT: relocate
|
||||
; CHECK-NOT: remat
|
||||
; CHECK: %load = load i8, i8 addrspace(1)* %derived
|
||||
%load = load i8, i8 addrspace(1)* %derived
|
||||
ret i8 %load
|
||||
}
|
||||
|
||||
declare void @extern() gc "statepoint-example"
|
||||
|
||||
declare token @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...)
|
@ -1,20 +0,0 @@
|
||||
; RUN: opt < %s -rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s
|
||||
; RUN: opt < %s -passes=rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s
|
||||
|
||||
; CHECK: derived %merged_value base %base_obj
|
||||
|
||||
define i64 addrspace(1)* @test(i64 addrspace(1)* %base_obj, i1 %runtime_condition) gc "statepoint-example" {
|
||||
entry:
|
||||
br i1 %runtime_condition, label %merge, label %there
|
||||
|
||||
there: ; preds = %entry
|
||||
%derived_obj = getelementptr i64, i64 addrspace(1)* %base_obj, i32 1
|
||||
br label %merge
|
||||
|
||||
merge: ; preds = %there, %entry
|
||||
%merged_value = phi i64 addrspace(1)* [ %base_obj, %entry ], [ %derived_obj, %there ]
|
||||
call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
|
||||
ret i64 addrspace(1)* %merged_value
|
||||
}
|
||||
|
||||
declare void @foo()
|
@ -1,20 +0,0 @@
|
||||
; RUN: opt < %s -rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s
|
||||
; RUN: opt < %s -passes=rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s
|
||||
|
||||
; CHECK: derived %next.i64 base %base_obj
|
||||
|
||||
define void @test(i64 addrspace(1)* %base_obj) gc "statepoint-example" {
|
||||
entry:
|
||||
%obj = getelementptr i64, i64 addrspace(1)* %base_obj, i32 1
|
||||
br label %loop
|
||||
|
||||
loop: ; preds = %loop, %entry
|
||||
%current = phi i64 addrspace(1)* [ %obj, %entry ], [ %next.i64, %loop ]
|
||||
%current.i32 = bitcast i64 addrspace(1)* %current to i32 addrspace(1)*
|
||||
%next.i32 = getelementptr i32, i32 addrspace(1)* %current.i32, i32 1
|
||||
%next.i64 = bitcast i32 addrspace(1)* %next.i32 to i64 addrspace(1)*
|
||||
call void @do_safepoint() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
|
||||
br label %loop
|
||||
}
|
||||
|
||||
declare void @do_safepoint()
|
@ -1,45 +0,0 @@
|
||||
; RUN: opt < %s -rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s
|
||||
; RUN: opt < %s -passes=rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s
|
||||
|
||||
; CHECK: derived %obj_to_consume base %obj_to_consume.base
|
||||
|
||||
declare void @foo()
|
||||
|
||||
declare i64 addrspace(1)* @generate_obj()
|
||||
|
||||
declare void @consume_obj(i64 addrspace(1)*)
|
||||
|
||||
define void @test(i32 %condition) gc "statepoint-example" {
|
||||
entry:
|
||||
br label %loop
|
||||
|
||||
loop: ; preds = %merge.split, %entry
|
||||
; CHECK: loop:
|
||||
; CHECK: [[TOKEN_0:%[^ ]+]] = call token (i64, i32, i64 addrspace(1)* ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_p1i64f(i64 2882400000, i32 0, i64 addrspace(1)* ()* @generate_obj, i32 0, i32 0, i32 0, i32 5, i32 0, i32 -1, i32 0, i32 0, i3
|
||||
; CHECK-NEXT: [[RESULT_0:%[^ ]+]] = call i64 addrspace(1)* @llvm.experimental.gc.result
|
||||
%0 = call i64 addrspace(1)* @generate_obj() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
|
||||
switch i32 %condition, label %dest_a [
|
||||
i32 0, label %dest_b
|
||||
i32 1, label %dest_c
|
||||
]
|
||||
|
||||
dest_a: ; preds = %loop
|
||||
br label %merge
|
||||
|
||||
dest_b: ; preds = %loop
|
||||
br label %merge
|
||||
|
||||
dest_c: ; preds = %loop
|
||||
br label %merge
|
||||
|
||||
merge: ; preds = %dest_c, %dest_b, %dest_a
|
||||
; CHECK: merge:
|
||||
; CHECK: %obj_to_consume = phi i64 addrspace(1)* [ [[RESULT_0]], %dest_a ], [ null, %dest_b ], [ null, %dest_c ]
|
||||
%obj_to_consume = phi i64 addrspace(1)* [ %0, %dest_a ], [ null, %dest_b ], [ null, %dest_c ]
|
||||
call void @consume_obj(i64 addrspace(1)* %obj_to_consume) [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
|
||||
br label %merge.split
|
||||
|
||||
merge.split: ; preds = %merge
|
||||
call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
|
||||
br label %loop
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
; RUN: opt < %s -rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s
|
||||
; RUN: opt < %s -passes=rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s
|
||||
|
||||
; CHECK: derived %merged_value base %merged_value.base
|
||||
|
||||
declare void @foo()
|
||||
|
||||
define i64 addrspace(1)* @test(i64 addrspace(1)* %base_obj_x, i64 addrspace(1)* %base_obj_y, i1 %runtime_condition) gc "statepoint-example" {
|
||||
entry:
|
||||
br i1 %runtime_condition, label %here, label %there
|
||||
|
||||
here: ; preds = %entry
|
||||
br label %bump
|
||||
|
||||
bump: ; preds = %here
|
||||
br label %merge
|
||||
|
||||
there: ; preds = %entry
|
||||
%y = getelementptr i64, i64 addrspace(1)* %base_obj_y, i32 1
|
||||
br label %merge
|
||||
|
||||
merge: ; preds = %there, %bump
|
||||
; CHECK: merge:
|
||||
; CHECK: %merged_value.base = phi i64 addrspace(1)* [ %base_obj_x, %bump ], [ %base_obj_y, %there ]
|
||||
; CHECK-NEXT: %merged_value = phi i64 addrspace(1)* [ %base_obj_x, %bump ], [ %y, %there ]
|
||||
%merged_value = phi i64 addrspace(1)* [ %base_obj_x, %bump ], [ %y, %there ]
|
||||
call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
|
||||
ret i64 addrspace(1)* %merged_value
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
; RUN: opt < %s -rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s
|
||||
; RUN: opt < %s -passes=rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s
|
||||
|
||||
; CHECK: derived %merged_value base %merged_value.base
|
||||
|
||||
declare void @site_for_call_safpeoint()
|
||||
|
||||
define i64 addrspace(1)* @test(i64 addrspace(1)* %base_obj_x, i64 addrspace(1)* %base_obj_y, i1 %runtime_condition_x, i1 %runtime_condition_y) gc "statepoint-example" {
|
||||
entry:
|
||||
br i1 %runtime_condition_x, label %here, label %there
|
||||
|
||||
here: ; preds = %entry
|
||||
br i1 %runtime_condition_y, label %bump_here_a, label %bump_here_b
|
||||
|
||||
bump_here_a: ; preds = %here
|
||||
%x_a = getelementptr i64, i64 addrspace(1)* %base_obj_x, i32 1
|
||||
br label %merge_here
|
||||
|
||||
bump_here_b: ; preds = %here
|
||||
%x_b = getelementptr i64, i64 addrspace(1)* %base_obj_x, i32 2
|
||||
br label %merge_here
|
||||
|
||||
merge_here: ; preds = %bump_here_b, %bump_here_a
|
||||
%x = phi i64 addrspace(1)* [ %x_a, %bump_here_a ], [ %x_b, %bump_here_b ]
|
||||
br label %merge
|
||||
|
||||
there: ; preds = %entry
|
||||
%y = getelementptr i64, i64 addrspace(1)* %base_obj_y, i32 1
|
||||
br label %merge
|
||||
|
||||
merge: ; preds = %there, %merge_here
|
||||
; CHECK: merge:
|
||||
; CHECK: %merged_value.base = phi i64 addrspace(1)* [ %base_obj_x, %merge_here ], [ %base_obj_y, %there ]
|
||||
; CHECK-NEXT: %merged_value = phi i64 addrspace(1)* [ %x, %merge_here ], [ %y, %there ]
|
||||
%merged_value = phi i64 addrspace(1)* [ %x, %merge_here ], [ %y, %there ]
|
||||
call void @site_for_call_safpeoint() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
|
||||
ret i64 addrspace(1)* %merged_value
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
; RUN: opt < %s -rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s
|
||||
; RUN: opt < %s -passes=rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s
|
||||
|
||||
; CHECK: derived %merged_value base %merged_value.base
|
||||
|
||||
declare void @site_for_call_safpeoint()
|
||||
|
||||
define i64 addrspace(1)* @test(i64 addrspace(1)* %base_obj_x, i64 addrspace(1)* %base_obj_y, i1 %runtime_condition_x, i1 %runtime_condition_y) gc "statepoint-example" {
|
||||
entry:
|
||||
br i1 %runtime_condition_x, label %here, label %there
|
||||
|
||||
here: ; preds = %entry
|
||||
br i1 %runtime_condition_y, label %bump_here_a, label %bump_here_b
|
||||
|
||||
bump_here_a: ; preds = %here
|
||||
%x_a = getelementptr i64, i64 addrspace(1)* %base_obj_x, i32 1
|
||||
br label %merge_here
|
||||
|
||||
bump_here_b: ; preds = %here
|
||||
%x_b = getelementptr i64, i64 addrspace(1)* %base_obj_y, i32 2
|
||||
br label %merge_here
|
||||
|
||||
merge_here: ; preds = %bump_here_b, %bump_here_a
|
||||
; CHECK: merge_here:
|
||||
; CHECK-DAG: %x.base
|
||||
; CHECK-DAG: phi i64 addrspace(1)*
|
||||
; CHECK-DAG: [ %base_obj_x, %bump_here_a ]
|
||||
; CHECK-DAG: [ %base_obj_y, %bump_here_b ]
|
||||
%x = phi i64 addrspace(1)* [ %x_a, %bump_here_a ], [ %x_b, %bump_here_b ]
|
||||
br label %merge
|
||||
|
||||
there: ; preds = %entry
|
||||
%y = getelementptr i64, i64 addrspace(1)* %base_obj_y, i32 1
|
||||
br label %merge
|
||||
|
||||
merge: ; preds = %there, %merge_here
|
||||
; CHECK: merge:
|
||||
; CHECK-DAG: %merged_value.base
|
||||
; CHECK-DAG: phi i64 addrspace(1)*
|
||||
; CHECK-DAG: %merge_here
|
||||
; CHECK-DAG: [ %base_obj_y, %there ]
|
||||
; CHECK: %merged_value = phi i64 addrspace(1)* [ %x, %merge_here ], [ %y, %there ]
|
||||
%merged_value = phi i64 addrspace(1)* [ %x, %merge_here ], [ %y, %there ]
|
||||
call void @site_for_call_safpeoint() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
|
||||
ret i64 addrspace(1)* %merged_value
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
; RUN: opt < %s -rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s
|
||||
; RUN: opt < %s -passes=rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s
|
||||
|
||||
; CHECK: derived %next_element_ptr base %array_obj
|
||||
|
||||
define i32 @null_in_array(i64 addrspace(1)* %array_obj) gc "statepoint-example" {
|
||||
entry:
|
||||
%array_len_pointer.i64 = getelementptr i64, i64 addrspace(1)* %array_obj, i32 1
|
||||
%array_len_pointer.i32 = bitcast i64 addrspace(1)* %array_len_pointer.i64 to i32 addrspace(1)*
|
||||
%array_len = load i32, i32 addrspace(1)* %array_len_pointer.i32
|
||||
%array_elems = bitcast i32 addrspace(1)* %array_len_pointer.i32 to i64 addrspace(1)* addrspace(1)*
|
||||
br label %loop_check
|
||||
|
||||
loop_check: ; preds = %loop_back, %entry
|
||||
%index = phi i32 [ 0, %entry ], [ %next_index, %loop_back ]
|
||||
%current_element_ptr = phi i64 addrspace(1)* addrspace(1)* [ %array_elems, %entry ], [ %next_element_ptr, %loop_back ]
|
||||
%index_lt = icmp ult i32 %index, %array_len
|
||||
br i1 %index_lt, label %check_for_null, label %not_found
|
||||
|
||||
check_for_null: ; preds = %loop_check
|
||||
%current_element = load i64 addrspace(1)*, i64 addrspace(1)* addrspace(1)* %current_element_ptr
|
||||
%is_null = icmp eq i64 addrspace(1)* %current_element, null
|
||||
br i1 %is_null, label %found, label %loop_back
|
||||
|
||||
loop_back: ; preds = %check_for_null
|
||||
%next_element_ptr = getelementptr i64 addrspace(1)*, i64 addrspace(1)* addrspace(1)* %current_element_ptr, i32 1
|
||||
%next_index = add i32 %index, 1
|
||||
call void @do_safepoint() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
|
||||
br label %loop_check
|
||||
|
||||
not_found: ; preds = %loop_check
|
||||
ret i32 -1
|
||||
|
||||
found: ; preds = %check_for_null
|
||||
ret i32 %index
|
||||
}
|
||||
|
||||
declare void @do_safepoint()
|
@ -1,21 +0,0 @@
|
||||
; RUN: opt < %s -rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s
|
||||
; RUN: opt < %s -passes=rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s
|
||||
|
||||
; CHECK: derived %next base %base_obj
|
||||
|
||||
declare i1 @runtime_value() "gc-leaf-function"
|
||||
|
||||
define void @maybe_GEP(i64 addrspace(1)* %base_obj) gc "statepoint-example" {
|
||||
entry:
|
||||
br label %loop
|
||||
|
||||
loop: ; preds = %loop, %entry
|
||||
%current = phi i64 addrspace(1)* [ %base_obj, %entry ], [ %next, %loop ]
|
||||
%condition = call i1 @runtime_value()
|
||||
%maybe_next = getelementptr i64, i64 addrspace(1)* %current, i32 1
|
||||
%next = select i1 %condition, i64 addrspace(1)* %maybe_next, i64 addrspace(1)* %current
|
||||
call void @do_safepoint() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
|
||||
br label %loop
|
||||
}
|
||||
|
||||
declare void @do_safepoint()
|
@ -1,155 +0,0 @@
|
||||
; RUN: opt < %s -rewrite-statepoints-for-gc -S 2>&1 | FileCheck %s
|
||||
; RUN: opt < %s -passes=rewrite-statepoints-for-gc -S 2>&1 | FileCheck %s
|
||||
|
||||
; The rewriting needs to make %obj loop variant by inserting a phi
|
||||
; of the original value and it's relocation.
|
||||
|
||||
declare i64 addrspace(1)* @generate_obj() "gc-leaf-function"
|
||||
|
||||
declare void @use_obj(i64 addrspace(1)*) "gc-leaf-function"
|
||||
|
||||
define void @def_use_safepoint() gc "statepoint-example" {
|
||||
; CHECK-LABEL: def_use_safepoint
|
||||
; CHECK: phi i64 addrspace(1)*
|
||||
; CHECK-DAG: [ %obj.relocated.casted, %loop ]
|
||||
; CHECK-DAG: [ %obj, %entry ]
|
||||
entry:
|
||||
%obj = call i64 addrspace(1)* @generate_obj()
|
||||
br label %loop
|
||||
|
||||
loop: ; preds = %loop, %entry
|
||||
call void @use_obj(i64 addrspace(1)* %obj)
|
||||
call void @do_safepoint() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
|
||||
br label %loop
|
||||
}
|
||||
|
||||
declare void @do_safepoint()
|
||||
|
||||
declare void @parse_point(i64 addrspace(1)*)
|
||||
|
||||
define i64 addrspace(1)* @test1(i32 %caller, i8 addrspace(1)* %a, i8 addrspace(1)* %b, i32 %unknown) gc "statepoint-example" {
|
||||
; CHECK-LABEL: test1
|
||||
entry:
|
||||
br i1 undef, label %left, label %right
|
||||
|
||||
left: ; preds = %entry
|
||||
; CHECK: left:
|
||||
; CHECK-NEXT: %a.cast = bitcast i8 addrspace(1)* %a to i64 addrspace(1)*
|
||||
; CHECK-NEXT: [[CAST_L:%.*]] = bitcast i8 addrspace(1)* %a to i64 addrspace(1)*
|
||||
; Our safepoint placement pass calls removeUnreachableBlocks, which does a bunch
|
||||
; of simplifications to branch instructions. This bug is visible only when
|
||||
; there are multiple branches into the same block from the same predecessor, and
|
||||
; the following ceremony is to make that artefact survive a call to
|
||||
; removeUnreachableBlocks. As an example, "br i1 undef, label %merge, label %merge"
|
||||
; will get simplified to "br label %merge" by removeUnreachableBlocks.
|
||||
%a.cast = bitcast i8 addrspace(1)* %a to i64 addrspace(1)*
|
||||
switch i32 %unknown, label %right [
|
||||
i32 0, label %merge
|
||||
i32 1, label %merge
|
||||
i32 5, label %merge
|
||||
i32 3, label %right
|
||||
]
|
||||
|
||||
right: ; preds = %left, %left, %entry
|
||||
; CHECK: right:
|
||||
; CHECK-NEXT: %b.cast = bitcast i8 addrspace(1)* %b to i64 addrspace(1)*
|
||||
; CHECK-NEXT: [[CAST_R:%.*]] = bitcast i8 addrspace(1)* %b to i64 addrspace(1)*
|
||||
%b.cast = bitcast i8 addrspace(1)* %b to i64 addrspace(1)*
|
||||
br label %merge
|
||||
|
||||
merge: ; preds = %right, %left, %left, %left
|
||||
; CHECK: merge:
|
||||
; CHECK-NEXT: %value.base = phi i64 addrspace(1)* [ [[CAST_L]], %left ], [ [[CAST_L]], %left ], [ [[CAST_L]], %left ], [ [[CAST_R]], %right ], !is_base_value !0
|
||||
%value = phi i64 addrspace(1)* [ %a.cast, %left ], [ %a.cast, %left ], [ %a.cast, %left ], [ %b.cast, %right ]
|
||||
call void @parse_point(i64 addrspace(1)* %value) [ "deopt"(i32 0, i32 0, i32 0, i32 0, i32 0) ]
|
||||
ret i64 addrspace(1)* %value
|
||||
}
|
||||
|
||||
;; The purpose of this test is to ensure that when two live values share a
|
||||
;; base defining value with inherent conflicts, we end up with a *single*
|
||||
;; base phi/select per such node. This is testing an optimization, not a
|
||||
;; fundemental correctness criteria
|
||||
define void @test2(i1 %cnd, i64 addrspace(1)* %base_obj, i64 addrspace(1)* %base_arg2) gc "statepoint-example" {
|
||||
; CHECK-LABEL: @test2
|
||||
entry:
|
||||
%obj = getelementptr i64, i64 addrspace(1)* %base_obj, i32 1
|
||||
br label %loop
|
||||
; CHECK-LABEL: loop
|
||||
; CHECK: %current.base = phi i64 addrspace(1)*
|
||||
; CHECK-DAG: [ %base_obj, %entry ]
|
||||
|
||||
; Given the two selects are equivelent, so are their base phis - ideally,
|
||||
; we'd have commoned these, but that's a missed optimization, not correctness.
|
||||
; CHECK-DAG: [ [[DISCARD:%.*.base.relocated.casted]], %loop ]
|
||||
; CHECK-NOT: extra.base
|
||||
; CHECK: next.base = select
|
||||
; CHECK: next = select
|
||||
; CHECK: extra2.base = select
|
||||
; CHECK: extra2 = select
|
||||
; CHECK: statepoint
|
||||
;; Both 'next' and 'extra2' are live across the backedge safepoint...
|
||||
|
||||
loop: ; preds = %loop, %entry
|
||||
%current = phi i64 addrspace(1)* [ %obj, %entry ], [ %next, %loop ]
|
||||
%extra = phi i64 addrspace(1)* [ %obj, %entry ], [ %extra2, %loop ]
|
||||
%nexta = getelementptr i64, i64 addrspace(1)* %current, i32 1
|
||||
%next = select i1 %cnd, i64 addrspace(1)* %nexta, i64 addrspace(1)* %base_arg2
|
||||
%extra2 = select i1 %cnd, i64 addrspace(1)* %nexta, i64 addrspace(1)* %base_arg2
|
||||
call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
|
||||
br label %loop
|
||||
}
|
||||
|
||||
define i64 addrspace(1)* @test3(i1 %cnd, i64 addrspace(1)* %obj, i64 addrspace(1)* %obj2) gc "statepoint-example" {
|
||||
; CHECK-LABEL: @test3
|
||||
entry:
|
||||
br i1 %cnd, label %merge, label %taken
|
||||
|
||||
taken: ; preds = %entry
|
||||
br label %merge
|
||||
|
||||
merge: ; preds = %taken, %entry
|
||||
; CHECK-LABEL: merge:
|
||||
; CHECK-NEXT: phi
|
||||
; CHECK-NEXT: phi
|
||||
; CHECK-NEXT: gc.statepoint
|
||||
%bdv = phi i64 addrspace(1)* [ %obj, %entry ], [ %obj2, %taken ]
|
||||
call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
|
||||
ret i64 addrspace(1)* %bdv
|
||||
}
|
||||
|
||||
define i64 addrspace(1)* @test4(i1 %cnd, i64 addrspace(1)* %obj, i64 addrspace(1)* %obj2) gc "statepoint-example" {
|
||||
; CHECK-LABEL: @test4
|
||||
entry:
|
||||
br i1 %cnd, label %merge, label %taken
|
||||
|
||||
taken: ; preds = %entry
|
||||
br label %merge
|
||||
|
||||
merge: ; preds = %taken, %entry
|
||||
; CHECK-LABEL: merge:
|
||||
; CHECK-NEXT: phi
|
||||
; CHECK-NEXT: gc.statepoint
|
||||
%bdv = phi i64 addrspace(1)* [ %obj, %entry ], [ %obj, %taken ]
|
||||
call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
|
||||
ret i64 addrspace(1)* %bdv
|
||||
}
|
||||
|
||||
define i64 addrspace(1)* @test5(i1 %cnd, i64 addrspace(1)* %obj, i64 addrspace(1)* %obj2) gc "statepoint-example" {
|
||||
; CHECK-LABEL: @test5
|
||||
entry:
|
||||
br label %merge
|
||||
|
||||
merge: ; preds = %merge, %entry
|
||||
; CHECK-LABEL: merge:
|
||||
; CHECK-NEXT: phi
|
||||
; CHECK-NEXT: phi
|
||||
; CHECK-NEXT: br i1
|
||||
%bdv = phi i64 addrspace(1)* [ %obj, %entry ], [ %obj2, %merge ]
|
||||
br i1 %cnd, label %merge, label %next
|
||||
|
||||
next: ; preds = %merge
|
||||
call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
|
||||
ret i64 addrspace(1)* %bdv
|
||||
}
|
||||
|
||||
declare void @foo()
|
@ -1,263 +0,0 @@
|
||||
; RUN: opt < %s -rewrite-statepoints-for-gc -S | FileCheck %s
|
||||
; RUN: opt < %s -passes=rewrite-statepoints-for-gc -S | FileCheck %s
|
||||
|
||||
|
||||
define i64 addrspace(1)* @test(<2 x i64 addrspace(1)*> %vec, i32 %idx) gc "statepoint-example" {
|
||||
; CHECK-LABEL: @test
|
||||
; CHECK: extractelement
|
||||
; CHECK: extractelement
|
||||
; CHECK: statepoint
|
||||
; CHECK: gc.relocate
|
||||
; CHECK-DAG: ; (%base_ee, %obj)
|
||||
; CHECK: gc.relocate
|
||||
; CHECK-DAG: ; (%base_ee, %base_ee)
|
||||
; Note that the second extractelement is actually redundant here. A correct output would
|
||||
; be to reuse the existing obj as a base since it is actually a base pointer.
|
||||
entry:
|
||||
%obj = extractelement <2 x i64 addrspace(1)*> %vec, i32 %idx
|
||||
call void @do_safepoint() [ "deopt"() ]
|
||||
ret i64 addrspace(1)* %obj
|
||||
}
|
||||
|
||||
define i64 addrspace(1)* @test2(<2 x i64 addrspace(1)*>* %ptr, i1 %cnd, i32 %idx1, i32 %idx2) gc "statepoint-example" {
|
||||
; CHECK-LABEL: test2
|
||||
entry:
|
||||
br i1 %cnd, label %taken, label %untaken
|
||||
|
||||
taken: ; preds = %entry
|
||||
%obja = load <2 x i64 addrspace(1)*>, <2 x i64 addrspace(1)*>* %ptr
|
||||
br label %merge
|
||||
|
||||
untaken: ; preds = %entry
|
||||
%objb = load <2 x i64 addrspace(1)*>, <2 x i64 addrspace(1)*>* %ptr
|
||||
br label %merge
|
||||
|
||||
merge: ; preds = %untaken, %taken
|
||||
%vec = phi <2 x i64 addrspace(1)*> [ %obja, %taken ], [ %objb, %untaken ]
|
||||
br i1 %cnd, label %taken2, label %untaken2
|
||||
|
||||
taken2: ; preds = %merge
|
||||
%obj0 = extractelement <2 x i64 addrspace(1)*> %vec, i32 %idx1
|
||||
br label %merge2
|
||||
|
||||
untaken2: ; preds = %merge
|
||||
%obj1 = extractelement <2 x i64 addrspace(1)*> %vec, i32 %idx2
|
||||
br label %merge2
|
||||
|
||||
merge2: ; preds = %untaken2, %taken2
|
||||
; CHECK-LABEL: merge2:
|
||||
; CHECK: %obj.base = phi i64 addrspace(1)*
|
||||
; CHECK: %obj = phi i64 addrspace(1)*
|
||||
; CHECK: statepoint
|
||||
; CHECK: gc.relocate
|
||||
; CHECK-DAG: ; (%obj.base, %obj)
|
||||
; CHECK: gc.relocate
|
||||
; CHECK-DAG: ; (%obj.base, %obj.base)
|
||||
%obj = phi i64 addrspace(1)* [ %obj0, %taken2 ], [ %obj1, %untaken2 ]
|
||||
call void @do_safepoint() [ "deopt"() ]
|
||||
ret i64 addrspace(1)* %obj
|
||||
}
|
||||
|
||||
define i64 addrspace(1)* @test3(i64 addrspace(1)* %ptr) gc "statepoint-example" {
|
||||
; CHECK-LABEL: test3
|
||||
; CHECK: insertelement
|
||||
; CHECK: extractelement
|
||||
; CHECK: statepoint
|
||||
; CHECK: gc.relocate
|
||||
; CHECK-DAG: (%obj.base, %obj)
|
||||
entry:
|
||||
%vec = insertelement <2 x i64 addrspace(1)*> undef, i64 addrspace(1)* %ptr, i32 0
|
||||
%obj = extractelement <2 x i64 addrspace(1)*> %vec, i32 0
|
||||
call void @do_safepoint() [ "deopt"() ]
|
||||
ret i64 addrspace(1)* %obj
|
||||
}
|
||||
|
||||
define i64 addrspace(1)* @test4(i64 addrspace(1)* %ptr) gc "statepoint-example" {
|
||||
; CHECK-LABEL: test4
|
||||
; CHECK: statepoint
|
||||
; CHECK: gc.relocate
|
||||
; CHECK-DAG: ; (%obj.base, %obj)
|
||||
; When we can optimize an extractelement from a known
|
||||
; index and avoid introducing new base pointer instructions
|
||||
entry:
|
||||
%derived = getelementptr i64, i64 addrspace(1)* %ptr, i64 16
|
||||
%veca = insertelement <2 x i64 addrspace(1)*> undef, i64 addrspace(1)* %derived, i32 0
|
||||
%vec = insertelement <2 x i64 addrspace(1)*> %veca, i64 addrspace(1)* %ptr, i32 1
|
||||
%obj = extractelement <2 x i64 addrspace(1)*> %vec, i32 0
|
||||
call void @do_safepoint() [ "deopt"() ]
|
||||
ret i64 addrspace(1)* %obj
|
||||
}
|
||||
|
||||
declare void @use(i64 addrspace(1)*) "gc-leaf-function"
|
||||
declare void @use_vec(<4 x i64 addrspace(1)*>) "gc-leaf-function"
|
||||
|
||||
define void @test5(i1 %cnd, i64 addrspace(1)* %obj) gc "statepoint-example" {
|
||||
; CHECK-LABEL: @test5
|
||||
; CHECK: gc.relocate
|
||||
; CHECK-DAG: (%bdv.base, %bdv)
|
||||
; When we fundementally have to duplicate
|
||||
entry:
|
||||
%gep = getelementptr i64, i64 addrspace(1)* %obj, i64 1
|
||||
%vec = insertelement <2 x i64 addrspace(1)*> undef, i64 addrspace(1)* %gep, i32 0
|
||||
%bdv = extractelement <2 x i64 addrspace(1)*> %vec, i32 0
|
||||
call void @do_safepoint() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
|
||||
call void @use(i64 addrspace(1)* %bdv)
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @test6(i1 %cnd, i64 addrspace(1)* %obj, i64 %idx) gc "statepoint-example" {
|
||||
; CHECK-LABEL: @test6
|
||||
; CHECK: %gep = getelementptr i64, i64 addrspace(1)* %obj, i64 1
|
||||
; CHECK: %vec.base = insertelement <2 x i64 addrspace(1)*> zeroinitializer, i64 addrspace(1)* %obj, i32 0, !is_base_value !0
|
||||
; CHECK: %vec = insertelement <2 x i64 addrspace(1)*> undef, i64 addrspace(1)* %gep, i32 0
|
||||
; CHECK: %bdv.base = extractelement <2 x i64 addrspace(1)*> %vec.base, i64 %idx, !is_base_value !0
|
||||
; CHECK: %bdv = extractelement <2 x i64 addrspace(1)*> %vec, i64 %idx
|
||||
; CHECK: gc.statepoint
|
||||
; CHECK: gc.relocate
|
||||
; CHECK-DAG: (%bdv.base, %bdv)
|
||||
; A more complicated example involving vector and scalar bases.
|
||||
; This is derived from a failing test case when we didn't have correct
|
||||
; insertelement handling.
|
||||
entry:
|
||||
%gep = getelementptr i64, i64 addrspace(1)* %obj, i64 1
|
||||
%vec = insertelement <2 x i64 addrspace(1)*> undef, i64 addrspace(1)* %gep, i32 0
|
||||
%bdv = extractelement <2 x i64 addrspace(1)*> %vec, i64 %idx
|
||||
call void @do_safepoint() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
|
||||
call void @use(i64 addrspace(1)* %bdv)
|
||||
ret void
|
||||
}
|
||||
|
||||
define i64 addrspace(1)* @test7(i1 %cnd, i64 addrspace(1)* %obj, i64 addrspace(1)* %obj2) gc "statepoint-example" {
|
||||
; CHECK-LABEL: @test7
|
||||
entry:
|
||||
%vec = insertelement <2 x i64 addrspace(1)*> undef, i64 addrspace(1)* %obj2, i32 0
|
||||
br label %merge1
|
||||
|
||||
merge1: ; preds = %merge1, %entry
|
||||
; CHECK-LABEL: merge1:
|
||||
; CHECK: vec2.base
|
||||
; CHECK: vec2
|
||||
; CHECK: gep
|
||||
; CHECK: vec3.base
|
||||
; CHECK: vec3
|
||||
%vec2 = phi <2 x i64 addrspace(1)*> [ %vec, %entry ], [ %vec3, %merge1 ]
|
||||
%gep = getelementptr i64, i64 addrspace(1)* %obj2, i64 1
|
||||
%vec3 = insertelement <2 x i64 addrspace(1)*> undef, i64 addrspace(1)* %gep, i32 0
|
||||
br i1 %cnd, label %merge1, label %next1
|
||||
|
||||
next1: ; preds = %merge1
|
||||
; CHECK-LABEL: next1:
|
||||
; CHECK: bdv.base =
|
||||
; CHECK: bdv =
|
||||
%bdv = extractelement <2 x i64 addrspace(1)*> %vec2, i32 0
|
||||
br label %merge
|
||||
|
||||
merge: ; preds = %merge, %next1
|
||||
; CHECK-LABEL: merge:
|
||||
; CHECK: %objb.base
|
||||
; CHECK: %objb
|
||||
; CHECK: gc.statepoint
|
||||
; CHECK: gc.relocate
|
||||
; CHECK-DAG: (%objb.base, %objb)
|
||||
%objb = phi i64 addrspace(1)* [ %obj, %next1 ], [ %bdv, %merge ]
|
||||
br i1 %cnd, label %merge, label %next
|
||||
|
||||
next: ; preds = %merge
|
||||
call void @do_safepoint() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
|
||||
ret i64 addrspace(1)* %objb
|
||||
}
|
||||
|
||||
; identify base for shufflevector
|
||||
define void @test8(i64 addrspace(1)* %obj, i64 %idx) gc "statepoint-example" {
|
||||
; CHECK-LABEL: @test8
|
||||
; CHECK: %gep = getelementptr i64, i64 addrspace(1)* %obj, i64 1
|
||||
; CHECK: %gep2 = getelementptr i64, i64 addrspace(1)* %obj, i64 2
|
||||
; CHECK: %vec1.base = insertelement <4 x i64 addrspace(1)*> zeroinitializer, i64 addrspace(1)* %obj, i32 0, !is_base_value !0
|
||||
; CHECK: %vec1 = insertelement <4 x i64 addrspace(1)*> undef, i64 addrspace(1)* %gep, i32 0
|
||||
; CHECK: %vec2.base = insertelement <4 x i64 addrspace(1)*> zeroinitializer, i64 addrspace(1)* %obj, i32 2, !is_base_value !0
|
||||
; CHECK: %vec2 = insertelement <4 x i64 addrspace(1)*> undef, i64 addrspace(1)* %gep2, i32 2
|
||||
; CHECK: %vec.base = shufflevector <4 x i64 addrspace(1)*> %vec1.base, <4 x i64 addrspace(1)*> %vec2.base, <2 x i32> <i32 0, i32 2>, !is_base_value !0
|
||||
; CHECK: %vec = shufflevector <4 x i64 addrspace(1)*> %vec1, <4 x i64 addrspace(1)*> %vec2, <2 x i32> <i32 0, i32 2>
|
||||
; CHECK: %bdv.base = extractelement <2 x i64 addrspace(1)*> %vec.base, i64 %idx, !is_base_value !0
|
||||
; CHECK: %bdv = extractelement <2 x i64 addrspace(1)*> %vec, i64 %idx
|
||||
; CHECK: gc.statepoint
|
||||
; CHECK: gc.relocate
|
||||
; CHECK-DAG: (%bdv.base, %bdv)
|
||||
entry:
|
||||
%gep = getelementptr i64, i64 addrspace(1)* %obj, i64 1
|
||||
%gep2 = getelementptr i64, i64 addrspace(1)* %obj, i64 2
|
||||
%vec1 = insertelement <4 x i64 addrspace(1)*> undef, i64 addrspace(1)* %gep, i32 0
|
||||
%vec2 = insertelement <4 x i64 addrspace(1)*> undef, i64 addrspace(1)* %gep2, i32 2
|
||||
%vec = shufflevector <4 x i64 addrspace(1)*> %vec1, <4 x i64 addrspace(1)*> %vec2, <2 x i32> <i32 0, i32 2>
|
||||
%bdv = extractelement <2 x i64 addrspace(1)*> %vec, i64 %idx
|
||||
call void @do_safepoint() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
|
||||
call void @use(i64 addrspace(1)* %bdv)
|
||||
ret void
|
||||
}
|
||||
|
||||
; Since the same 'base' vector is used in the shuffle operands, we do not need
|
||||
; create a shufflevector base.
|
||||
define void @test9(<4 x i64 addrspace(1)*> %vec1, i64 %idx) gc "statepoint-example" {
|
||||
; CHECK-LABEL: @test9
|
||||
; CHECK: %vec = shufflevector <4 x i64 addrspace(1)*> %vec1, <4 x i64 addrspace(1)*> %vec1, <2 x i32> <i32 0, i32 2>
|
||||
; CHECK: %base_ee = extractelement <4 x i64 addrspace(1)*> %vec1, i64 %idx, !is_base_value !0
|
||||
; CHECK: %bdv = extractelement <2 x i64 addrspace(1)*> %vec, i64 %idx
|
||||
; CHECK: gc.statepoint
|
||||
; CHECK: gc.relocate
|
||||
; CHECK-DAG: (%base_ee, %bdv)
|
||||
entry:
|
||||
; shrinking vec1 into vec
|
||||
%vec = shufflevector <4 x i64 addrspace(1)*> %vec1, <4 x i64 addrspace(1)*> %vec1, <2 x i32> <i32 0, i32 2>
|
||||
%bdv = extractelement <2 x i64 addrspace(1)*> %vec, i64 %idx
|
||||
call void @do_safepoint() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
|
||||
call void @use(i64 addrspace(1)* %bdv)
|
||||
ret void
|
||||
}
|
||||
|
||||
; vector operand of shufflevector is a phi
|
||||
define i64 addrspace(1)* @test10(i1 %cnd, i64 addrspace(1)* %obj, i64 addrspace(1)* %obj2) gc "statepoint-example" {
|
||||
; CHECK-LABEL: @test10
|
||||
entry:
|
||||
%vec1 = insertelement <4 x i64 addrspace(1)*> undef, i64 addrspace(1)* %obj, i32 0
|
||||
br i1 %cnd, label %here, label %merge
|
||||
|
||||
here:
|
||||
%vec2 = insertelement <4 x i64 addrspace(1)*> undef, i64 addrspace(1)* %obj2, i32 2
|
||||
br label %merge
|
||||
|
||||
merge: ; preds = %merge, %entry, %here
|
||||
; CHECK-LABEL: merge:
|
||||
; CHECK: %vec.base = phi <4 x i64 addrspace(1)*> [ %vec1.base, %entry ], [ %vec2.base, %here ], [ %vec3.base, %merge ], !is_base_value !0
|
||||
; CHECK: vec
|
||||
; CHECK: vec3.base = shufflevector <4 x i64 addrspace(1)*> %vec.base, <4 x i64 addrspace(1)*> %vec.base
|
||||
; CHECK: vec3
|
||||
; CHECK: bdv.base
|
||||
; CHECK: bdv
|
||||
%vec = phi <4 x i64 addrspace(1)*> [ %vec1, %entry ], [ %vec2, %here], [ %vec3, %merge]
|
||||
%vec3 = shufflevector <4 x i64 addrspace(1)*> %vec, <4 x i64 addrspace(1)*> %vec, <4 x i32> <i32 2, i32 0, i32 1, i32 3>
|
||||
%bdv = extractelement <4 x i64 addrspace(1)*> %vec3, i32 0
|
||||
br i1 %cnd, label %merge, label %next
|
||||
|
||||
next:
|
||||
; CHECK-LABEL: next:
|
||||
; CHECK: gc.statepoint
|
||||
; CHECK: gc.relocate
|
||||
; CHECK-DAG: (%bdv.base, %bdv)
|
||||
call void @do_safepoint() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
|
||||
ret i64 addrspace(1)* %bdv
|
||||
}
|
||||
declare void @do_safepoint()
|
||||
|
||||
define void @test11(<4 x i64 addrspace(1)*> %vec1) gc "statepoint-example" {
|
||||
; CHECK-LABEL: @test11(
|
||||
; CHECK: @llvm.experimental.gc.statepoint.p0f_isVoidf{{.*}}<4 x i64 addrspace(1)*> %vec1)
|
||||
; CHECK: %vec1.relocated = call coldcc <4 x i8 addrspace(1)*> @llvm.experimental.gc.relocate.v4p1i8
|
||||
; CHECK: %vec1.relocated.casted = bitcast <4 x i8 addrspace(1)*> %vec1.relocated to <4 x i64 addrspace(1)*>
|
||||
; CHECK: %vec2.remat = getelementptr i64, <4 x i64 addrspace(1)*> %vec1.relocated.casted, i32 1024
|
||||
; CHECK: call void @use_vec(<4 x i64 addrspace(1)*> %vec2.remat)
|
||||
entry:
|
||||
%vec2 = getelementptr i64, <4 x i64 addrspace(1)*> %vec1, i32 1024
|
||||
call void @do_safepoint() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
|
||||
call void @use_vec(<4 x i64 addrspace(1) *> %vec2)
|
||||
ret void
|
||||
}
|
@ -1,74 +0,0 @@
|
||||
; RUN: opt -S -rewrite-statepoints-for-gc < %s | FileCheck %s
|
||||
; RUN: opt -S -passes=rewrite-statepoints-for-gc < %s | FileCheck %s
|
||||
|
||||
declare void @g()
|
||||
declare i32 @h()
|
||||
|
||||
define i32 addrspace(1)* @f0(i32 addrspace(1)* %arg) gc "statepoint-example" {
|
||||
; CHECK-LABEL: @f0(
|
||||
entry:
|
||||
; CHECK: [[TOKEN_0:%[^ ]+]] = call token {{[^@]*}} @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* @g, i32 0, i32 0, i32 0, i32 1, i32 100, i32 addrspace(1)* %arg)
|
||||
call void @g() [ "deopt"(i32 100) ]
|
||||
|
||||
; CHECK: %arg.relocated = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[TOKEN_0]], i32 8, i32 8)
|
||||
ret i32 addrspace(1)* %arg
|
||||
}
|
||||
|
||||
define i32 addrspace(1)* @f1(i32 addrspace(1)* %arg) gc "statepoint-example" personality i32 8 {
|
||||
; CHECK-LABEL: @f1(
|
||||
entry:
|
||||
; CHECK: [[TOKEN_1:%[^ ]+]] = invoke token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* @g, i32 0, i32 0, i32 0, i32 1, i32 100, i32 addrspace(1)* %arg)
|
||||
invoke void @g() [ "deopt"(i32 100) ] to label %normal_dest unwind label %unwind_dest
|
||||
|
||||
normal_dest:
|
||||
; CHECK: %arg.relocated1 = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[TOKEN_1]], i32 8, i32 8)
|
||||
ret i32 addrspace(1)* %arg
|
||||
|
||||
unwind_dest:
|
||||
%lpad = landingpad token cleanup
|
||||
resume token undef
|
||||
}
|
||||
|
||||
define i32 addrspace(1)* @f2(i32 addrspace(1)* %arg) gc "statepoint-example" {
|
||||
; CHECK-LABEL: @f2(
|
||||
entry:
|
||||
; CHECK: [[TOKEN_2:%[^ ]+]] = call token (i64, i32, i32 ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_i32f(i64 2882400000, i32 0, i32 ()* @h, i32 0, i32 0, i32 0, i32 1, i32 100, i32 addrspace(1)* %arg)
|
||||
%val = call i32 @h() [ "deopt"(i32 100) ]
|
||||
|
||||
; CHECK: [[RESULT_F2:%[^ ]+]] = call i32 @llvm.experimental.gc.result.i32(token [[TOKEN_2]])
|
||||
; CHECK: %arg.relocated = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[TOKEN_2]], i32 8, i32 8)
|
||||
; CHECK: %arg.relocated.casted = bitcast i8 addrspace(1)* %arg.relocated to i32 addrspace(1)*
|
||||
|
||||
store i32 %val, i32 addrspace(1)* %arg
|
||||
; CHECK: store i32 [[RESULT_F2]], i32 addrspace(1)* %arg.relocated.casted
|
||||
ret i32 addrspace(1)* %arg
|
||||
}
|
||||
|
||||
define i32 addrspace(1)* @f3(i32 addrspace(1)* %arg) gc "statepoint-example" personality i32 8 {
|
||||
; CHECK-LABEL: @f3(
|
||||
entry:
|
||||
; CHECK: [[TOKEN_3:%[^ ]+]] = invoke token (i64, i32, i32 ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_i32f(i64 2882400000, i32 0, i32 ()* @h, i32 0, i32 0, i32 0, i32 1, i32 100, i32 addrspace(1)* %arg)
|
||||
%val = invoke i32 @h() [ "deopt"(i32 100) ] to label %normal_dest unwind label %unwind_dest
|
||||
|
||||
normal_dest:
|
||||
; CHECK: [[RESULT_F3:%[^ ]+]] = call i32 @llvm.experimental.gc.result.i32(token [[TOKEN_3]])
|
||||
; CHECK: [[ARG_RELOCATED:%[^ ]+]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[TOKEN_3]], i32 8, i32 8)
|
||||
; CHECK: [[ARG_RELOCATED_CASTED:%[^ ]+]] = bitcast i8 addrspace(1)* [[ARG_RELOCATED]] to i32 addrspace(1)*
|
||||
|
||||
store i32 %val, i32 addrspace(1)* %arg
|
||||
|
||||
; CHECK: store i32 [[RESULT_F3]], i32 addrspace(1)* [[ARG_RELOCATED_CASTED]]
|
||||
ret i32 addrspace(1)* %arg
|
||||
|
||||
unwind_dest:
|
||||
%lpad = landingpad token cleanup
|
||||
resume token undef
|
||||
}
|
||||
|
||||
define i32 addrspace(1)* @f4(i32 addrspace(1)* %arg) gc "statepoint-example" {
|
||||
; CHECK-LABEL: @f4(
|
||||
entry:
|
||||
; CHECK: @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* @g, i32 0, i32 1, i32 2, i32 400, i8 90,
|
||||
call void @g() [ "gc-transition"(i32 400, i8 90) ]
|
||||
ret i32 addrspace(1)* %arg
|
||||
}
|
@ -1,89 +0,0 @@
|
||||
; This is a collection of really basic tests for gc.statepoint rewriting.
|
||||
; RUN: opt < %s -rewrite-statepoints-for-gc -spp-rematerialization-threshold=0 -S | FileCheck %s
|
||||
; RUN: opt < %s -passes=rewrite-statepoints-for-gc -spp-rematerialization-threshold=0 -S | FileCheck %s
|
||||
|
||||
; Trivial relocation over a single call
|
||||
|
||||
declare void @foo()
|
||||
|
||||
define i8 addrspace(1)* @test1(i8 addrspace(1)* %obj) gc "statepoint-example" {
|
||||
; CHECK-LABEL: @test1
|
||||
entry:
|
||||
; CHECK-LABEL: entry:
|
||||
; CHECK-NEXT: gc.statepoint
|
||||
; CHECK-NEXT: %obj.relocated = call coldcc i8 addrspace(1)*
|
||||
; Two safepoints in a row (i.e. consistent liveness)
|
||||
call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
|
||||
ret i8 addrspace(1)* %obj
|
||||
}
|
||||
|
||||
define i8 addrspace(1)* @test2(i8 addrspace(1)* %obj) gc "statepoint-example" {
|
||||
; CHECK-LABEL: @test2
|
||||
entry:
|
||||
; CHECK-LABEL: entry:
|
||||
; CHECK-NEXT: gc.statepoint
|
||||
; CHECK-NEXT: %obj.relocated = call coldcc i8 addrspace(1)*
|
||||
; CHECK-NEXT: gc.statepoint
|
||||
; CHECK-NEXT: %obj.relocated2 = call coldcc i8 addrspace(1)*
|
||||
; A simple derived pointer
|
||||
call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
|
||||
call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
|
||||
ret i8 addrspace(1)* %obj
|
||||
}
|
||||
|
||||
define i8 @test3(i8 addrspace(1)* %obj) gc "statepoint-example" {
|
||||
entry:
|
||||
; CHECK-LABEL: entry:
|
||||
; CHECK-NEXT: getelementptr
|
||||
; CHECK-NEXT: gc.statepoint
|
||||
; CHECK-NEXT: %obj.relocated = call coldcc i8 addrspace(1)*
|
||||
; CHECK-NEXT: %derived.relocated = call coldcc i8 addrspace(1)*
|
||||
; CHECK-NEXT: load i8, i8 addrspace(1)* %derived.relocated
|
||||
; CHECK-NEXT: load i8, i8 addrspace(1)* %obj.relocated
|
||||
; Tests to make sure we visit both the taken and untaken predeccessor
|
||||
; of merge. This was a bug in the dataflow liveness at one point.
|
||||
%derived = getelementptr i8, i8 addrspace(1)* %obj, i64 10
|
||||
call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
|
||||
%a = load i8, i8 addrspace(1)* %derived
|
||||
%b = load i8, i8 addrspace(1)* %obj
|
||||
%c = sub i8 %a, %b
|
||||
ret i8 %c
|
||||
}
|
||||
|
||||
define i8 addrspace(1)* @test4(i1 %cmp, i8 addrspace(1)* %obj) gc "statepoint-example" {
|
||||
entry:
|
||||
br i1 %cmp, label %taken, label %untaken
|
||||
|
||||
taken: ; preds = %entry
|
||||
; CHECK-LABEL: taken:
|
||||
; CHECK-NEXT: gc.statepoint
|
||||
; CHECK-NEXT: %obj.relocated = call coldcc i8 addrspace(1)*
|
||||
call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
|
||||
br label %merge
|
||||
|
||||
untaken: ; preds = %entry
|
||||
; CHECK-LABEL: untaken:
|
||||
; CHECK-NEXT: gc.statepoint
|
||||
; CHECK-NEXT: %obj.relocated2 = call coldcc i8 addrspace(1)*
|
||||
call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
|
||||
br label %merge
|
||||
|
||||
merge: ; preds = %untaken, %taken
|
||||
; CHECK-LABEL: merge:
|
||||
; CHECK-NEXT: %.0 = phi i8 addrspace(1)* [ %obj.relocated, %taken ], [ %obj.relocated2, %untaken ]
|
||||
; CHECK-NEXT: ret i8 addrspace(1)* %.0
|
||||
; When run over a function which doesn't opt in, should do nothing!
|
||||
ret i8 addrspace(1)* %obj
|
||||
}
|
||||
|
||||
define i8 addrspace(1)* @test5(i8 addrspace(1)* %obj) gc "ocaml" {
|
||||
; CHECK-LABEL: @test5
|
||||
entry:
|
||||
; CHECK-LABEL: entry:
|
||||
; CHECK-NEXT: gc.statepoint
|
||||
; CHECK-NOT: %obj.relocated = call coldcc i8 addrspace(1)*
|
||||
%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 5, i32 0, i32 -1, i32 0, i32 0, i32 0)
|
||||
ret i8 addrspace(1)* %obj
|
||||
}
|
||||
|
||||
declare token @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...)
|
@ -1,39 +0,0 @@
|
||||
;; RUN: opt < %s -rewrite-statepoints-for-gc -S | FileCheck %s
|
||||
;; RUN: opt < %s -passes=rewrite-statepoints-for-gc -S | FileCheck %s
|
||||
|
||||
;; This test is to verify that gc_result from a call statepoint
|
||||
;; can have preceding phis in its parent basic block. Unlike
|
||||
;; invoke statepoint, call statepoint does not terminate the
|
||||
;; block, and thus its gc_result is in the same block with the
|
||||
;; call statepoint.
|
||||
|
||||
declare i32 @foo()
|
||||
|
||||
define i32 @test1(i1 %cond, i32 %a) gc "statepoint-example" {
|
||||
entry:
|
||||
br i1 %cond, label %branch1, label %branch2
|
||||
|
||||
branch1:
|
||||
%b = add i32 %a, 1
|
||||
br label %merge
|
||||
|
||||
branch2:
|
||||
br label %merge
|
||||
|
||||
merge:
|
||||
;; CHECK: %phi = phi i32 [ %a, %branch2 ], [ %b, %branch1 ]
|
||||
;; CHECK-NEXT: [[TOKEN:%[^ ]+]] = call token (i64, i32, i32 ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_i32f(i64 2882400000, i32 0, i32 ()* @foo, i32 0, i32 0, i32 0, i32 0
|
||||
;; CHECK-NEXT: call i32 @llvm.experimental.gc.result.i32(token [[TOKEN]])
|
||||
%phi = phi i32 [ %a, %branch2 ], [ %b, %branch1 ]
|
||||
%ret = call i32 @foo()
|
||||
ret i32 %ret
|
||||
}
|
||||
|
||||
; This function is inlined when inserting a poll.
|
||||
declare void @do_safepoint()
|
||||
define void @gc.safepoint_poll() {
|
||||
; CHECK-LABEL: gc.safepoint_poll
|
||||
entry:
|
||||
call void @do_safepoint()
|
||||
ret void
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
; RUN: opt -S -rewrite-statepoints-for-gc < %s | FileCheck %s
|
||||
|
||||
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128-ni:1"
|
||||
target triple = "x86_64-unknown-linux-gnu"
|
||||
|
||||
declare void @f()
|
||||
declare void @g(i8 addrspace(1)*, i8 addrspace(1)*)
|
||||
declare i32 @personality_function()
|
||||
|
||||
; Make sure that we do not fail assertion because we process call of @g before
|
||||
; we process the call of @f.
|
||||
|
||||
define void @test_01(i8 addrspace(1)* %p, i1 %cond) gc "statepoint-example" personality i32 ()* @personality_function {
|
||||
|
||||
; CHECK-LABEL: @test_01(
|
||||
|
||||
entry:
|
||||
%tmp0 = insertelement <2 x i8 addrspace(1)*> undef, i8 addrspace(1)* %p, i32 0
|
||||
%tmp1 = insertelement <2 x i8 addrspace(1)*> %tmp0, i8 addrspace(1)* %p, i32 1
|
||||
%tmp2 = extractelement <2 x i8 addrspace(1)*> %tmp1, i32 1
|
||||
%tmp3 = extractelement <2 x i8 addrspace(1)*> %tmp1, i32 0
|
||||
br label %loop
|
||||
|
||||
loop:
|
||||
br i1 %cond, label %cond_block, label %exit
|
||||
|
||||
cond_block:
|
||||
br i1 %cond, label %backedge, label %exit
|
||||
|
||||
exit:
|
||||
%tmp4 = phi i8 addrspace(1)* [ %tmp2, %loop ], [ %tmp2, %cond_block ]
|
||||
call void @g(i8 addrspace(1)* %tmp3, i8 addrspace(1)* %tmp4)
|
||||
ret void
|
||||
|
||||
backedge:
|
||||
call void @f()
|
||||
br label %loop
|
||||
}
|
@ -1,82 +0,0 @@
|
||||
; RUN: opt -rewrite-statepoints-for-gc -S < %s | FileCheck %s
|
||||
; RUN: opt -passes=rewrite-statepoints-for-gc -S < %s | FileCheck %s
|
||||
|
||||
; A null test of a single value
|
||||
|
||||
define i1 @test(i8 addrspace(1)* %p, i1 %rare) gc "statepoint-example" {
|
||||
; CHECK-LABEL: @test
|
||||
entry:
|
||||
%cond = icmp eq i8 addrspace(1)* %p, null
|
||||
br i1 %rare, label %safepoint, label %continue, !prof !0
|
||||
|
||||
safepoint: ; preds = %entry
|
||||
call void @safepoint() [ "deopt"() ]
|
||||
br label %continue
|
||||
|
||||
continue: ; preds = %safepoint, %entry
|
||||
; CHECK-LABEL: continue:
|
||||
; CHECK: phi
|
||||
; CHECK-DAG: [ %p.relocated, %safepoint ]
|
||||
; CHECK-DAG: [ %p, %entry ]
|
||||
; CHECK: %cond = icmp
|
||||
; CHECK: br i1 %cond
|
||||
; Comparing two pointers
|
||||
br i1 %cond, label %taken, label %untaken
|
||||
|
||||
taken: ; preds = %continue
|
||||
ret i1 true
|
||||
|
||||
untaken: ; preds = %continue
|
||||
ret i1 false
|
||||
}
|
||||
|
||||
define i1 @test2(i8 addrspace(1)* %p, i8 addrspace(1)* %q, i1 %rare) gc "statepoint-example" {
|
||||
; CHECK-LABEL: @test2
|
||||
entry:
|
||||
%cond = icmp eq i8 addrspace(1)* %p, %q
|
||||
br i1 %rare, label %safepoint, label %continue, !prof !0
|
||||
|
||||
safepoint: ; preds = %entry
|
||||
call void @safepoint() [ "deopt"() ]
|
||||
br label %continue
|
||||
|
||||
continue: ; preds = %safepoint, %entry
|
||||
; CHECK-LABEL: continue:
|
||||
; CHECK: phi
|
||||
; CHECK-DAG: [ %q.relocated, %safepoint ]
|
||||
; CHECK-DAG: [ %q, %entry ]
|
||||
; CHECK: phi
|
||||
; CHECK-DAG: [ %p.relocated, %safepoint ]
|
||||
; CHECK-DAG: [ %p, %entry ]
|
||||
; CHECK: %cond = icmp
|
||||
; CHECK: br i1 %cond
|
||||
; Sanity check that nothing bad happens if already last instruction
|
||||
; before terminator
|
||||
br i1 %cond, label %taken, label %untaken
|
||||
|
||||
taken: ; preds = %continue
|
||||
ret i1 true
|
||||
|
||||
untaken: ; preds = %continue
|
||||
ret i1 false
|
||||
}
|
||||
|
||||
define i1 @test3(i8 addrspace(1)* %p, i8 addrspace(1)* %q, i1 %rare) gc "statepoint-example" {
|
||||
; CHECK-LABEL: @test3
|
||||
; CHECK: gc.statepoint
|
||||
; CHECK: %cond = icmp
|
||||
; CHECK: br i1 %cond
|
||||
entry:
|
||||
call void @safepoint() [ "deopt"() ]
|
||||
%cond = icmp eq i8 addrspace(1)* %p, %q
|
||||
br i1 %cond, label %taken, label %untaken
|
||||
|
||||
taken: ; preds = %entry
|
||||
ret i1 true
|
||||
|
||||
untaken: ; preds = %entry
|
||||
ret i1 false
|
||||
}
|
||||
|
||||
declare void @safepoint()
|
||||
!0 = !{!"branch_weights", i32 1, i32 10000}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user