diff options
Diffstat (limited to 'test/Transforms/RewriteStatepointsForGC')
63 files changed, 1132 insertions, 2644 deletions
diff --git a/test/Transforms/RewriteStatepointsForGC/base-pointers-1.ll b/test/Transforms/RewriteStatepointsForGC/base-pointers-1.ll index 3fd7fd9282f1..54e9f41c99be 100644 --- a/test/Transforms/RewriteStatepointsForGC/base-pointers-1.ll +++ b/test/Transforms/RewriteStatepointsForGC/base-pointers-1.ll @@ -1,4 +1,4 @@ -; RUN: opt %s -rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s +; RUN: opt < %s -rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s ; CHECK: derived %merged_value base %merged_value.base @@ -8,21 +8,18 @@ define i64 addrspace(1)* @test(i64 addrspace(1)* %base_obj_x, i64 addrspace(1)* entry: br i1 %runtime_condition, label %here, label %there -here: +here: ; preds = %entry %x = getelementptr i64, i64 addrspace(1)* %base_obj_x, i32 1 br label %merge -there: +there: ; preds = %entry %y = getelementptr i64, i64 addrspace(1)* %base_obj_y, i32 1 br label %merge -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 ] - %safepoint_token = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @site_for_call_safpeoint, i32 0, i32 0, i32 0, i32 5, i32 0, i32 -1, i32 0, i32 0, i32 0) + call void @site_for_call_safpeoint() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ] ret i64 addrspace(1)* %merged_value } - -declare void @foo() -declare token @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...) diff --git a/test/Transforms/RewriteStatepointsForGC/base-pointers-10.ll b/test/Transforms/RewriteStatepointsForGC/base-pointers-10.ll index 19f1423eea03..04795741ead6 100644 --- a/test/Transforms/RewriteStatepointsForGC/base-pointers-10.ll +++ b/test/Transforms/RewriteStatepointsForGC/base-pointers-10.ll @@ -1,38 +1,35 @@ -; RUN: opt %s -rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s +; RUN: opt < %s -rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s -; 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 -declare i1 @runtime_value() +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: - %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 ] - +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: +true: ; preds = %loop br label %merge -false: +false: ; preds = %loop br label %merge -merge: +merge: ; preds = %false, %true %next = phi i64 addrspace(1)* [ %next_x, %true ], [ %next_y, %false ] - %safepoint_token = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 5, i32 0, i32 -1, i32 0, i32 0, i32 0) + call void @do_safepoint() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ] br label %loop } - -declare token @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...) +; 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 diff --git a/test/Transforms/RewriteStatepointsForGC/base-pointers-11.ll b/test/Transforms/RewriteStatepointsForGC/base-pointers-11.ll index a28c925f7828..5149a2918152 100644 --- a/test/Transforms/RewriteStatepointsForGC/base-pointers-11.ll +++ b/test/Transforms/RewriteStatepointsForGC/base-pointers-11.ll @@ -1,4 +1,4 @@ -; RUN: opt %s -rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s +; RUN: opt < %s -rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s ; CHECK: derived %next base %base_obj @@ -19,8 +19,6 @@ loop: ; preds = %loop, %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 - %safepoint_token = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 5, i32 0, i32 -1, i32 0, i32 0, i32 0) + call void @do_safepoint() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ] br label %loop } - -declare token @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...)
\ No newline at end of file diff --git a/test/Transforms/RewriteStatepointsForGC/base-pointers-12.ll b/test/Transforms/RewriteStatepointsForGC/base-pointers-12.ll index 5ebff642347d..4706ce70df18 100644 --- a/test/Transforms/RewriteStatepointsForGC/base-pointers-12.ll +++ b/test/Transforms/RewriteStatepointsForGC/base-pointers-12.ll @@ -1,6 +1,6 @@ -; RUN: opt %s -rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s +; RUN: opt < %s -rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s -; CHECK: derived %select base @global +; CHECK: derived %select base null @global = external addrspace(1) global i8 @@ -8,7 +8,7 @@ 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 - %safepoint_token = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* @extern, i32 0, i32 0, i32 0, i32 0) + call void @extern() ; CHECK-NOT: relocate ; CHECK: %load = load i8, i8 addrspace(1)* %select %load = load i8, i8 addrspace(1)* %select diff --git a/test/Transforms/RewriteStatepointsForGC/base-pointers-13.ll b/test/Transforms/RewriteStatepointsForGC/base-pointers-13.ll index 8e43e638f989..d01c771349e1 100644 --- a/test/Transforms/RewriteStatepointsForGC/base-pointers-13.ll +++ b/test/Transforms/RewriteStatepointsForGC/base-pointers-13.ll @@ -1,12 +1,12 @@ -; RUN: opt %s -rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s +; RUN: opt < %s -rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s -; CHECK: derived %derived base @global +; 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 - %safepoint_token = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* @extern, i32 0, i32 0, i32 0, i32 0) + call void @extern() ; CHECK-NOT: relocate ; CHECK-NOT: remat ; CHECK: %load = load i8, i8 addrspace(1)* %derived diff --git a/test/Transforms/RewriteStatepointsForGC/base-pointers-2.ll b/test/Transforms/RewriteStatepointsForGC/base-pointers-2.ll index 802ce5d79a33..f7676d272f58 100644 --- a/test/Transforms/RewriteStatepointsForGC/base-pointers-2.ll +++ b/test/Transforms/RewriteStatepointsForGC/base-pointers-2.ll @@ -1,21 +1,19 @@ -; RUN: opt %s -rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s +; RUN: opt < %s -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: +there: ; preds = %entry %derived_obj = getelementptr i64, i64 addrspace(1)* %base_obj, i32 1 br label %merge -merge: +merge: ; preds = %there, %entry %merged_value = phi i64 addrspace(1)* [ %base_obj, %entry ], [ %derived_obj, %there ] - %safepoint_token = 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) + call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ] ret i64 addrspace(1)* %merged_value } declare void @foo() -declare token @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...)
\ No newline at end of file diff --git a/test/Transforms/RewriteStatepointsForGC/base-pointers-3.ll b/test/Transforms/RewriteStatepointsForGC/base-pointers-3.ll index e0035d353887..6f54f8929869 100644 --- a/test/Transforms/RewriteStatepointsForGC/base-pointers-3.ll +++ b/test/Transforms/RewriteStatepointsForGC/base-pointers-3.ll @@ -1,4 +1,4 @@ -; RUN: opt %s -rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s +; RUN: opt < %s -rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s ; CHECK: derived %next.i64 base %base_obj @@ -7,14 +7,13 @@ entry: %obj = getelementptr i64, i64 addrspace(1)* %base_obj, i32 1 br label %loop -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)* - %safepoint_token = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 5, i32 0, i32 -1, i32 0, i32 0, i32 0) + call void @do_safepoint() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ] br label %loop } declare void @do_safepoint() -declare token @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...)
\ No newline at end of file diff --git a/test/Transforms/RewriteStatepointsForGC/base-pointers-4.ll b/test/Transforms/RewriteStatepointsForGC/base-pointers-4.ll index 4e0bb14cb453..5694cfd5ecb0 100644 --- a/test/Transforms/RewriteStatepointsForGC/base-pointers-4.ll +++ b/test/Transforms/RewriteStatepointsForGC/base-pointers-4.ll @@ -1,52 +1,44 @@ -; RUN: opt %s -rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s +; RUN: opt < %s -rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s - -; CHECK: derived %obj_to_consume base %obj_to_consume +; 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: +loop: ; preds = %merge.split, %entry ; CHECK: loop: -; CHECK: %safepoint_token1 = call token (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 -; CHECK-NEXT: %obj2 = call i64 addrspace(1)* @llvm.experimental.gc.result - %safepoint_token1 = call token (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) - %obj2 = call i64 addrspace(1)* @llvm.experimental.gc.result.p1i64(token %safepoint_token1) +; 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: +dest_a: ; preds = %loop br label %merge -dest_b: +dest_b: ; preds = %loop br label %merge -dest_c: +dest_c: ; preds = %loop br label %merge -merge: +merge: ; preds = %dest_c, %dest_b, %dest_a ; CHECK: merge: -; CHECK: %obj_to_consume = phi i64 addrspace(1)* [ %obj2, %dest_a ], [ null, %dest_b ], [ null, %dest_c ] - - %obj_to_consume = phi i64 addrspace(1)* [ %obj2, %dest_a ], [ null, %dest_b ], [ null, %dest_c ] - %safepoint_token3 = call token (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) +; 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 - %safepoint_token = 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) + call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ] br label %loop } - - -; Function Attrs: nounwind -declare i64 addrspace(1)* @llvm.experimental.gc.result.p1i64(token) #0 -declare token @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...) -declare token @llvm.experimental.gc.statepoint.p0f_p1i64f(i64, i32, i64 addrspace(1)* ()*, i32, i32, ...) -declare token @llvm.experimental.gc.statepoint.p0f_isVoidp1i64f(i64, i32, void (i64 addrspace(1)*)*, i32, i32, ...) diff --git a/test/Transforms/RewriteStatepointsForGC/base-pointers-5.ll b/test/Transforms/RewriteStatepointsForGC/base-pointers-5.ll index c5acd2962f9e..c1e3a368de00 100644 --- a/test/Transforms/RewriteStatepointsForGC/base-pointers-5.ll +++ b/test/Transforms/RewriteStatepointsForGC/base-pointers-5.ll @@ -1,4 +1,4 @@ -; RUN: opt %s -rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s +; RUN: opt < %s -rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s ; CHECK: derived %merged_value base %merged_value.base @@ -8,23 +8,21 @@ define i64 addrspace(1)* @test(i64 addrspace(1)* %base_obj_x, i64 addrspace(1)* entry: br i1 %runtime_condition, label %here, label %there -here: +here: ; preds = %entry br label %bump -bump: +bump: ; preds = %here br label %merge -there: +there: ; preds = %entry %y = getelementptr i64, i64 addrspace(1)* %base_obj_y, i32 1 br label %merge -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 ] - %safepoint_token = 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) + call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ] ret i64 addrspace(1)* %merged_value } - -declare token @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...) diff --git a/test/Transforms/RewriteStatepointsForGC/base-pointers-6.ll b/test/Transforms/RewriteStatepointsForGC/base-pointers-6.ll index 95a42846a2fe..5db6d7ad6aed 100644 --- a/test/Transforms/RewriteStatepointsForGC/base-pointers-6.ll +++ b/test/Transforms/RewriteStatepointsForGC/base-pointers-6.ll @@ -1,4 +1,4 @@ -; RUN: opt %s -rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s +; RUN: opt < %s -rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s ; CHECK: derived %merged_value base %merged_value.base @@ -8,34 +8,30 @@ define i64 addrspace(1)* @test(i64 addrspace(1)* %base_obj_x, i64 addrspace(1)* entry: br i1 %runtime_condition_x, label %here, label %there -here: - br i1 %runtime_condition_y, label %bump_here_a, label %bump_here_b +here: ; preds = %entry + br i1 %runtime_condition_y, label %bump_here_a, label %bump_here_b -bump_here_a: +bump_here_a: ; preds = %here %x_a = getelementptr i64, i64 addrspace(1)* %base_obj_x, i32 1 br label %merge_here -bump_here_b: +bump_here_b: ; preds = %here %x_b = getelementptr i64, i64 addrspace(1)* %base_obj_x, i32 2 br label %merge_here - -merge_here: - %x = phi i64 addrspace(1)* [ %x_a , %bump_here_a ], [ %x_b , %bump_here_b ] +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: +there: ; preds = %entry %y = getelementptr i64, i64 addrspace(1)* %base_obj_y, i32 1 br label %merge -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 ] - %safepoint_token = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @site_for_call_safpeoint, i32 0, i32 0, i32 0, i32 5, i32 0, i32 -1, i32 0, i32 0, i32 0) + call void @site_for_call_safpeoint() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ] ret i64 addrspace(1)* %merged_value } - -declare void @do_safepoint() -declare token @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...) diff --git a/test/Transforms/RewriteStatepointsForGC/base-pointers-7.ll b/test/Transforms/RewriteStatepointsForGC/base-pointers-7.ll index 49cf20eab191..930a8380df80 100644 --- a/test/Transforms/RewriteStatepointsForGC/base-pointers-7.ll +++ b/test/Transforms/RewriteStatepointsForGC/base-pointers-7.ll @@ -1,41 +1,38 @@ -; RUN: opt %s -rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s +; RUN: opt < %s -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" { +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: - br i1 %runtime_condition_y, label %bump_here_a, label %bump_here_b +here: ; preds = %entry + br i1 %runtime_condition_y, label %bump_here_a, label %bump_here_b -bump_here_a: +bump_here_a: ; preds = %here %x_a = getelementptr i64, i64 addrspace(1)* %base_obj_x, i32 1 br label %merge_here -bump_here_b: +bump_here_b: ; preds = %here %x_b = getelementptr i64, i64 addrspace(1)* %base_obj_y, i32 2 br label %merge_here - -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 ] + %x = phi i64 addrspace(1)* [ %x_a, %bump_here_a ], [ %x_b, %bump_here_b ] br label %merge -there: +there: ; preds = %entry %y = getelementptr i64, i64 addrspace(1)* %base_obj_y, i32 1 br label %merge -merge: +merge: ; preds = %there, %merge_here ; CHECK: merge: ; CHECK-DAG: %merged_value.base ; CHECK-DAG: phi i64 addrspace(1)* @@ -43,10 +40,6 @@ merge: ; 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 ] - - %safepoint_token = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @site_for_call_safpeoint, i32 0, i32 0, i32 0, i32 5, i32 0, i32 -1, i32 0, i32 0, i32 0) + call void @site_for_call_safpeoint() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ] ret i64 addrspace(1)* %merged_value } - -declare void @do_safepoint() -declare token @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...) diff --git a/test/Transforms/RewriteStatepointsForGC/base-pointers-8.ll b/test/Transforms/RewriteStatepointsForGC/base-pointers-8.ll index e5ef42dda24b..2f7fcd9974be 100644 --- a/test/Transforms/RewriteStatepointsForGC/base-pointers-8.ll +++ b/test/Transforms/RewriteStatepointsForGC/base-pointers-8.ll @@ -1,4 +1,4 @@ -; RUN: opt %s -rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s +; RUN: opt < %s -rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s ; CHECK: derived %next_element_ptr base %array_obj @@ -10,29 +10,28 @@ entry: %array_elems = bitcast i32 addrspace(1)* %array_len_pointer.i32 to i64 addrspace(1)* addrspace(1)* br label %loop_check -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: +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: +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 - %safepoint_token = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 5, i32 0, i32 -1, i32 0, i32 0, i32 0) + call void @do_safepoint() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ] br label %loop_check -not_found: +not_found: ; preds = %loop_check ret i32 -1 -found: +found: ; preds = %check_for_null ret i32 %index } declare void @do_safepoint() -declare token @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...)
\ No newline at end of file diff --git a/test/Transforms/RewriteStatepointsForGC/base-pointers-9.ll b/test/Transforms/RewriteStatepointsForGC/base-pointers-9.ll index 946d89a08e27..bf49f69515cf 100644 --- a/test/Transforms/RewriteStatepointsForGC/base-pointers-9.ll +++ b/test/Transforms/RewriteStatepointsForGC/base-pointers-9.ll @@ -1,21 +1,20 @@ -; RUN: opt %s -rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s +; RUN: opt < %s -rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s ; CHECK: derived %next base %base_obj -declare i1 @runtime_value() +declare i1 @runtime_value() "gc-leaf-function" define void @maybe_GEP(i64 addrspace(1)* %base_obj) gc "statepoint-example" { entry: br label %loop -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 - %safepoint_token = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 5, i32 0, i32 -1, i32 0, i32 0, i32 0) + call void @do_safepoint() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ] br label %loop } declare void @do_safepoint() -declare token @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...)
\ No newline at end of file diff --git a/test/Transforms/RewriteStatepointsForGC/base-pointers.ll b/test/Transforms/RewriteStatepointsForGC/base-pointers.ll index cd0473a67678..e65897e7a899 100644 --- a/test/Transforms/RewriteStatepointsForGC/base-pointers.ll +++ b/test/Transforms/RewriteStatepointsForGC/base-pointers.ll @@ -1,22 +1,24 @@ -; RUN: opt %s -rewrite-statepoints-for-gc -S 2>&1 | FileCheck %s - -declare i64 addrspace(1)* @generate_obj() -declare void @use_obj(i64 addrspace(1)*) +; RUN: opt < %s -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: -; CHECK: phi i64 addrspace(1)* -; CHECK-DAG: [ %obj.relocated.casted, %loop ] -; CHECK-DAG: [ %obj, %entry ] +loop: ; preds = %loop, %entry call void @use_obj(i64 addrspace(1)* %obj) - %safepoint_token = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 5, i32 0, i32 -1, i32 0, i32 0, i32 0) + call void @do_safepoint() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ] br label %loop } @@ -26,39 +28,39 @@ 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: +entry: br i1 undef, label %left, label %right - left: - %a.cast = bitcast i8 addrspace(1)* %a to i64 addrspace(1)* +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. - switch i32 %unknown, label %right [ i32 0, label %merge - i32 1, label %merge - i32 5, label %merge - i32 3, label %right ] - - right: - %b.cast = bitcast i8 addrspace(1)* %b to i64 addrspace(1)* - br label %merge + %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: +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] - %safepoint_token = call token (i64, i32, void (i64 addrspace(1)*)*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidp1i64f(i64 0, i32 0, void (i64 addrspace(1)*)* @parse_point, i32 1, i32 0, i64 addrspace(1)* %value, i32 0, i32 5, i32 0, i32 0, i32 0, i32 0, i32 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 } @@ -66,86 +68,87 @@ define i64 addrspace(1)* @test1(i32 %caller, i8 addrspace(1)* %a, i8 addrspace(1 ;; 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" { +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 - -loop: ; preds = %loop, %entry ; 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 - %safepoint_token = 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) + 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" { +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: + +taken: ; preds = %entry br label %merge -merge: + +merge: ; preds = %taken, %entry ; CHECK-LABEL: merge: -; CHECK-NEXT: %bdv = phi +; CHECK-NEXT: phi +; CHECK-NEXT: phi ; CHECK-NEXT: gc.statepoint %bdv = phi i64 addrspace(1)* [ %obj, %entry ], [ %obj2, %taken ] - %safepoint_token = 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) + 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" { +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: + +taken: ; preds = %entry br label %merge -merge: + +merge: ; preds = %taken, %entry ; CHECK-LABEL: merge: -; CHECK-NEXT: %bdv = phi +; CHECK-NEXT: phi ; CHECK-NEXT: gc.statepoint %bdv = phi i64 addrspace(1)* [ %obj, %entry ], [ %obj, %taken ] - %safepoint_token = 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) + 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" { +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: + +merge: ; preds = %merge, %entry ; CHECK-LABEL: merge: -; CHECK-NEXT: %bdv = phi +; 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: - %safepoint_token = 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) + +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() -declare token @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...) -declare token @llvm.experimental.gc.statepoint.p0f_isVoidp1i64f(i64, i32, void (i64 addrspace(1)*)*, i32, i32, ...) diff --git a/test/Transforms/RewriteStatepointsForGC/base-vector.ll b/test/Transforms/RewriteStatepointsForGC/base-vector.ll index 6084efeb0509..39a78d725977 100644 --- a/test/Transforms/RewriteStatepointsForGC/base-vector.ll +++ b/test/Transforms/RewriteStatepointsForGC/base-vector.ll @@ -1,4 +1,5 @@ -; RUN: opt %s -rewrite-statepoints-for-gc -S | FileCheck %s +; RUN: opt < %s -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 @@ -6,130 +7,131 @@ define i64 addrspace(1)* @test(<2 x i64 addrspace(1)*> %vec, i32 %idx) gc "state ; CHECK: extractelement ; CHECK: statepoint ; CHECK: gc.relocate -; CHECK-DAG: ; (%base_ee, %base_ee) -; 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 - %safepoint_token = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0) - + 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" { +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: + +taken: ; preds = %entry %obja = load <2 x i64 addrspace(1)*>, <2 x i64 addrspace(1)*>* %ptr br label %merge -untaken: + +untaken: ; preds = %entry %objb = load <2 x i64 addrspace(1)*>, <2 x i64 addrspace(1)*>* %ptr br label %merge -merge: - %vec = phi <2 x i64 addrspace(1)*> [%obja, %taken], [%objb, %untaken] + +merge: ; preds = %untaken, %taken + %vec = phi <2 x i64 addrspace(1)*> [ %obja, %taken ], [ %objb, %untaken ] br i1 %cnd, label %taken2, label %untaken2 -taken2: + +taken2: ; preds = %merge %obj0 = extractelement <2 x i64 addrspace(1)*> %vec, i32 %idx1 br label %merge2 -untaken2: + +untaken2: ; preds = %merge %obj1 = extractelement <2 x i64 addrspace(1)*> %vec, i32 %idx2 br label %merge2 -merge2: + +merge2: ; preds = %untaken2, %taken2 ; CHECK-LABEL: merge2: -; CHECK-NEXT: %obj = phi i64 addrspace(1)* -; CHECK-NEXT: statepoint +; 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, %obj) - %obj = phi i64 addrspace(1)* [%obj0, %taken2], [%obj1, %untaken2] - %safepoint_token = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0) +; 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" { +define i64 addrspace(1)* @test3(i64 addrspace(1)* %ptr) gc "statepoint-example" { ; CHECK-LABEL: test3 -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 ; CHECK: insertelement ; CHECK: extractelement ; CHECK: statepoint ; CHECK: gc.relocate -; CHECK-DAG: (%obj, %obj) - %safepoint_token = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0) +; 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" { + +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 -; CHECK: statepoint -; CHECK: gc.relocate -; CHECK-DAG: ; (%ptr, %obj) -; CHECK: gc.relocate -; CHECK-DAG: ; (%ptr, %ptr) - %safepoint_token = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0) + call void @do_safepoint() [ "deopt"() ] ret i64 addrspace(1)* %obj } -declare void @use(i64 addrspace(1)*) +declare void @use(i64 addrspace(1)*) "gc-leaf-function" -; When we can optimize an extractelement from a known -; index and avoid introducing new base pointer instructions -define void @test5(i1 %cnd, i64 addrspace(1)* %obj) - gc "statepoint-example" { +define void @test5(i1 %cnd, i64 addrspace(1)* %obj) gc "statepoint-example" { ; CHECK-LABEL: @test5 ; CHECK: gc.relocate -; CHECK-DAG: (%obj, %bdv) +; 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 - %safepoint_token = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 5, i32 0, i32 -1, i32 0, i32 0, 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 } -; When we fundementally have to duplicate -define void @test6(i1 %cnd, i64 addrspace(1)* %obj, i64 %idx) - gc "statepoint-example" { +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)*> undef, i64 addrspace(1)* %obj, i32 0, !is_base_value !0 +; 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 - %safepoint_token = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 5, i32 0, i32 -1, i32 0, i32 0, 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 } -; 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. -define i64 addrspace(1)* @test7(i1 %cnd, i64 addrspace(1)* %obj, - i64 addrspace(1)* %obj2) - gc "statepoint-example" { +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: + +merge1: ; preds = %merge1, %entry ; CHECK-LABEL: merge1: ; CHECK: vec2.base ; CHECK: vec2 @@ -140,28 +142,27 @@ 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: + +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: + +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: - %safepoint_token = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 5, i32 0, i32 -1, i32 0, i32 0, i32 0) + +next: ; preds = %merge + call void @do_safepoint() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ] ret i64 addrspace(1)* %objb } - declare void @do_safepoint() - -declare token @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...) diff --git a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/basic.ll b/test/Transforms/RewriteStatepointsForGC/basic.ll index c0dc6940e5db..bb2210c7849a 100644 --- a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/basic.ll +++ b/test/Transforms/RewriteStatepointsForGC/basic.ll @@ -1,4 +1,4 @@ -; RUN: opt -S -rewrite-statepoints-for-gc -rs4gc-use-deopt-bundles < %s | FileCheck %s +; RUN: opt -S -rewrite-statepoints-for-gc < %s | FileCheck %s declare void @g() declare i32 @h() @@ -63,3 +63,11 @@ define i32 addrspace(1)* @f3(i32 addrspace(1)* %arg) gc "statepoint-example" pe %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 +} diff --git a/test/Transforms/RewriteStatepointsForGC/basics.ll b/test/Transforms/RewriteStatepointsForGC/basics.ll index 48f464356865..967a804f7a18 100644 --- a/test/Transforms/RewriteStatepointsForGC/basics.ll +++ b/test/Transforms/RewriteStatepointsForGC/basics.ll @@ -1,88 +1,88 @@ ; 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 -rewrite-statepoints-for-gc -spp-rematerialization-threshold=0 -S | FileCheck %s + +; Trivial relocation over a single call declare void @foo() -; Trivial relocation over a single call 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)* -entry: - 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) +; 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 } -; Two safepoints in a row (i.e. consistent liveness) 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.relocated1 = call coldcc i8 addrspace(1)* -entry: - 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) - 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) +; 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 } -; A simple derived pointer define i8 @test3(i8 addrspace(1)* %obj) gc "statepoint-example" { +entry: ; CHECK-LABEL: entry: ; CHECK-NEXT: getelementptr ; CHECK-NEXT: gc.statepoint -; CHECK-NEXT: %derived.relocated = call coldcc i8 addrspace(1)* ; 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 -entry: +; 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 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) - + 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 } -; 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. define i8 addrspace(1)* @test4(i1 %cmp, i8 addrspace(1)* %obj) gc "statepoint-example" { entry: br i1 %cmp, label %taken, label %untaken -taken: +taken: ; preds = %entry ; CHECK-LABEL: taken: ; CHECK-NEXT: gc.statepoint ; CHECK-NEXT: %obj.relocated = call coldcc i8 addrspace(1)* - 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) + call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ] br label %merge -untaken: +untaken: ; preds = %entry ; CHECK-LABEL: untaken: ; CHECK-NEXT: gc.statepoint -; CHECK-NEXT: %obj.relocated1 = call coldcc i8 addrspace(1)* - 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) +; 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: +merge: ; preds = %untaken, %taken ; CHECK-LABEL: merge: -; CHECK-NEXT: %.0 = phi i8 addrspace(1)* [ %obj.relocated, %taken ], [ %obj.relocated1, %untaken ] +; 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 } -; When run over a function which doesn't opt in, should do nothing! 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)* -entry: - 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) + %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, ...)
\ No newline at end of file +declare token @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...) diff --git a/test/Transforms/RewriteStatepointsForGC/call-gc-result.ll b/test/Transforms/RewriteStatepointsForGC/call-gc-result.ll new file mode 100644 index 000000000000..6fcd9b5644ad --- /dev/null +++ b/test/Transforms/RewriteStatepointsForGC/call-gc-result.ll @@ -0,0 +1,38 @@ +;; RUN: opt < %s -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 +} diff --git a/test/Transforms/RewriteStatepointsForGC/codegen-cond.ll b/test/Transforms/RewriteStatepointsForGC/codegen-cond.ll index 8221cd0e0f82..9e8cbaf0260d 100644 --- a/test/Transforms/RewriteStatepointsForGC/codegen-cond.ll +++ b/test/Transforms/RewriteStatepointsForGC/codegen-cond.ll @@ -1,39 +1,45 @@ ; RUN: opt -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: - call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* @safepoint, i32 0, i32 0, i32 0, i32 0) - br label %continue -continue: + %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 - br i1 %cond, label %taken, label %untaken -taken: - ret i1 true -untaken: - ret i1 false +; Comparing two pointers + br i1 %cond, label %taken, label %untaken + +taken: ; preds = %continue + ret i1 true + +untaken: ; preds = %continue + ret i1 false } -; Comparing two pointers -define i1 @test2(i8 addrspace(1)* %p, i8 addrspace(1)* %q, i1 %rare) - gc "statepoint-example" { +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: - call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* @safepoint, i32 0, i32 0, i32 0, i32 0) - br label %continue -continue: +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 ] @@ -43,32 +49,33 @@ continue: ; CHECK-DAG: [ %p, %entry ] ; CHECK: %cond = icmp ; CHECK: br i1 %cond - br i1 %cond, label %taken, label %untaken -taken: - ret i1 true -untaken: - ret i1 false -} - ; Sanity check that nothing bad happens if already last instruction ; before terminator -define i1 @test3(i8 addrspace(1)* %p, i8 addrspace(1)* %q, i1 %rare) - gc "statepoint-example" { + 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 -entry: - call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* @safepoint, i32 0, i32 0, i32 0, i32 0) ; CHECK: gc.statepoint ; CHECK: %cond = icmp ; CHECK: br i1 %cond - %cond = icmp eq i8 addrspace(1)* %p, %q - br i1 %cond, label %taken, label %untaken -taken: - ret i1 true -untaken: - ret i1 false +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() -declare token @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...) - !0 = !{!"branch_weights", i32 1, i32 10000} diff --git a/test/Transforms/RewriteStatepointsForGC/constants.ll b/test/Transforms/RewriteStatepointsForGC/constants.ll index 0f600f215718..0a16f38f1369 100644 --- a/test/Transforms/RewriteStatepointsForGC/constants.ll +++ b/test/Transforms/RewriteStatepointsForGC/constants.ll @@ -1,58 +1,51 @@ -; RUN: opt -S -rewrite-statepoints-for-gc %s | FileCheck %s +; RUN: opt -S -rewrite-statepoints-for-gc < %s | FileCheck %s + +; constants don't get relocated. +@G = addrspace(1) global i8 5 declare void @foo() -declare token @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...) -; constants don't get relocated. define i8 @test() gc "statepoint-example" { ; CHECK-LABEL: @test ; CHECK: gc.statepoint ; CHECK-NEXT: load i8, i8 addrspace(1)* inttoptr (i64 15 to i8 addrspace(1)*) +; Mostly just here to show reasonable code test can come from. entry: - 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 0) + call void @foo() [ "deopt"() ] %res = load i8, i8 addrspace(1)* inttoptr (i64 15 to i8 addrspace(1)*) ret i8 %res } - -; Mostly just here to show reasonable code test can come from. define i8 @test2(i8 addrspace(1)* %p) gc "statepoint-example" { ; CHECK-LABEL: @test2 ; CHECK: gc.statepoint ; CHECK-NEXT: gc.relocate ; CHECK-NEXT: icmp +; Globals don't move and thus don't get relocated entry: - 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 0) + call void @foo() [ "deopt"() ] %cmp = icmp eq i8 addrspace(1)* %p, null br i1 %cmp, label %taken, label %not_taken -taken: +taken: ; preds = %not_taken, %entry ret i8 0 -not_taken: +not_taken: ; preds = %entry %cmp2 = icmp ne i8 addrspace(1)* %p, null br i1 %cmp2, label %taken, label %dead -dead: - ; We see that dead can't be reached, but the optimizer might not. It's - ; completely legal for it to exploit the fact that if dead executed, %p - ; would have to equal null. This can produce intermediate states which - ; look like that of test above, even if arbitrary constant addresses aren't - ; legal in the source language +dead: ; preds = %not_taken %addr = getelementptr i8, i8 addrspace(1)* %p, i32 15 - %res = load i8, i8addrspace(1)* %addr + %res = load i8, i8 addrspace(1)* %addr ret i8 %res } -@G = addrspace(1) global i8 5 - -; Globals don't move and thus don't get relocated define i8 @test3(i1 %always_true) gc "statepoint-example" { ; CHECK-LABEL: @test3 ; CHECK: gc.statepoint ; CHECK-NEXT: load i8, i8 addrspace(1)* @G entry: - 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 0) + call void @foo() [ "deopt"() ] %res = load i8, i8 addrspace(1)* @G, align 1 ret i8 %res } @@ -67,7 +60,7 @@ entry: br i1 %is_null, label %split, label %join split: - 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 0) + 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 @@ -87,7 +80,7 @@ use: ; CHECK-LABEL: use: ; CHECK: gc.statepoint ; CHECK: gc.relocate - 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 0) + call void @foo() %res = load i8 addrspace(1)*, i8 addrspace(1)* addrspace(1)* %addr2, align 1 ret i8 addrspace(1)* %res } @@ -98,7 +91,173 @@ define i8 addrspace(1)* @test5(i1 %always_true) gc "statepoint-example" { ; CHECK: gc.statepoint ; CHECK-NEXT: %res = extractelement <2 x i8 addrspace(1)*> <i8 addrspace(1)* @G, i8 addrspace(1)* @G>, i32 0 entry: - 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 0) + 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 } + +define i8 addrspace(1)* @test6(i64 %arg) gc "statepoint-example" { +entry: + ; Don't fail any assertions and don't record null as a live value + ; CHECK-LABEL: test6 + ; CHECK: gc.statepoint + ; CHECK-NOT: call {{.*}}gc.relocate + %load_addr = getelementptr i8, i8 addrspace(1)* null, i64 %arg + call void @foo() [ "deopt"() ] + ret i8 addrspace(1)* %load_addr +} + +define i8 addrspace(1)* @test7(i64 %arg) gc "statepoint-example" { +entry: + ; Same as test7 but use regular constant instead of a null + ; CHECK-LABEL: test7 + ; CHECK: gc.statepoint + ; CHECK-NOT: call {{.*}}gc.relocate + %load_addr = getelementptr i8, i8 addrspace(1)* inttoptr (i64 15 to i8 addrspace(1)*), i64 %arg + call void @foo() [ "deopt"() ] + ret i8 addrspace(1)* %load_addr +} + +define i8 @test8(i8 addrspace(1)* %p) gc "statepoint-example" { +; Checks that base( phi(gep null, oop) ) = phi(null, base(oop)) and that we +; correctly relocate this value +; CHECK-LABEL: @test8 +entry: + %is_null = icmp eq i8 addrspace(1)* %p, null + br i1 %is_null, label %null.crit-edge, label %not-null + +not-null: + %load_addr = getelementptr inbounds i8, i8 addrspace(1)* %p, i64 8 + br label %join + +null.crit-edge: + %load_addr.const = getelementptr inbounds i8, i8 addrspace(1)* null, i64 8 + br label %join + +join: + %addr = phi i8 addrspace(1)* [ %load_addr, %not-null ], [%load_addr.const, %null.crit-edge] + ; CHECK: %addr.base = phi i8 addrspace(1)* + ; CHECK-DAG: [ %p, %not-null ] + ; CHECK-DAG: [ null, %null.crit-edge ] + ; CHECK: gc.statepoint + call void @foo() [ "deopt"() ] + ; CHECK-DAG: call {{.*}}gc.relocate{{.*}}(%addr.base, %addr.base) + ; CHECK-DAG: call {{.*}}gc.relocate{{.*}}(%addr.base, %addr) + br i1 %is_null, label %early-exit, label %use + +early-exit: + ret i8 0 + +use: + %res = load i8, i8 addrspace(1)* %addr, align 1 + ret i8 %res +} + +define i8 @test9(i8 addrspace(1)* %p) gc "statepoint-example" { +; Checks that base( phi(inttoptr, oop) ) = phi(null, base(oop)) and that we +; correctly relocate this value +; CHECK-LABEL: @test9 +entry: + %is_null = icmp eq i8 addrspace(1)* %p, null + br i1 %is_null, label %null.crit-edge, label %not-null + +not-null: + %load_addr = getelementptr inbounds i8, i8 addrspace(1)* %p, i64 8 + br label %join + +null.crit-edge: + br label %join + +join: + %addr = phi i8 addrspace(1)* [ %load_addr, %not-null ], [inttoptr (i64 8 to i8 addrspace(1)*), %null.crit-edge] + ; CHECK: %addr.base = phi i8 addrspace(1)* + ; CHECK-DAG: [ %p, %not-null ] + ; CHECK-DAG: [ null, %null.crit-edge ] + ; CHECK: gc.statepoint + call void @foo() [ "deopt"() ] + ; CHECK-DAG: call {{.*}}gc.relocate{{.*}}(%addr.base, %addr.base) + ; CHECK-DAG: call {{.*}}gc.relocate{{.*}}(%addr.base, %addr) + br i1 %is_null, label %early-exit, label %use + +early-exit: + ret i8 0 + +use: + %res = load i8, i8 addrspace(1)* %addr, align 1 + ret i8 %res +} + +define i8 @test10(i8 addrspace(1)* %p) gc "statepoint-example" { +; Checks that base( phi(const gep, oop) ) = phi(null, base(oop)) and that we +; correctly relocate this value +; CHECK-LABEL: @test10 +entry: + %is_null = icmp eq i8 addrspace(1)* %p, null + br i1 %is_null, label %null.crit-edge, label %not-null + +not-null: + %load_addr = getelementptr inbounds i8, i8 addrspace(1)* %p, i64 8 + br label %join + +null.crit-edge: + br label %join + +join: + %addr = phi i8 addrspace(1)* [ %load_addr, %not-null ], [getelementptr (i8, i8 addrspace(1)* null, i64 8), %null.crit-edge] + ; CHECK: %addr.base = phi i8 addrspace(1)* + ; CHECK-DAG: [ %p, %not-null ] + ; CHECK-DAG: [ null, %null.crit-edge ] + ; CHECK: gc.statepoint + call void @foo() [ "deopt"() ] + ; CHECK-DAG: call {{.*}}gc.relocate{{.*}}(%addr.base, %addr.base) + ; CHECK-DAG: call {{.*}}gc.relocate{{.*}}(%addr.base, %addr) + br i1 %is_null, label %early-exit, label %use + +early-exit: + ret i8 0 + +use: + %res = load i8, i8 addrspace(1)* %addr, align 1 + ret i8 %res +} + +define i32 addrspace(1)* @test11(i1 %c) gc "statepoint-example" { +; CHECK-LABEL: @test11 +; Checks that base( select(const1, const2) ) == null and that we don't record +; such value in the oop map +entry: + %val = select i1 %c, i32 addrspace(1)* inttoptr (i64 8 to i32 addrspace(1)*), i32 addrspace(1)* inttoptr (i64 15 to i32 addrspace(1)*) + ; CHECK: gc.statepoint + ; CHECK-NOT: call {{.*}}gc.relocate + call void @foo() [ "deopt"() ] + ret i32 addrspace(1)* %val +} + + +define <2 x i32 addrspace(1)*> @test12(i1 %c) gc "statepoint-example" { +; CHECK-LABEL: @test12 +; Same as test11 but with vectors +entry: + %val = select i1 %c, <2 x i32 addrspace(1)*> <i32 addrspace(1)* inttoptr (i64 5 to i32 addrspace(1)*), + i32 addrspace(1)* inttoptr (i64 15 to i32 addrspace(1)*)>, + <2 x i32 addrspace(1)*> <i32 addrspace(1)* inttoptr (i64 30 to i32 addrspace(1)*), + i32 addrspace(1)* inttoptr (i64 60 to i32 addrspace(1)*)> + ; CHECK: gc.statepoint + ; CHECK-NOT: call {{.*}}gc.relocate + call void @foo() [ "deopt"() ] + ret <2 x i32 addrspace(1)*> %val +} + +define <2 x i32 addrspace(1)*> @test13(i1 %c, <2 x i32 addrspace(1)*> %ptr) gc "statepoint-example" { +; CHECK-LABEL: @test13 +; Similar to test8, test9 and test10 but with vectors +entry: + %val = select i1 %c, <2 x i32 addrspace(1)*> %ptr, + <2 x i32 addrspace(1)*> <i32 addrspace(1)* inttoptr (i64 30 to i32 addrspace(1)*), i32 addrspace(1)* inttoptr (i64 60 to i32 addrspace(1)*)> + ; CHECK: %val.base = select i1 %c, <2 x i32 addrspace(1)*> %ptr, <2 x i32 addrspace(1)*> zeroinitializer, !is_base_value !0 + ; CHECK: gc.statepoint + call void @foo() [ "deopt"() ] + ; CHECK-DAG: call {{.*}}gc.relocate{{.*}}(%val.base, %val.base) + ; CHECK-DAG: call {{.*}}gc.relocate{{.*}}(%val.base, %val) + ret <2 x i32 addrspace(1)*> %val +} diff --git a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/base-pointers-1.ll b/test/Transforms/RewriteStatepointsForGC/deopt-bundles/base-pointers-1.ll deleted file mode 100644 index 6af2a3012b5c..000000000000 --- a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/base-pointers-1.ll +++ /dev/null @@ -1,25 +0,0 @@ -; RUN: opt %s -rewrite-statepoints-for-gc -rs4gc-use-deopt-bundles -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 -} diff --git a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/base-pointers-10.ll b/test/Transforms/RewriteStatepointsForGC/deopt-bundles/base-pointers-10.ll deleted file mode 100644 index 8c486d6b3896..000000000000 --- a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/base-pointers-10.ll +++ /dev/null @@ -1,35 +0,0 @@ -; RUN: opt %s -rewrite-statepoints-for-gc -rs4gc-use-deopt-bundles -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 diff --git a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/base-pointers-11.ll b/test/Transforms/RewriteStatepointsForGC/deopt-bundles/base-pointers-11.ll deleted file mode 100644 index ae793b2cb630..000000000000 --- a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/base-pointers-11.ll +++ /dev/null @@ -1,24 +0,0 @@ -; RUN: opt %s -rewrite-statepoints-for-gc -rs4gc-use-deopt-bundles -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 -} diff --git a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/base-pointers-2.ll b/test/Transforms/RewriteStatepointsForGC/deopt-bundles/base-pointers-2.ll deleted file mode 100644 index 2b9485388f80..000000000000 --- a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/base-pointers-2.ll +++ /dev/null @@ -1,19 +0,0 @@ -; RUN: opt %s -rewrite-statepoints-for-gc -rs4gc-use-deopt-bundles -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() diff --git a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/base-pointers-3.ll b/test/Transforms/RewriteStatepointsForGC/deopt-bundles/base-pointers-3.ll deleted file mode 100644 index 71bb309d1301..000000000000 --- a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/base-pointers-3.ll +++ /dev/null @@ -1,19 +0,0 @@ -; RUN: opt %s -rewrite-statepoints-for-gc -rs4gc-use-deopt-bundles -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() diff --git a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/base-pointers-4.ll b/test/Transforms/RewriteStatepointsForGC/deopt-bundles/base-pointers-4.ll deleted file mode 100644 index 3fcbf26a6fc0..000000000000 --- a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/base-pointers-4.ll +++ /dev/null @@ -1,44 +0,0 @@ -; RUN: opt %s -rewrite-statepoints-for-gc -rs4gc-use-deopt-bundles -spp-print-base-pointers -S 2>&1 | FileCheck %s - -; CHECK: derived %obj_to_consume base %obj_to_consume - -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 -} diff --git a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/base-pointers-5.ll b/test/Transforms/RewriteStatepointsForGC/deopt-bundles/base-pointers-5.ll deleted file mode 100644 index 4d43d7f7307c..000000000000 --- a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/base-pointers-5.ll +++ /dev/null @@ -1,28 +0,0 @@ -; RUN: opt %s -rewrite-statepoints-for-gc -rs4gc-use-deopt-bundles -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 -} diff --git a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/base-pointers-6.ll b/test/Transforms/RewriteStatepointsForGC/deopt-bundles/base-pointers-6.ll deleted file mode 100644 index 2d555d179c29..000000000000 --- a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/base-pointers-6.ll +++ /dev/null @@ -1,37 +0,0 @@ -; RUN: opt %s -rewrite-statepoints-for-gc -rs4gc-use-deopt-bundles -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 -} diff --git a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/base-pointers-7.ll b/test/Transforms/RewriteStatepointsForGC/deopt-bundles/base-pointers-7.ll deleted file mode 100644 index e90ef63184ee..000000000000 --- a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/base-pointers-7.ll +++ /dev/null @@ -1,45 +0,0 @@ -; RUN: opt %s -rewrite-statepoints-for-gc -rs4gc-use-deopt-bundles -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 -} diff --git a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/base-pointers-8.ll b/test/Transforms/RewriteStatepointsForGC/deopt-bundles/base-pointers-8.ll deleted file mode 100644 index 628696ba2c2f..000000000000 --- a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/base-pointers-8.ll +++ /dev/null @@ -1,37 +0,0 @@ -; RUN: opt %s -rewrite-statepoints-for-gc -rs4gc-use-deopt-bundles -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() diff --git a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/base-pointers-9.ll b/test/Transforms/RewriteStatepointsForGC/deopt-bundles/base-pointers-9.ll deleted file mode 100644 index a82af3b96892..000000000000 --- a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/base-pointers-9.ll +++ /dev/null @@ -1,20 +0,0 @@ -; RUN: opt %s -rewrite-statepoints-for-gc -rs4gc-use-deopt-bundles -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() diff --git a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/base-pointers.ll b/test/Transforms/RewriteStatepointsForGC/deopt-bundles/base-pointers.ll deleted file mode 100644 index a378d1502add..000000000000 --- a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/base-pointers.ll +++ /dev/null @@ -1,151 +0,0 @@ -; RUN: opt %s -rewrite-statepoints-for-gc -rs4gc-use-deopt-bundles -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 = 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: %bdv = 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: %bdv = 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: %bdv = 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() diff --git a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/base-vector.ll b/test/Transforms/RewriteStatepointsForGC/deopt-bundles/base-vector.ll deleted file mode 100644 index 96b7390b77bc..000000000000 --- a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/base-vector.ll +++ /dev/null @@ -1,167 +0,0 @@ -; RUN: opt %s -rewrite-statepoints-for-gc -rs4gc-use-deopt-bundles -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, %base_ee) -; CHECK: gc.relocate -; CHECK-DAG: ; (%base_ee, %obj) -; 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-NEXT: %obj = phi i64 addrspace(1)* -; CHECK-NEXT: statepoint -; CHECK: gc.relocate -; CHECK-DAG: ; (%obj, %obj) - %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, %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: ; (%ptr, %obj) -; CHECK: gc.relocate -; CHECK-DAG: ; (%ptr, %ptr) -; 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" - -define void @test5(i1 %cnd, i64 addrspace(1)* %obj) gc "statepoint-example" { -; CHECK-LABEL: @test5 -; CHECK: gc.relocate -; CHECK-DAG: (%obj, %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)*> undef, 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 -} - -declare void @do_safepoint() diff --git a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/basics.ll b/test/Transforms/RewriteStatepointsForGC/deopt-bundles/basics.ll deleted file mode 100644 index 48c45eaa1b01..000000000000 --- a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/basics.ll +++ /dev/null @@ -1,88 +0,0 @@ -; This is a collection of really basic tests for gc.statepoint rewriting. -; RUN: opt %s -rewrite-statepoints-for-gc -rs4gc-use-deopt-bundles -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: %derived.relocated = call coldcc i8 addrspace(1)* -; CHECK-NEXT: %obj.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, ...) diff --git a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/codegen-cond.ll b/test/Transforms/RewriteStatepointsForGC/deopt-bundles/codegen-cond.ll deleted file mode 100644 index f0da0c06db0a..000000000000 --- a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/codegen-cond.ll +++ /dev/null @@ -1,81 +0,0 @@ -; RUN: opt -rewrite-statepoints-for-gc -rs4gc-use-deopt-bundles -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} diff --git a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/constants.ll b/test/Transforms/RewriteStatepointsForGC/deopt-bundles/constants.ll deleted file mode 100644 index eede1b09d161..000000000000 --- a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/constants.ll +++ /dev/null @@ -1,51 +0,0 @@ -; RUN: opt -S -rewrite-statepoints-for-gc -rs4gc-use-deopt-bundles %s | FileCheck %s - -; constants don't get relocated. -@G = addrspace(1) global i8 5 - -declare void @foo() - -define i8 @test() gc "statepoint-example" { -; CHECK-LABEL: @test -; CHECK: gc.statepoint -; CHECK-NEXT: load i8, i8 addrspace(1)* inttoptr (i64 15 to i8 addrspace(1)*) -; Mostly just here to show reasonable code test can come from. -entry: - call void @foo() [ "deopt"() ] - %res = load i8, i8 addrspace(1)* inttoptr (i64 15 to i8 addrspace(1)*) - ret i8 %res -} - -define i8 @test2(i8 addrspace(1)* %p) gc "statepoint-example" { -; CHECK-LABEL: @test2 -; CHECK: gc.statepoint -; CHECK-NEXT: gc.relocate -; CHECK-NEXT: icmp -; Globals don't move and thus don't get relocated -entry: - call void @foo() [ "deopt"() ] - %cmp = icmp eq i8 addrspace(1)* %p, null - br i1 %cmp, label %taken, label %not_taken - -taken: ; preds = %not_taken, %entry - ret i8 0 - -not_taken: ; preds = %entry - %cmp2 = icmp ne i8 addrspace(1)* %p, null - br i1 %cmp2, label %taken, label %dead - -dead: ; preds = %not_taken - %addr = getelementptr i8, i8 addrspace(1)* %p, i32 15 - %res = load i8, i8 addrspace(1)* %addr - ret i8 %res -} - -define i8 @test3(i1 %always_true) gc "statepoint-example" { -; CHECK-LABEL: @test3 -; CHECK: gc.statepoint -; CHECK-NEXT: load i8, i8 addrspace(1)* @G -entry: - call void @foo() [ "deopt"() ] - %res = load i8, i8 addrspace(1)* @G, align 1 - ret i8 %res -} diff --git a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/deref-pointers.ll b/test/Transforms/RewriteStatepointsForGC/deopt-bundles/deref-pointers.ll deleted file mode 100644 index f04c6784a878..000000000000 --- a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/deref-pointers.ll +++ /dev/null @@ -1,104 +0,0 @@ -; RUN: opt -S -rewrite-statepoints-for-gc -rs4gc-use-deopt-bundles < %s | FileCheck %s - -; CHECK: declare i8 addrspace(1)* @some_function_ret_deref() -; CHECK: define i8 addrspace(1)* @test_deref_arg(i8 addrspace(1)* %a) -; CHECK: define i8 addrspace(1)* @test_deref_or_null_arg(i8 addrspace(1)* %a) -; CHECK: define i8 addrspace(1)* @test_noalias_arg(i8 addrspace(1)* %a) - -declare void @foo() - -declare i8 addrspace(1)* @some_function() "gc-leaf-function" - -declare void @some_function_consumer(i8 addrspace(1)*) "gc-leaf-function" - -declare dereferenceable(4) i8 addrspace(1)* @some_function_ret_deref() "gc-leaf-function" -declare noalias i8 addrspace(1)* @some_function_ret_noalias() "gc-leaf-function" - -define i8 addrspace(1)* @test_deref_arg(i8 addrspace(1)* dereferenceable(4) %a) gc "statepoint-example" { -entry: - call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ] - ret i8 addrspace(1)* %a -} - -define i8 addrspace(1)* @test_deref_or_null_arg(i8 addrspace(1)* dereferenceable_or_null(4) %a) gc "statepoint-example" { -entry: - call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ] - ret i8 addrspace(1)* %a -} - -define i8 addrspace(1)* @test_noalias_arg(i8 addrspace(1)* noalias %a) gc "statepoint-example" { -entry: - call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ] - ret i8 addrspace(1)* %a -} - -define i8 addrspace(1)* @test_deref_retval() gc "statepoint-example" { -; CHECK-LABEL: @test_deref_retval( -; CHECK: %a = call i8 addrspace(1)* @some_function() -entry: - %a = call dereferenceable(4) i8 addrspace(1)* @some_function() - call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ] - ret i8 addrspace(1)* %a -} - -define i8 addrspace(1)* @test_deref_or_null_retval() gc "statepoint-example" { -; CHECK-LABEL: @test_deref_or_null_retval( -; CHECK: %a = call i8 addrspace(1)* @some_function() -entry: - %a = call dereferenceable_or_null(4) i8 addrspace(1)* @some_function() - call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ] - ret i8 addrspace(1)* %a -} - -define i8 addrspace(1)* @test_noalias_retval() gc "statepoint-example" { -; CHECK-LABEL: @test_noalias_retval( -; CHECK: %a = call i8 addrspace(1)* @some_function() -entry: - %a = call noalias i8 addrspace(1)* @some_function() - call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ] - ret i8 addrspace(1)* %a -} - -define i8 @test_md(i8 addrspace(1)* %ptr) gc "statepoint-example" { -; CHECK-LABEL: @test_md( -; CHECK: %tmp = load i8, i8 addrspace(1)* %ptr, !tbaa !0 -entry: - %tmp = load i8, i8 addrspace(1)* %ptr, !tbaa !0 - call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ] - ret i8 %tmp -} - -define i8 addrspace(1)* @test_decl_only_attribute(i8 addrspace(1)* %ptr) gc "statepoint-example" { -; CHECK-LABEL: @test_decl_only_attribute( -; No change here, but the prototype of some_function_ret_deref should have changed. -; CHECK: call i8 addrspace(1)* @some_function_ret_deref() -entry: - %a = call i8 addrspace(1)* @some_function_ret_deref() - call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ] - ret i8 addrspace(1)* %a -} - -define i8 addrspace(1)* @test_decl_only_noalias(i8 addrspace(1)* %ptr) gc "statepoint-example" { -; CHECK-LABEL: @test_decl_only_noalias( -; No change here, but the prototype of some_function_ret_noalias should have changed. -; CHECK: call i8 addrspace(1)* @some_function_ret_noalias() -entry: - %a = call i8 addrspace(1)* @some_function_ret_noalias() - call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ] - ret i8 addrspace(1)* %a -} - -define i8 addrspace(1)* @test_callsite_arg_attribute(i8 addrspace(1)* %ptr) gc "statepoint-example" { -; CHECK-LABEL: @test_callsite_arg_attribute( -; CHECK: call void @some_function_consumer(i8 addrspace(1)* %ptr) -; CHECK: !0 = !{!1, !1, i64 0} -; CHECK: !1 = !{!"red", !2} -; CHECK: !2 = !{!"blue"} -entry: - call void @some_function_consumer(i8 addrspace(1)* dereferenceable(4) noalias %ptr) - call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ] - ret i8 addrspace(1)* %ptr -} -!0 = !{!1, !1, i64 0, i64 1} -!1 = !{!"red", !2} -!2 = !{!"blue"} diff --git a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/live-vector.ll b/test/Transforms/RewriteStatepointsForGC/deopt-bundles/live-vector.ll deleted file mode 100644 index 284a993bae29..000000000000 --- a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/live-vector.ll +++ /dev/null @@ -1,149 +0,0 @@ -; Test that we can correctly handle vectors of pointers in statepoint -; rewriting. Currently, we scalarize, but that's an implementation detail. -; RUN: opt %s -rewrite-statepoints-for-gc -rs4gc-use-deopt-bundles -rs4gc-split-vector-values -S | FileCheck %s - -; A non-vector relocation for comparison - -define i64 addrspace(1)* @test(i64 addrspace(1)* %obj) gc "statepoint-example" { -; CHECK-LABEL: test -; CHECK: gc.statepoint -; CHECK-NEXT: gc.relocate -; CHECK-NEXT: bitcast -; CHECK-NEXT: ret i64 addrspace(1)* %obj.relocated.casted -; A base vector from a argument -entry: - call void @do_safepoint() [ "deopt"() ] - ret i64 addrspace(1)* %obj -} - -define <2 x i64 addrspace(1)*> @test2(<2 x i64 addrspace(1)*> %obj) gc "statepoint-example" { -; CHECK-LABEL: test2 -; CHECK: extractelement -; CHECK-NEXT: extractelement -; CHECK-NEXT: gc.statepoint -; CHECK-NEXT: gc.relocate -; CHECK-NEXT: bitcast -; CHECK-NEXT: gc.relocate -; CHECK-NEXT: bitcast -; CHECK-NEXT: insertelement -; CHECK-NEXT: insertelement -; CHECK-NEXT: ret <2 x i64 addrspace(1)*> %7 -; A base vector from a load -entry: - call void @do_safepoint() [ "deopt"() ] - ret <2 x i64 addrspace(1)*> %obj -} - -define <2 x i64 addrspace(1)*> @test3(<2 x i64 addrspace(1)*>* %ptr) gc "statepoint-example" { -; CHECK-LABEL: test3 -; CHECK: load -; CHECK-NEXT: extractelement -; CHECK-NEXT: extractelement -; CHECK-NEXT: gc.statepoint -; CHECK-NEXT: gc.relocate -; CHECK-NEXT: bitcast -; CHECK-NEXT: gc.relocate -; CHECK-NEXT: bitcast -; CHECK-NEXT: insertelement -; CHECK-NEXT: insertelement -; CHECK-NEXT: ret <2 x i64 addrspace(1)*> %7 -; When a statepoint is an invoke rather than a call -entry: - %obj = load <2 x i64 addrspace(1)*>, <2 x i64 addrspace(1)*>* %ptr - call void @do_safepoint() [ "deopt"() ] - ret <2 x i64 addrspace(1)*> %obj -} - -declare i32 @fake_personality_function() - -define <2 x i64 addrspace(1)*> @test4(<2 x i64 addrspace(1)*>* %ptr) gc "statepoint-example" personality i32 ()* @fake_personality_function { -; CHECK-LABEL: test4 -; CHECK: load -; CHECK-NEXT: extractelement -; CHECK-NEXT: extractelement -; CHECK-NEXT: gc.statepoint -entry: - %obj = load <2 x i64 addrspace(1)*>, <2 x i64 addrspace(1)*>* %ptr - invoke void @do_safepoint() [ "deopt"() ] - to label %normal_return unwind label %exceptional_return - -normal_return: ; preds = %entry -; CHECK-LABEL: normal_return: -; CHECK: gc.relocate -; CHECK-NEXT: bitcast -; CHECK-NEXT: gc.relocate -; CHECK-NEXT: bitcast -; CHECK-NEXT: insertelement -; CHECK-NEXT: insertelement -; CHECK-NEXT: ret <2 x i64 addrspace(1)*> %7 - ret <2 x i64 addrspace(1)*> %obj - -exceptional_return: ; preds = %entry -; CHECK-LABEL: exceptional_return: -; CHECK: gc.relocate -; CHECK-NEXT: bitcast -; CHECK-NEXT: gc.relocate -; CHECK-NEXT: bitcast -; CHECK-NEXT: insertelement -; CHECK-NEXT: insertelement -; CHECK-NEXT: ret <2 x i64 addrspace(1)*> %13 -; Can we handle an insert element with a constant offset? This effectively -; tests both the equal and inequal case since we have to relocate both indices -; in the vector. - %landing_pad4 = landingpad token - cleanup - ret <2 x i64 addrspace(1)*> %obj -} - -define <2 x i64 addrspace(1)*> @test5(i64 addrspace(1)* %p) gc "statepoint-example" { -; CHECK-LABEL: test5 -; CHECK: insertelement -; CHECK-NEXT: extractelement -; CHECK-NEXT: extractelement -; CHECK-NEXT: gc.statepoint -; CHECK-NEXT: gc.relocate -; CHECK-NEXT: bitcast -; CHECK-NEXT: gc.relocate -; CHECK-NEXT: bitcast -; CHECK-NEXT: insertelement -; CHECK-NEXT: insertelement -; CHECK-NEXT: ret <2 x i64 addrspace(1)*> %7 -; A base vector from a load -entry: - %vec = insertelement <2 x i64 addrspace(1)*> undef, i64 addrspace(1)* %p, i32 0 - call void @do_safepoint() [ "deopt"() ] - ret <2 x i64 addrspace(1)*> %vec -} - -define <2 x i64 addrspace(1)*> @test6(i1 %cnd, <2 x i64 addrspace(1)*>* %ptr) gc "statepoint-example" { -; CHECK-LABEL: test6 -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 -; CHECK-LABEL: merge: -; CHECK-NEXT: = phi -; CHECK-NEXT: extractelement -; CHECK-NEXT: extractelement -; CHECK-NEXT: gc.statepoint -; CHECK-NEXT: gc.relocate -; CHECK-NEXT: bitcast -; CHECK-NEXT: gc.relocate -; CHECK-NEXT: bitcast -; CHECK-NEXT: insertelement -; CHECK-NEXT: insertelement -; CHECK-NEXT: ret <2 x i64 addrspace(1)*> - %obj = phi <2 x i64 addrspace(1)*> [ %obja, %taken ], [ %objb, %untaken ] - call void @do_safepoint() [ "deopt"() ] - ret <2 x i64 addrspace(1)*> %obj -} - -declare void @do_safepoint() diff --git a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/liveness-basics.ll b/test/Transforms/RewriteStatepointsForGC/deopt-bundles/liveness-basics.ll deleted file mode 100644 index c5b213f4c82d..000000000000 --- a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/liveness-basics.ll +++ /dev/null @@ -1,165 +0,0 @@ -; A collection of liveness test cases to ensure we're reporting the -; correct live values at statepoints -; RUN: opt -rewrite-statepoints-for-gc -rs4gc-use-deopt-bundles -spp-rematerialization-threshold=0 -S < %s | FileCheck %s - -; Tests to make sure we consider %obj live in both the taken and untaken -; predeccessor of merge. - -define i64 addrspace(1)* @test1(i1 %cmp, i64 addrspace(1)* %obj) gc "statepoint-example" { -; CHECK-LABEL: @test1 -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)* -; CHECK-NEXT: bitcast -; CHECK-NEXT: br label %merge - call void @foo() [ "deopt"() ] - br label %merge - -untaken: ; preds = %entry -; CHECK-LABEL: untaken: -; CHECK-NEXT: gc.statepoint -; CHECK-NEXT: %obj.relocated2 = call coldcc i8 addrspace(1)* -; CHECK-NEXT: bitcast -; CHECK-NEXT: br label %merge - call void @foo() [ "deopt"() ] - br label %merge - -merge: ; preds = %untaken, %taken -; CHECK-LABEL: merge: -; CHECK-NEXT: %.0 = phi i64 addrspace(1)* [ %obj.relocated.casted, %taken ], [ %obj.relocated2.casted, %untaken ] -; CHECK-NEXT: ret i64 addrspace(1)* %.0 -; A local kill should not effect liveness in predecessor block - ret i64 addrspace(1)* %obj -} - -define i64 addrspace(1)* @test2(i1 %cmp, i64 addrspace(1)** %loc) gc "statepoint-example" { -; CHECK-LABEL: @test2 -entry: -; CHECK-LABEL: entry: -; CHECK-NEXT: gc.statepoint -; CHECK-NEXT: br - call void @foo() [ "deopt"() ] - br i1 %cmp, label %taken, label %untaken - -taken: ; preds = %entry -; CHECK-LABEL: taken: -; CHECK-NEXT: %obj = load -; CHECK-NEXT: gc.statepoint -; CHECK-NEXT: gc.relocate -; CHECK-NEXT: bitcast -; CHECK-NEXT: ret i64 addrspace(1)* %obj.relocated.casted -; A local kill should effect values live from a successor phi. Also, we -; should only propagate liveness from a phi to the appropriate predecessors. - %obj = load i64 addrspace(1)*, i64 addrspace(1)** %loc - call void @foo() [ "deopt"() ] - ret i64 addrspace(1)* %obj - -untaken: ; preds = %entry - ret i64 addrspace(1)* null -} - -define i64 addrspace(1)* @test3(i1 %cmp, i64 addrspace(1)** %loc) gc "statepoint-example" { -; CHECK-LABEL: @test3 -entry: - br i1 %cmp, label %taken, label %untaken - -taken: ; preds = %entry -; CHECK-LABEL: taken: -; CHECK-NEXT: gc.statepoint -; CHECK-NEXT: %obj = load -; CHECK-NEXT: gc.statepoint -; CHECK-NEXT: %obj.relocated = call coldcc i8 addrspace(1)* -; CHECK-NEXT: bitcast -; CHECK-NEXT: br label %merge - call void @foo() [ "deopt"() ] - %obj = load i64 addrspace(1)*, i64 addrspace(1)** %loc - call void @foo() [ "deopt"() ] - br label %merge - -untaken: ; preds = %entry -; CHECK-LABEL: taken: -; CHECK-NEXT: gc.statepoint -; CHECK-NEXT: br label %merge -; A base pointer must be live if it is needed at a later statepoint, -; even if the base pointer is otherwise unused. - call void @foo() [ "deopt"() ] - br label %merge - -merge: ; preds = %untaken, %taken - %phi = phi i64 addrspace(1)* [ %obj, %taken ], [ null, %untaken ] - ret i64 addrspace(1)* %phi -} - -define i64 addrspace(1)* @test4(i1 %cmp, i64 addrspace(1)* %obj) gc "statepoint-example" { -; CHECK-LABEL: @test4 -entry: -; CHECK-LABEL: entry: -; CHECK-NEXT: %derived = getelementptr -; CHECK-NEXT: gc.statepoint -; CHECK-NEXT: %derived.relocated = -; CHECK-NEXT: bitcast -; CHECK-NEXT: %obj.relocated = -; CHECK-NEXT: bitcast -; CHECK-NEXT: gc.statepoint -; CHECK-NEXT: %derived.relocated2 = -; CHECK-NEXT: bitcast - -; Note: It's legal to relocate obj again, but not strictly needed -; CHECK-NEXT: %obj.relocated3 = -; CHECK-NEXT: bitcast -; CHECK-NEXT: ret i64 addrspace(1)* %derived.relocated2.casted -; -; Make sure that a phi def visited during iteration is considered a kill. -; Also, liveness after base pointer analysis can change based on new uses, -; not just new defs. - %derived = getelementptr i64, i64 addrspace(1)* %obj, i64 8 - call void @foo() [ "deopt"() ] - call void @foo() [ "deopt"() ] - ret i64 addrspace(1)* %derived -} - -declare void @consume(...) readonly "gc-leaf-function" - -define i64 addrspace(1)* @test5(i1 %cmp, i64 addrspace(1)* %obj) gc "statepoint-example" { -; CHECK-LABEL: @test5 -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)* -; CHECK-NEXT: bitcast -; CHECK-NEXT: br label %merge - call void @foo() [ "deopt"() ] - br label %merge - -untaken: ; preds = %entry -; CHECK-LABEL: untaken: -; CHECK-NEXT: br label %merge - br label %merge - -merge: ; preds = %untaken, %taken -; CHECK-LABEL: merge: -; CHECK-NEXT: %.0 = phi i64 addrspace(1)* -; CHECK-NEXT: %obj2a = phi -; CHECK-NEXT: @consume -; CHECK-NEXT: br label %final - %obj2a = phi i64 addrspace(1)* [ %obj, %taken ], [ null, %untaken ] - call void (...) @consume(i64 addrspace(1)* %obj2a) - br label %final - -final: ; preds = %merge -; CHECK-LABEL: final: -; CHECK-NEXT: @consume -; CHECK-NEXT: ret i64 addrspace(1)* %.0 - call void (...) @consume(i64 addrspace(1)* %obj2a) - ret i64 addrspace(1)* %obj -} - -declare void @foo() - diff --git a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/preprocess.ll b/test/Transforms/RewriteStatepointsForGC/deopt-bundles/preprocess.ll deleted file mode 100644 index e0bd542aa5d5..000000000000 --- a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/preprocess.ll +++ /dev/null @@ -1,62 +0,0 @@ -; RUN: opt -rewrite-statepoints-for-gc -rs4gc-use-deopt-bundles -S < %s | FileCheck %s - -; Test to make sure we destroy LCSSA's single entry phi nodes before -; running liveness - -declare void @consume(...) "gc-leaf-function" - -define void @test6(i64 addrspace(1)* %obj) gc "statepoint-example" { -; CHECK-LABEL: @test6 -entry: - br label %next - -next: ; preds = %entry -; CHECK-LABEL: next: -; CHECK-NEXT: gc.statepoint -; CHECK-NEXT: gc.relocate -; CHECK-NEXT: bitcast -; CHECK-NEXT: @consume(i64 addrspace(1)* %obj.relocated.casted) -; CHECK-NEXT: @consume(i64 addrspace(1)* %obj.relocated.casted) -; Need to delete unreachable gc.statepoint call - %obj2 = phi i64 addrspace(1)* [ %obj, %entry ] - call void @foo() [ "deopt"() ] - call void (...) @consume(i64 addrspace(1)* %obj2) - call void (...) @consume(i64 addrspace(1)* %obj) - ret void -} - -define void @test7() gc "statepoint-example" { -; CHECK-LABEL: test7 -; CHECK-NOT: gc.statepoint -; Need to delete unreachable gc.statepoint invoke - tested seperately given -; a correct implementation could only remove the instructions, not the block - ret void - -unreached: ; preds = %unreached - %obj = phi i64 addrspace(1)* [ null, %unreached ] - call void @foo() [ "deopt"() ] - call void (...) @consume(i64 addrspace(1)* %obj) - br label %unreached -} - -define void @test8() gc "statepoint-example" personality i32 ()* undef { -; CHECK-LABEL: test8 -; CHECK-NOT: gc.statepoint -; Bound the last check-not - ret void - -unreached: ; No predecessors! - invoke void @foo() [ "deopt"() ] -; CHECK-LABEL: @foo - to label %normal_return unwind label %exceptional_return - -normal_return: ; preds = %unreached - ret void - -exceptional_return: ; preds = %unreached - %landing_pad4 = landingpad { i8*, i32 } - cleanup - ret void -} - -declare void @foo() diff --git a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/relocation.ll b/test/Transforms/RewriteStatepointsForGC/deopt-bundles/relocation.ll deleted file mode 100644 index 584dc32b7529..000000000000 --- a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/relocation.ll +++ /dev/null @@ -1,279 +0,0 @@ -; RUN: opt %s -rewrite-statepoints-for-gc -rs4gc-use-deopt-bundles -spp-rematerialization-threshold=0 -S 2>&1 | FileCheck %s - - -declare void @foo() - -declare void @use(...) "gc-leaf-function" - -define i64 addrspace(1)* @test1(i64 addrspace(1)* %obj, i64 addrspace(1)* %obj2, i1 %condition) gc "statepoint-example" { -; CHECK-LABEL: @test1 -; CHECK-DAG: %obj.relocated -; CHECK-DAG: %obj2.relocated -entry: - call void @foo() [ "deopt"() ] - br label %joint - -joint: ; preds = %joint2, %entry -; CHECK-LABEL: joint: -; CHECK: %phi1 = phi i64 addrspace(1)* [ %obj.relocated.casted, %entry ], [ %obj3, %joint2 ] - %phi1 = phi i64 addrspace(1)* [ %obj, %entry ], [ %obj3, %joint2 ] - br i1 %condition, label %use, label %joint2 - -use: ; preds = %joint - br label %joint2 - -joint2: ; preds = %use, %joint -; CHECK-LABEL: joint2: -; CHECK: %phi2 = phi i64 addrspace(1)* [ %obj.relocated.casted, %use ], [ %obj2.relocated.casted, %joint ] -; CHECK: %obj3 = getelementptr i64, i64 addrspace(1)* %obj2.relocated.casted, i32 1 - %phi2 = phi i64 addrspace(1)* [ %obj, %use ], [ %obj2, %joint ] - %obj3 = getelementptr i64, i64 addrspace(1)* %obj2, i32 1 - br label %joint -} - -declare i64 addrspace(1)* @generate_obj() "gc-leaf-function" - -declare void @consume_obj(i64 addrspace(1)*) "gc-leaf-function" - -declare i1 @rt() "gc-leaf-function" - -define void @test2() gc "statepoint-example" { -; CHECK-LABEL: @test2 -entry: - %obj_init = call i64 addrspace(1)* @generate_obj() - %obj = getelementptr i64, i64 addrspace(1)* %obj_init, i32 42 - br label %loop - -loop: ; preds = %loop.backedge, %entry -; CHECK: loop: -; CHECK-DAG: [ %obj_init.relocated.casted, %loop.backedge ] -; CHECK-DAG: [ %obj_init, %entry ] -; CHECK-DAG: [ %obj.relocated.casted, %loop.backedge ] -; CHECK-DAG: [ %obj, %entry ] -; CHECK-NOT: %location = getelementptr i64, i64 addrspace(1)* %obj, i32 %index - %index = phi i32 [ 0, %entry ], [ %index.inc, %loop.backedge ] - %location = getelementptr i64, i64 addrspace(1)* %obj, i32 %index - call void @consume_obj(i64 addrspace(1)* %location) - %index.inc = add i32 %index, 1 - %condition = call i1 @rt() - br i1 %condition, label %loop_x, label %loop_y - -loop_x: ; preds = %loop - br label %loop.backedge - -loop.backedge: ; preds = %loop_y, %loop_x - call void @do_safepoint() [ "deopt"() ] - br label %loop - -loop_y: ; preds = %loop - br label %loop.backedge -} - -declare void @some_call(i8 addrspace(1)*) "gc-leaf-function" - -define void @relocate_merge(i1 %cnd, i8 addrspace(1)* %arg) gc "statepoint-example" { -; CHECK-LABEL: @relocate_merge - -bci_0: - br i1 %cnd, label %if_branch, label %else_branch - -if_branch: ; preds = %bci_0 -; CHECK-LABEL: if_branch: -; CHECK: gc.statepoint -; CHECK: gc.relocate - call void @foo() [ "deopt"() ] - br label %join - -else_branch: ; preds = %bci_0 -; CHECK-LABEL: else_branch: -; CHECK: gc.statepoint -; CHECK: gc.relocate -; We need to end up with a single relocation phi updated from both paths - call void @foo() [ "deopt"() ] - br label %join - -join: ; preds = %else_branch, %if_branch -; CHECK-LABEL: join: -; CHECK: phi i8 addrspace(1)* -; CHECK-DAG: [ %arg.relocated, %if_branch ] -; CHECK-DAG: [ %arg.relocated2, %else_branch ] -; CHECK-NOT: phi - call void @some_call(i8 addrspace(1)* %arg) - ret void -} - -; Make sure a use in a statepoint gets properly relocated at a previous one. -; This is basically just making sure that statepoints aren't accidentally -; treated specially. -define void @test3(i64 addrspace(1)* %obj) gc "statepoint-example" { -; CHECK-LABEL: @test3 -; CHECK: gc.statepoint -; CHECK-NEXT: gc.relocate -; CHECK-NEXT: bitcast -; CHECK-NEXT: gc.statepoint -entry: - call void undef(i64 undef) [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ] - %0 = call i32 undef(i64 addrspace(1)* %obj) [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ] - ret void -} - -; Check specifically for the case where the result of a statepoint needs to -; be relocated itself -define void @test4() gc "statepoint-example" { -; CHECK-LABEL: @test4 -; CHECK: gc.statepoint -; CHECK: gc.result -; CHECK: gc.statepoint -; CHECK: [[RELOCATED:%[^ ]+]] = call {{.*}}gc.relocate -; CHECK: @use(i8 addrspace(1)* [[RELOCATED]]) - %1 = call i8 addrspace(1)* undef() [ "deopt"() ] - %2 = call i8 addrspace(1)* undef() [ "deopt"() ] - call void (...) @use(i8 addrspace(1)* %1) - unreachable -} - -; Test updating a phi where not all inputs are live to begin with -define void @test5(i8 addrspace(1)* %arg) gc "statepoint-example" { -; CHECK-LABEL: test5 -entry: - %0 = call i8 addrspace(1)* undef() [ "deopt"() ] - switch i32 undef, label %kill [ - i32 10, label %merge - i32 13, label %merge - ] - -kill: ; preds = %entry - br label %merge - -merge: ; preds = %kill, %entry, %entry -; CHECK: merge: -; CHECK: %test = phi i8 addrspace(1) -; CHECK-DAG: [ null, %kill ] -; CHECK-DAG: [ %arg.relocated, %entry ] -; CHECK-DAG: [ %arg.relocated, %entry ] - %test = phi i8 addrspace(1)* [ null, %kill ], [ %arg, %entry ], [ %arg, %entry ] - call void (...) @use(i8 addrspace(1)* %test) - unreachable -} - -; Check to make sure we handle values live over an entry statepoint -define void @test6(i8 addrspace(1)* %arg1, i8 addrspace(1)* %arg2, i8 addrspace(1)* %arg3) gc "statepoint-example" { -; CHECK-LABEL: @test6 -entry: - br i1 undef, label %gc.safepoint_poll.exit2, label %do_safepoint - -do_safepoint: ; preds = %entry -; CHECK-LABEL: do_safepoint: -; CHECK: gc.statepoint -; CHECK: arg1.relocated = -; CHECK: arg2.relocated = -; CHECK: arg3.relocated = - call void @foo() [ "deopt"(i8 addrspace(1)* %arg1, i8 addrspace(1)* %arg2, i8 addrspace(1)* %arg3) ] - br label %gc.safepoint_poll.exit2 - -gc.safepoint_poll.exit2: ; preds = %do_safepoint, %entry -; CHECK-LABEL: gc.safepoint_poll.exit2: -; CHECK: phi i8 addrspace(1)* -; CHECK-DAG: [ %arg3, %entry ] -; CHECK-DAG: [ %arg3.relocated, %do_safepoint ] -; CHECK: phi i8 addrspace(1)* -; CHECK-DAG: [ %arg2, %entry ] -; CHECK-DAG: [ %arg2.relocated, %do_safepoint ] -; CHECK: phi i8 addrspace(1)* -; CHECK-DAG: [ %arg1, %entry ] -; CHECK-DAG: [ %arg1.relocated, %do_safepoint ] - call void (...) @use(i8 addrspace(1)* %arg1, i8 addrspace(1)* %arg2, i8 addrspace(1)* %arg3) - ret void -} - -; Check relocation in a loop nest where a relocation happens in the outer -; but not the inner loop -define void @test_outer_loop(i8 addrspace(1)* %arg1, i8 addrspace(1)* %arg2, i1 %cmp) gc "statepoint-example" { -; CHECK-LABEL: @test_outer_loop - -bci_0: - br label %outer-loop - -outer-loop: ; preds = %outer-inc, %bci_0 -; CHECK-LABEL: outer-loop: -; CHECK: phi i8 addrspace(1)* [ %arg2, %bci_0 ], [ %arg2.relocated, %outer-inc ] -; CHECK: phi i8 addrspace(1)* [ %arg1, %bci_0 ], [ %arg1.relocated, %outer-inc ] - br label %inner-loop - -inner-loop: ; preds = %inner-loop, %outer-loop - br i1 %cmp, label %inner-loop, label %outer-inc - -outer-inc: ; preds = %inner-loop -; CHECK-LABEL: outer-inc: -; CHECK: %arg1.relocated -; CHECK: %arg2.relocated - call void @foo() [ "deopt"(i8 addrspace(1)* %arg1, i8 addrspace(1)* %arg2) ] - br label %outer-loop -} - -; Check that both inner and outer loops get phis when relocation is in -; inner loop -define void @test_inner_loop(i8 addrspace(1)* %arg1, i8 addrspace(1)* %arg2, i1 %cmp) gc "statepoint-example" { -; CHECK-LABEL: @test_inner_loop - -bci_0: - br label %outer-loop - -outer-loop: ; preds = %outer-inc, %bci_0 -; CHECK-LABEL: outer-loop: -; CHECK: phi i8 addrspace(1)* [ %arg2, %bci_0 ], [ %arg2.relocated, %outer-inc ] -; CHECK: phi i8 addrspace(1)* [ %arg1, %bci_0 ], [ %arg1.relocated, %outer-inc ] - br label %inner-loop -; CHECK-LABEL: inner-loop -; CHECK: phi i8 addrspace(1)* -; CHECK-DAG: %outer-loop ] -; CHECK-DAG: [ %arg2.relocated, %inner-loop ] -; CHECK: phi i8 addrspace(1)* -; CHECK-DAG: %outer-loop ] -; CHECK-DAG: [ %arg1.relocated, %inner-loop ] -; CHECK: gc.statepoint -; CHECK: %arg1.relocated -; CHECK: %arg2.relocated - -inner-loop: ; preds = %inner-loop, %outer-loop - call void @foo() [ "deopt"(i8 addrspace(1)* %arg1, i8 addrspace(1)* %arg2) ] - br i1 %cmp, label %inner-loop, label %outer-inc - -outer-inc: ; preds = %inner-loop -; CHECK-LABEL: outer-inc: -; This test shows why updating just those uses of the original value being -; relocated dominated by the inserted relocation is not always sufficient. - br label %outer-loop -} - -define i64 addrspace(1)* @test7(i64 addrspace(1)* %obj, i64 addrspace(1)* %obj2, i1 %condition) gc "statepoint-example" { -; CHECK-LABEL: @test7 -entry: - br i1 %condition, label %branch2, label %join - -branch2: ; preds = %entry - br i1 %condition, label %callbb, label %join2 - -callbb: ; preds = %branch2 - call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ] - br label %join - -join: ; preds = %callbb, %entry -; CHECK-LABEL: join: -; CHECK: phi i64 addrspace(1)* [ %obj.relocated.casted, %callbb ], [ %obj, %entry ] -; CHECK: phi i64 addrspace(1)* -; CHECK-DAG: [ %obj, %entry ] -; CHECK-DAG: [ %obj2.relocated.casted, %callbb ] - %phi1 = phi i64 addrspace(1)* [ %obj, %entry ], [ %obj2, %callbb ] - br label %join2 - -join2: ; preds = %join, %branch2 -; CHECK-LABEL: join2: -; CHECK: phi2 = phi i64 addrspace(1)* -; CHECK-DAG: %join ] -; CHECK-DAG: [ %obj2, %branch2 ] - %phi2 = phi i64 addrspace(1)* [ %obj, %join ], [ %obj2, %branch2 ] - ret i64 addrspace(1)* %phi2 -} - -declare void @do_safepoint() diff --git a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/rematerialize-derived-pointers.ll b/test/Transforms/RewriteStatepointsForGC/deopt-bundles/rematerialize-derived-pointers.ll deleted file mode 100644 index 0020c5116c13..000000000000 --- a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/rematerialize-derived-pointers.ll +++ /dev/null @@ -1,150 +0,0 @@ -; RUN: opt %s -rewrite-statepoints-for-gc -rs4gc-use-deopt-bundles -S 2>&1 | FileCheck %s - - -declare void @use_obj16(i16 addrspace(1)*) "gc-leaf-function" -declare void @use_obj32(i32 addrspace(1)*) "gc-leaf-function" -declare void @use_obj64(i64 addrspace(1)*) "gc-leaf-function" - -declare void @do_safepoint() - -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 - call void @do_safepoint() [ "deopt"() ] - call void @use_obj32(i32 addrspace(1)* %base) - call void @use_obj32(i32 addrspace(1)* %ptr) - ret void -} - -define void @test_gep_idx(i32 addrspace(1)* %base, i32 %idx) gc "statepoint-example" { -; CHECK-LABEL: test_gep_idx -entry: - %ptr = getelementptr i32, i32 addrspace(1)* %base, i32 %idx - call void @do_safepoint() [ "deopt"() ] - call void @use_obj32(i32 addrspace(1)* %base) - call void @use_obj32(i32 addrspace(1)* %ptr) - ret void -} - -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)* - call void @do_safepoint() [ "deopt"() ] - call void @use_obj32(i32 addrspace(1)* %base) - call void @use_obj64(i64 addrspace(1)* %ptr) - 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 - %ptr.cast = bitcast i32 addrspace(1)* %ptr.gep to i64 addrspace(1)* - call void @do_safepoint() [ "deopt"() ] - call void @use_obj32(i32 addrspace(1)* %base) - call void @use_obj64(i64 addrspace(1)* %ptr.cast) - ret void -} - -define void @test_intersecting_chains(i32 addrspace(1)* %base, i32 %idx) gc "statepoint-example" { -; CHECK-LABEL: test_intersecting_chains -entry: - %ptr.gep = getelementptr i32, i32 addrspace(1)* %base, i32 15 - %ptr.cast = bitcast i32 addrspace(1)* %ptr.gep to i64 addrspace(1)* - %ptr.cast2 = bitcast i32 addrspace(1)* %ptr.gep to i16 addrspace(1)* - call void @do_safepoint() [ "deopt"() ] - call void @use_obj64(i64 addrspace(1)* %ptr.cast) - call void @use_obj16(i16 addrspace(1)* %ptr.cast2) - ret void -} - -define void @test_cost_threshold(i32 addrspace(1)* %base, i32 %idx1, i32 %idx2, i32 %idx3) gc "statepoint-example" { -; CHECK-LABEL: test_cost_threshold -entry: - %ptr.gep = getelementptr i32, i32 addrspace(1)* %base, i32 15 - %ptr.gep2 = getelementptr i32, i32 addrspace(1)* %ptr.gep, i32 %idx1 - %ptr.gep3 = getelementptr i32, i32 addrspace(1)* %ptr.gep2, i32 %idx2 - %ptr.gep4 = getelementptr i32, i32 addrspace(1)* %ptr.gep3, i32 %idx3 - %ptr.cast = bitcast i32 addrspace(1)* %ptr.gep4 to i64 addrspace(1)* - call void @do_safepoint() [ "deopt"() ] - call void @use_obj64(i64 addrspace(1)* %ptr.cast) - ret void -} - -define void @test_two_derived(i32 addrspace(1)* %base) gc "statepoint-example" { -; CHECK-LABEL: test_two_derived -entry: - %ptr = getelementptr i32, i32 addrspace(1)* %base, i32 15 - %ptr2 = getelementptr i32, i32 addrspace(1)* %base, i32 12 - call void @do_safepoint() [ "deopt"() ] - call void @use_obj32(i32 addrspace(1)* %ptr) - call void @use_obj32(i32 addrspace(1)* %ptr2) - ret void -} - -define void @test_gep_smallint_array([3 x i32] addrspace(1)* %base) gc "statepoint-example" { -; CHECK-LABEL: test_gep_smallint_array -entry: - %ptr = getelementptr [3 x i32], [3 x i32] addrspace(1)* %base, i32 0, i32 2 - call void @do_safepoint() [ "deopt"() ] - call void @use_obj32(i32 addrspace(1)* %ptr) - ret void -} - -declare i32 @fake_personality_function() - -define void @test_invoke(i32 addrspace(1)* %base) gc "statepoint-example" personality i32 ()* @fake_personality_function { -; CHECK-LABEL: test_invoke -entry: - %ptr.gep = getelementptr i32, i32 addrspace(1)* %base, i32 15 - %ptr.cast = bitcast i32 addrspace(1)* %ptr.gep to i64 addrspace(1)* - %ptr.cast2 = bitcast i32 addrspace(1)* %ptr.gep to i16 addrspace(1)* - invoke void @do_safepoint() [ "deopt"() ] - to label %normal unwind label %exception - -normal: ; preds = %entry - call void @use_obj64(i64 addrspace(1)* %ptr.cast) - call void @use_obj16(i16 addrspace(1)* %ptr.cast2) - ret void - -exception: ; preds = %entry - %landing_pad4 = landingpad token - cleanup - call void @use_obj64(i64 addrspace(1)* %ptr.cast) - call void @use_obj16(i16 addrspace(1)* %ptr.cast2) - ret void -} - -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 - br label %loop - -loop: ; preds = %loop, %entry - call void @use_obj32(i32 addrspace(1)* %ptr.gep) - call void @do_safepoint() [ "deopt"() ] - br label %loop -} - -define void @test_too_long(i32 addrspace(1)* %base) gc "statepoint-example" { -; CHECK-LABEL: test_too_long -entry: - %ptr.gep = getelementptr i32, i32 addrspace(1)* %base, i32 15 - %ptr.gep1 = getelementptr i32, i32 addrspace(1)* %ptr.gep, i32 15 - %ptr.gep2 = getelementptr i32, i32 addrspace(1)* %ptr.gep1, i32 15 - %ptr.gep3 = getelementptr i32, i32 addrspace(1)* %ptr.gep2, i32 15 - %ptr.gep4 = getelementptr i32, i32 addrspace(1)* %ptr.gep3, i32 15 - %ptr.gep5 = getelementptr i32, i32 addrspace(1)* %ptr.gep4, i32 15 - %ptr.gep6 = getelementptr i32, i32 addrspace(1)* %ptr.gep5, i32 15 - %ptr.gep7 = getelementptr i32, i32 addrspace(1)* %ptr.gep6, i32 15 - %ptr.gep8 = getelementptr i32, i32 addrspace(1)* %ptr.gep7, i32 15 - %ptr.gep9 = getelementptr i32, i32 addrspace(1)* %ptr.gep8, i32 15 - %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"() ] - call void @use_obj32(i32 addrspace(1)* %ptr.gep11) - ret void -} diff --git a/test/Transforms/RewriteStatepointsForGC/deopt-intrinsic-cconv.ll b/test/Transforms/RewriteStatepointsForGC/deopt-intrinsic-cconv.ll new file mode 100644 index 000000000000..b74c1963ddfd --- /dev/null +++ b/test/Transforms/RewriteStatepointsForGC/deopt-intrinsic-cconv.ll @@ -0,0 +1,16 @@ +; RUN: opt -rewrite-statepoints-for-gc -S < %s | FileCheck %s + +target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-apple-macosx10.11.0" + +declare cc42 double @llvm.experimental.deoptimize.f64(...) + +define double @caller_3() gc "statepoint-example" { +; CHECK-LABELL @caller_3( +; CHECK: call cc42 token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint +; CHECK: unreachable + +entry: + %val = call cc42 double(...) @llvm.experimental.deoptimize.f64() [ "deopt"() ] + ret double %val +} diff --git a/test/Transforms/RewriteStatepointsForGC/deopt-intrinsic.ll b/test/Transforms/RewriteStatepointsForGC/deopt-intrinsic.ll new file mode 100644 index 000000000000..ef0e2bd61afc --- /dev/null +++ b/test/Transforms/RewriteStatepointsForGC/deopt-intrinsic.ll @@ -0,0 +1,35 @@ +; RUN: opt -rewrite-statepoints-for-gc -S < %s | FileCheck %s + +target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-apple-macosx10.11.0" + +declare i32 @llvm.experimental.deoptimize.i32(...) +declare void @llvm.experimental.deoptimize.isVoid(...) + +define i32 @caller_0(i32 addrspace(1)* %ptr) gc "statepoint-example" { +; CHECK-LABEL: @caller_0( +; CHECK: @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* @__llvm_deoptimize, i32 0 +; CHECK: unreachable +entry: + %v = call i32(...) @llvm.experimental.deoptimize.i32() [ "deopt"(i32 0, i32 addrspace(1)* %ptr) ] + ret i32 %v +} + + +define i32 @caller_1(i32 addrspace(1)* %ptr) gc "statepoint-example" { +; CHECK-LABEL: @caller_1 +; CHECK: @llvm.experimental.gc.statepoint.p0f_isVoidi32p1i32f(i64 2882400000, i32 0, void (i32, i32 addrspace(1)*)* bitcast (void ()* @__llvm_deoptimize to void (i32, i32 addrspace(1)*)*), i32 2, i32 0, i32 50, i32 addrspace(1)* %ptr +; CHECK: unreachable +entry: + %v = call i32(...) @llvm.experimental.deoptimize.i32(i32 50, i32 addrspace(1)* %ptr) [ "deopt"(i32 0) ] + ret i32 %v +} + +define void @caller_2(i32 addrspace(1)* %ptr) gc "statepoint-example" { +; CHECK-LABEL: @caller_2( +; CHECK: @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* @__llvm_deoptimize, i32 0 +; CHECK: unreachable +entry: + call void(...) @llvm.experimental.deoptimize.isVoid() [ "deopt"(i32 0, i32 addrspace(1)* %ptr) ] + ret void +} diff --git a/test/Transforms/RewriteStatepointsForGC/deref-pointers.ll b/test/Transforms/RewriteStatepointsForGC/deref-pointers.ll index b4954f6a9b60..551da0843ad0 100644 --- a/test/Transforms/RewriteStatepointsForGC/deref-pointers.ll +++ b/test/Transforms/RewriteStatepointsForGC/deref-pointers.ll @@ -1,114 +1,104 @@ ; RUN: opt -S -rewrite-statepoints-for-gc < %s | FileCheck %s -declare void @foo() -declare i8 addrspace(1)* @some_function() -declare void @some_function_consumer(i8 addrspace(1)*) -declare dereferenceable(4) i8 addrspace(1)* @some_function_ret_deref() ; CHECK: declare i8 addrspace(1)* @some_function_ret_deref() -declare noalias i8 addrspace(1)* @some_function_ret_noalias() -; CHECK: declare i8 addrspace(1)* @some_function_ret_noalias() +; CHECK: define i8 addrspace(1)* @test_deref_arg(i8 addrspace(1)* %a) +; CHECK: define i8 addrspace(1)* @test_deref_or_null_arg(i8 addrspace(1)* %a) +; CHECK: define i8 addrspace(1)* @test_noalias_arg(i8 addrspace(1)* %a) + +declare void @foo() + +declare i8 addrspace(1)* @some_function() "gc-leaf-function" + +declare void @some_function_consumer(i8 addrspace(1)*) "gc-leaf-function" + +declare dereferenceable(4) i8 addrspace(1)* @some_function_ret_deref() "gc-leaf-function" +declare noalias i8 addrspace(1)* @some_function_ret_noalias() "gc-leaf-function" define i8 addrspace(1)* @test_deref_arg(i8 addrspace(1)* dereferenceable(4) %a) gc "statepoint-example" { -; CHECK: define i8 addrspace(1)* @test_deref_arg(i8 addrspace(1)* %a) entry: - 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) + call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ] ret i8 addrspace(1)* %a } define i8 addrspace(1)* @test_deref_or_null_arg(i8 addrspace(1)* dereferenceable_or_null(4) %a) gc "statepoint-example" { -; CHECK: define i8 addrspace(1)* @test_deref_or_null_arg(i8 addrspace(1)* %a) entry: - 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) + call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ] + ret i8 addrspace(1)* %a +} + +define i8 addrspace(1)* @test_noalias_arg(i8 addrspace(1)* noalias %a) gc "statepoint-example" { +entry: + call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ] ret i8 addrspace(1)* %a } define i8 addrspace(1)* @test_deref_retval() gc "statepoint-example" { ; CHECK-LABEL: @test_deref_retval( +; CHECK: %a = call i8 addrspace(1)* @some_function() entry: %a = call dereferenceable(4) i8 addrspace(1)* @some_function() -; CHECK: %a = call i8 addrspace(1)* @some_function() - 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) + call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ] ret i8 addrspace(1)* %a } define i8 addrspace(1)* @test_deref_or_null_retval() gc "statepoint-example" { ; CHECK-LABEL: @test_deref_or_null_retval( +; CHECK: %a = call i8 addrspace(1)* @some_function() entry: %a = call dereferenceable_or_null(4) i8 addrspace(1)* @some_function() + call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ] + ret i8 addrspace(1)* %a +} + +define i8 addrspace(1)* @test_noalias_retval() gc "statepoint-example" { +; CHECK-LABEL: @test_noalias_retval( ; CHECK: %a = call i8 addrspace(1)* @some_function() - 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) +entry: + %a = call noalias i8 addrspace(1)* @some_function() + call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ] ret i8 addrspace(1)* %a } define i8 @test_md(i8 addrspace(1)* %ptr) gc "statepoint-example" { ; CHECK-LABEL: @test_md( - entry: ; CHECK: %tmp = load i8, i8 addrspace(1)* %ptr, !tbaa !0 +entry: %tmp = load i8, i8 addrspace(1)* %ptr, !tbaa !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) + call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ] ret i8 %tmp } define i8 addrspace(1)* @test_decl_only_attribute(i8 addrspace(1)* %ptr) gc "statepoint-example" { ; CHECK-LABEL: @test_decl_only_attribute( -entry: ; No change here, but the prototype of some_function_ret_deref should have changed. ; CHECK: call i8 addrspace(1)* @some_function_ret_deref() - %a = call i8 addrspace(1)* @some_function_ret_deref() - 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)* %a -} - -define i8 addrspace(1)* @test_callsite_arg_attribute(i8 addrspace(1)* %ptr) gc "statepoint-example" { -; CHECK-LABEL: @test_callsite_arg_attribute( -entry: -; CHECK: call void @some_function_consumer(i8 addrspace(1)* %ptr) - call void @some_function_consumer(i8 addrspace(1)* dereferenceable(4) %ptr) - 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)* %ptr -} - -define i8 addrspace(1)* @test_noalias_arg(i8 addrspace(1)* noalias %a) gc "statepoint-example" { -; CHECK: define i8 addrspace(1)* @test_noalias_arg(i8 addrspace(1)* %a) entry: - 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)* %a -} - -define i8 addrspace(1)* @test_noalias_retval() gc "statepoint-example" { -; CHECK-LABEL: @test_noalias_retval( -entry: - %a = call noalias i8 addrspace(1)* @some_function() -; CHECK: %a = call i8 addrspace(1)* @some_function() - 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) + %a = call i8 addrspace(1)* @some_function_ret_deref() + call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ] ret i8 addrspace(1)* %a } define i8 addrspace(1)* @test_decl_only_noalias(i8 addrspace(1)* %ptr) gc "statepoint-example" { ; CHECK-LABEL: @test_decl_only_noalias( -entry: ; No change here, but the prototype of some_function_ret_noalias should have changed. ; CHECK: call i8 addrspace(1)* @some_function_ret_noalias() +entry: %a = call i8 addrspace(1)* @some_function_ret_noalias() - 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) + call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ] ret i8 addrspace(1)* %a } -define i8 addrspace(1)* @test_callsite_arg_noalias(i8 addrspace(1)* %ptr) gc "statepoint-example" { -; CHECK-LABEL: @test_callsite_arg_noalias( -entry: +define i8 addrspace(1)* @test_callsite_arg_attribute(i8 addrspace(1)* %ptr) gc "statepoint-example" { +; CHECK-LABEL: @test_callsite_arg_attribute( ; CHECK: call void @some_function_consumer(i8 addrspace(1)* %ptr) - call void @some_function_consumer(i8 addrspace(1)* noalias %ptr) - 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) +; CHECK: !0 = !{!1, !1, i64 0} +; CHECK: !1 = !{!"red", !2} +; CHECK: !2 = !{!"blue"} +entry: + call void @some_function_consumer(i8 addrspace(1)* dereferenceable(4) noalias %ptr) + call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ] ret i8 addrspace(1)* %ptr } - -declare token @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...) - !0 = !{!1, !1, i64 0, i64 1} !1 = !{!"red", !2} !2 = !{!"blue"} - -; CHECK: !0 = !{!1, !1, i64 0} -; CHECK: !1 = !{!"red", !2} -; CHECK: !2 = !{!"blue"} diff --git a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/gc-relocate-creation.ll b/test/Transforms/RewriteStatepointsForGC/gc-relocate-creation.ll index 0d53af704df2..714d7399c5b3 100644 --- a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/gc-relocate-creation.ll +++ b/test/Transforms/RewriteStatepointsForGC/gc-relocate-creation.ll @@ -1,4 +1,4 @@ -; RUN: opt %s -rewrite-statepoints-for-gc -rs4gc-use-deopt-bundles -S 2>&1 | FileCheck %s +; RUN: opt < %s -rewrite-statepoints-for-gc -S | FileCheck %s ; This test is to verify gc.relocate can handle pointer to vector of ; pointers (<2 x i32 addrspace(1)*> addrspace(1)* in this case). diff --git a/test/Transforms/RewriteStatepointsForGC/gc_relocate_creation.ll b/test/Transforms/RewriteStatepointsForGC/gc_relocate_creation.ll deleted file mode 100644 index 3cd4bc65d1a5..000000000000 --- a/test/Transforms/RewriteStatepointsForGC/gc_relocate_creation.ll +++ /dev/null @@ -1,20 +0,0 @@ -; RUN: opt %s -rewrite-statepoints-for-gc -S 2>&1 | FileCheck %s -; This test is to verify gc.relocate can handle pointer to vector of -; pointers (<2 x i32 addrspace(1)*> addrspace(1)* in this case). -; The old scheme to create a gc.relocate of <2 x i32 addrspace(1)*> addrspace(1)* -; type will fail because llvm does not support mangling vector of pointers. -; The new scheme will create all gc.relocate to i8 addrspace(1)* type and -; then bitcast to the correct type. - -declare void @foo() -declare void @use(...) -declare token @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...) - -define void @test1(<2 x i32 addrspace(1)*> addrspace(1)* %obj) gc "statepoint-example" { -entry: - %safepoint_token = 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 0) -; CHECK: %obj.relocated = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token %safepoint_token, i32 7, i32 7) -; CHECK-NEXT: %obj.relocated.casted = bitcast i8 addrspace(1)* %obj.relocated to <2 x i32 addrspace(1)*> addrspace(1)* - call void (...) @use(<2 x i32 addrspace(1)*> addrspace(1)* %obj) - ret void -} diff --git a/test/Transforms/RewriteStatepointsForGC/invokes.ll b/test/Transforms/RewriteStatepointsForGC/invokes.ll new file mode 100644 index 000000000000..afcb6ad559de --- /dev/null +++ b/test/Transforms/RewriteStatepointsForGC/invokes.ll @@ -0,0 +1,111 @@ +; RUN: opt < %s -S -rewrite-statepoints-for-gc | FileCheck %s + +declare i64 addrspace(1)* @some_call(i64 addrspace(1)*) +declare i32 @personality_function() + +define i64 addrspace(1)* @test_basic(i64 addrspace(1)* %obj, i64 addrspace(1)* %obj1) gc "statepoint-example" personality i32 ()* @personality_function { +; CHECK-LABEL: entry: +entry: + ; CHECK: invoke + ; CHECK: statepoint + ; CHECK: some_call + %ret_val = invoke i64 addrspace(1)* @some_call(i64 addrspace(1)* %obj) + to label %normal_return unwind label %exceptional_return + +; CHECK-LABEL: normal_return: +; CHECK: gc.result +; CHECK: ret i64 + +normal_return: + ret i64 addrspace(1)* %ret_val + +; CHECK-LABEL: exceptional_return: +; CHECK: landingpad +; CHECK: ret i64 + +exceptional_return: + %landing_pad4 = landingpad token + cleanup + ret i64 addrspace(1)* %obj1 +} + +define i64 addrspace(1)* @test_two_invokes(i64 addrspace(1)* %obj, i64 addrspace(1)* %obj1) gc "statepoint-example" personality i32 ()* @personality_function { +; CHECK-LABEL: entry: +entry: + ; CHECK: invoke + ; CHECK: statepoint + ; CHECK: some_call + %ret_val1 = invoke i64 addrspace(1)* @some_call(i64 addrspace(1)* %obj) + to label %second_invoke unwind label %exceptional_return + +; CHECK-LABEL: second_invoke: +second_invoke: + ; CHECK: invoke + ; CHECK: statepoint + ; CHECK: some_call + %ret_val2 = invoke i64 addrspace(1)* @some_call(i64 addrspace(1)* %ret_val1) + to label %normal_return unwind label %exceptional_return + +; CHECK-LABEL: normal_return: +normal_return: + ; CHECK: gc.result + ; CHECK: ret i64 + ret i64 addrspace(1)* %ret_val2 + +; CHECK: exceptional_return: +; CHECK: ret i64 + +exceptional_return: + %landing_pad4 = landingpad token + cleanup + ret i64 addrspace(1)* %obj1 +} + +define i64 addrspace(1)* @test_phi_node(i1 %cond, i64 addrspace(1)* %obj) gc "statepoint-example" personality i32 ()* @personality_function { +; CHECK-LABEL: @test_phi_node +; CHECK-LABEL: entry: +entry: + br i1 %cond, label %left, label %right + +left: + %ret_val_left = invoke i64 addrspace(1)* @some_call(i64 addrspace(1)* %obj) + to label %merge unwind label %exceptional_return + +right: + %ret_val_right = invoke i64 addrspace(1)* @some_call(i64 addrspace(1)* %obj) + to label %merge unwind label %exceptional_return + +; CHECK: merge[[A:[0-9]]]: +; CHECK: gc.result +; CHECK: br label %[[with_phi:merge[0-9]*]] + +; CHECK: merge[[B:[0-9]]]: +; CHECK: gc.result +; CHECK: br label %[[with_phi]] + +; CHECK: [[with_phi]]: +; CHECK: phi +; CHECK: ret i64 addrspace(1)* %ret_val +merge: + %ret_val = phi i64 addrspace(1)* [%ret_val_left, %left], [%ret_val_right, %right] + ret i64 addrspace(1)* %ret_val + +; CHECK-LABEL: exceptional_return: +; CHECK: ret i64 addrspace(1)* + +exceptional_return: + %landing_pad4 = landingpad token + cleanup + ret i64 addrspace(1)* %obj +} + +declare void @do_safepoint() +define void @gc.safepoint_poll() { +; CHECK-LABEL: gc.safepoint_poll +; CHECK-LABEL: entry +; CHECK-NEXT: do_safepoint +; CHECK-NEXT: ret void +entry: + call void @do_safepoint() + ret void +} diff --git a/test/Transforms/RewriteStatepointsForGC/leaf-function.ll b/test/Transforms/RewriteStatepointsForGC/leaf-function.ll new file mode 100644 index 000000000000..e2350d4f9e0a --- /dev/null +++ b/test/Transforms/RewriteStatepointsForGC/leaf-function.ll @@ -0,0 +1,33 @@ +; RUN: opt < %s -S -rewrite-statepoints-for-gc | FileCheck %s + +declare void @foo() "gc-leaf-function" +declare void @bar() + +; Calls of functions with the "gc-leaf-function" attribute shouldn't be turned +; into a safepoint. An entry safepoint should get inserted, though. +define void @test_leaf_function() gc "statepoint-example" { +; CHECK-LABEL: test_leaf_function +; CHECK-NOT: gc.statepoint +; CHECK-NOT: gc.result +entry: + call void @foo() + ret void +} + +define void @test_leaf_function_call() gc "statepoint-example" { +; CHECK-LABEL: test_leaf_function_call +; CHECK-NOT: gc.statepoint +; CHECK-NOT: gc.result +entry: + call void @bar() "gc-leaf-function" + ret void +} + +; 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 +} diff --git a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/live-vector-nosplit.ll b/test/Transforms/RewriteStatepointsForGC/live-vector-nosplit.ll index ee578eb3d309..cc0140a97c5d 100644 --- a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/live-vector-nosplit.ll +++ b/test/Transforms/RewriteStatepointsForGC/live-vector-nosplit.ll @@ -1,6 +1,6 @@ ; Test that we can correctly handle vectors of pointers in statepoint ; rewriting. -; RUN: opt %s -rewrite-statepoints-for-gc -rs4gc-use-deopt-bundles -rs4gc-split-vector-values=0 -S | FileCheck %s +; RUN: opt < %s -rewrite-statepoints-for-gc -S | FileCheck %s ; A non-vector relocation for comparison define i64 addrspace(1)* @test(i64 addrspace(1)* %obj) gc "statepoint-example" { @@ -73,9 +73,12 @@ exceptional_return: ; preds = %entry define <2 x i64 addrspace(1)*> @test5(i64 addrspace(1)* %p) gc "statepoint-example" { ; CHECK-LABEL: test5 ; CHECK: insertelement +; CHECK-NEXT: insertelement ; CHECK-NEXT: gc.statepoint ; CHECK-NEXT: gc.relocate ; CHECK-NEXT: bitcast +; CHECK-NEXT: gc.relocate +; CHECK-NEXT: bitcast ; CHECK-NEXT: ret <2 x i64 addrspace(1)*> %vec.relocated.casted entry: %vec = insertelement <2 x i64 addrspace(1)*> undef, i64 addrspace(1)* %p, i32 0 @@ -100,9 +103,12 @@ untaken: ; preds = %entry merge: ; preds = %untaken, %taken ; CHECK-LABEL: merge: ; CHECK-NEXT: = phi +; CHECK-NEXT: = phi ; CHECK-NEXT: gc.statepoint ; CHECK-NEXT: gc.relocate ; CHECK-NEXT: bitcast +; CHECK-NEXT: gc.relocate +; CHECK-NEXT: bitcast ; CHECK-NEXT: ret <2 x i64 addrspace(1)*> %obj = phi <2 x i64 addrspace(1)*> [ %obja, %taken ], [ %objb, %untaken ] call void @do_safepoint() [ "deopt"() ] diff --git a/test/Transforms/RewriteStatepointsForGC/live-vector.ll b/test/Transforms/RewriteStatepointsForGC/live-vector.ll deleted file mode 100644 index 2ec09d6acae6..000000000000 --- a/test/Transforms/RewriteStatepointsForGC/live-vector.ll +++ /dev/null @@ -1,152 +0,0 @@ -; Test that we can correctly handle vectors of pointers in statepoint -; rewriting. Currently, we scalarize, but that's an implementation detail. -; RUN: opt %s -rewrite-statepoints-for-gc -rs4gc-split-vector-values -S | FileCheck %s - -; A non-vector relocation for comparison -define i64 addrspace(1)* @test(i64 addrspace(1)* %obj) gc "statepoint-example" { -; CHECK-LABEL: test -; CHECK: gc.statepoint -; CHECK-NEXT: gc.relocate -; CHECK-NEXT: bitcast -; CHECK-NEXT: ret i64 addrspace(1)* %obj.relocated.casted -entry: - %safepoint_token = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0) - ret i64 addrspace(1)* %obj -} - -; A base vector from a argument -define <2 x i64 addrspace(1)*> @test2(<2 x i64 addrspace(1)*> %obj) gc "statepoint-example" { -; CHECK-LABEL: test2 -; CHECK: extractelement -; CHECK-NEXT: extractelement -; CHECK-NEXT: gc.statepoint -; CHECK-NEXT: gc.relocate -; CHECK-NEXT: bitcast -; CHECK-NEXT: gc.relocate -; CHECK-NEXT: bitcast -; CHECK-NEXT: insertelement -; CHECK-NEXT: insertelement -; CHECK-NEXT: ret <2 x i64 addrspace(1)*> %7 -entry: - %safepoint_token = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0) - ret <2 x i64 addrspace(1)*> %obj -} - -; A base vector from a load -define <2 x i64 addrspace(1)*> @test3(<2 x i64 addrspace(1)*>* %ptr) gc "statepoint-example" { -; CHECK-LABEL: test3 -; CHECK: load -; CHECK-NEXT: extractelement -; CHECK-NEXT: extractelement -; CHECK-NEXT: gc.statepoint -; CHECK-NEXT: gc.relocate -; CHECK-NEXT: bitcast -; CHECK-NEXT: gc.relocate -; CHECK-NEXT: bitcast -; CHECK-NEXT: insertelement -; CHECK-NEXT: insertelement -; CHECK-NEXT: ret <2 x i64 addrspace(1)*> %7 -entry: - %obj = load <2 x i64 addrspace(1)*>, <2 x i64 addrspace(1)*>* %ptr - %safepoint_token = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0) - ret <2 x i64 addrspace(1)*> %obj -} - -declare i32 @fake_personality_function() - -; When a statepoint is an invoke rather than a call -define <2 x i64 addrspace(1)*> @test4(<2 x i64 addrspace(1)*>* %ptr) gc "statepoint-example" personality i32 ()* @fake_personality_function { -; CHECK-LABEL: test4 -; CHECK: load -; CHECK-NEXT: extractelement -; CHECK-NEXT: extractelement -; CHECK-NEXT: gc.statepoint -entry: - %obj = load <2 x i64 addrspace(1)*>, <2 x i64 addrspace(1)*>* %ptr - invoke token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0) - to label %normal_return unwind label %exceptional_return - -; CHECK-LABEL: normal_return: -; CHECK: gc.relocate -; CHECK-NEXT: bitcast -; CHECK-NEXT: gc.relocate -; CHECK-NEXT: bitcast -; CHECK-NEXT: insertelement -; CHECK-NEXT: insertelement -; CHECK-NEXT: ret <2 x i64 addrspace(1)*> %8 -normal_return: ; preds = %entry - ret <2 x i64 addrspace(1)*> %obj - -; CHECK-LABEL: exceptional_return: -; CHECK: gc.relocate -; CHECK-NEXT: bitcast -; CHECK-NEXT: gc.relocate -; CHECK-NEXT: bitcast -; CHECK-NEXT: insertelement -; CHECK-NEXT: insertelement -; CHECK-NEXT: ret <2 x i64 addrspace(1)*> %14 -exceptional_return: ; preds = %entry - %landing_pad4 = landingpad token - cleanup - ret <2 x i64 addrspace(1)*> %obj -} - -; Can we handle an insert element with a constant offset? This effectively -; tests both the equal and inequal case since we have to relocate both indices -; in the vector. -define <2 x i64 addrspace(1)*> @test5(i64 addrspace(1)* %p) - gc "statepoint-example" { -; CHECK-LABEL: test5 -; CHECK: insertelement -; CHECK-NEXT: extractelement -; CHECK-NEXT: extractelement -; CHECK-NEXT: gc.statepoint -; CHECK-NEXT: gc.relocate -; CHECK-NEXT: bitcast -; CHECK-NEXT: gc.relocate -; CHECK-NEXT: bitcast -; CHECK-NEXT: insertelement -; CHECK-NEXT: insertelement -; CHECK-NEXT: ret <2 x i64 addrspace(1)*> %7 -entry: - %vec = insertelement <2 x i64 addrspace(1)*> undef, i64 addrspace(1)* %p, i32 0 - %safepoint_token = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0) - ret <2 x i64 addrspace(1)*> %vec -} - - -; A base vector from a load -define <2 x i64 addrspace(1)*> @test6(i1 %cnd, <2 x i64 addrspace(1)*>* %ptr) - gc "statepoint-example" { -; CHECK-LABEL: test6 -; CHECK-LABEL: merge: -; CHECK-NEXT: = phi -; CHECK-NEXT: extractelement -; CHECK-NEXT: extractelement -; CHECK-NEXT: gc.statepoint -; CHECK-NEXT: gc.relocate -; CHECK-NEXT: bitcast -; CHECK-NEXT: gc.relocate -; CHECK-NEXT: bitcast -; CHECK-NEXT: insertelement -; CHECK-NEXT: insertelement -; CHECK-NEXT: ret <2 x i64 addrspace(1)*> -entry: - br i1 %cnd, label %taken, label %untaken -taken: - %obja = load <2 x i64 addrspace(1)*>, <2 x i64 addrspace(1)*>* %ptr - br label %merge -untaken: - %objb = load <2 x i64 addrspace(1)*>, <2 x i64 addrspace(1)*>* %ptr - br label %merge - -merge: - %obj = phi <2 x i64 addrspace(1)*> [%obja, %taken], [%objb, %untaken] - %safepoint_token = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0) - ret <2 x i64 addrspace(1)*> %obj -} - - -declare void @do_safepoint() - -declare token @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...) diff --git a/test/Transforms/RewriteStatepointsForGC/liveness-basics.ll b/test/Transforms/RewriteStatepointsForGC/liveness-basics.ll index 207003c17b5f..9c848e52faf9 100644 --- a/test/Transforms/RewriteStatepointsForGC/liveness-basics.ll +++ b/test/Transforms/RewriteStatepointsForGC/liveness-basics.ll @@ -2,73 +2,72 @@ ; correct live values at statepoints ; RUN: opt -rewrite-statepoints-for-gc -spp-rematerialization-threshold=0 -S < %s | FileCheck %s - ; Tests to make sure we consider %obj live in both the taken and untaken ; predeccessor of merge. + define i64 addrspace(1)* @test1(i1 %cmp, i64 addrspace(1)* %obj) gc "statepoint-example" { ; CHECK-LABEL: @test1 entry: br i1 %cmp, label %taken, label %untaken -taken: +taken: ; preds = %entry ; CHECK-LABEL: taken: ; CHECK-NEXT: gc.statepoint ; CHECK-NEXT: %obj.relocated = call coldcc i8 addrspace(1)* ; CHECK-NEXT: bitcast ; CHECK-NEXT: br label %merge - 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 0) + call void @foo() [ "deopt"() ] br label %merge -untaken: +untaken: ; preds = %entry ; CHECK-LABEL: untaken: ; CHECK-NEXT: gc.statepoint -; CHECK-NEXT: %obj.relocated1 = call coldcc i8 addrspace(1)* +; CHECK-NEXT: %obj.relocated2 = call coldcc i8 addrspace(1)* ; CHECK-NEXT: bitcast ; CHECK-NEXT: br label %merge - 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 0) + call void @foo() [ "deopt"() ] br label %merge -merge: +merge: ; preds = %untaken, %taken ; CHECK-LABEL: merge: -; CHECK-NEXT: %.0 = phi i64 addrspace(1)* [ %obj.relocated.casted, %taken ], [ %obj.relocated1.casted, %untaken ] +; CHECK-NEXT: %.0 = phi i64 addrspace(1)* [ %obj.relocated.casted, %taken ], [ %obj.relocated2.casted, %untaken ] ; CHECK-NEXT: ret i64 addrspace(1)* %.0 +; A local kill should not effect liveness in predecessor block ret i64 addrspace(1)* %obj } -; A local kill should not effect liveness in predecessor block define i64 addrspace(1)* @test2(i1 %cmp, i64 addrspace(1)** %loc) gc "statepoint-example" { ; CHECK-LABEL: @test2 entry: ; CHECK-LABEL: entry: ; CHECK-NEXT: gc.statepoint ; CHECK-NEXT: br - 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 0) + call void @foo() [ "deopt"() ] br i1 %cmp, label %taken, label %untaken -taken: +taken: ; preds = %entry ; CHECK-LABEL: taken: ; CHECK-NEXT: %obj = load ; CHECK-NEXT: gc.statepoint ; CHECK-NEXT: gc.relocate ; CHECK-NEXT: bitcast ; CHECK-NEXT: ret i64 addrspace(1)* %obj.relocated.casted - +; A local kill should effect values live from a successor phi. Also, we +; should only propagate liveness from a phi to the appropriate predecessors. %obj = load i64 addrspace(1)*, i64 addrspace(1)** %loc - 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 0) + call void @foo() [ "deopt"() ] ret i64 addrspace(1)* %obj -untaken: +untaken: ; preds = %entry ret i64 addrspace(1)* null } -; A local kill should effect values live from a successor phi. Also, we -; should only propagate liveness from a phi to the appropriate predecessors. define i64 addrspace(1)* @test3(i1 %cmp, i64 addrspace(1)** %loc) gc "statepoint-example" { ; CHECK-LABEL: @test3 entry: br i1 %cmp, label %taken, label %untaken -taken: +taken: ; preds = %entry ; CHECK-LABEL: taken: ; CHECK-NEXT: gc.statepoint ; CHECK-NEXT: %obj = load @@ -76,25 +75,25 @@ taken: ; CHECK-NEXT: %obj.relocated = call coldcc i8 addrspace(1)* ; CHECK-NEXT: bitcast ; CHECK-NEXT: br label %merge - 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 0) + call void @foo() [ "deopt"() ] %obj = load i64 addrspace(1)*, i64 addrspace(1)** %loc - 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 0) + call void @foo() [ "deopt"() ] br label %merge -untaken: +untaken: ; preds = %entry ; CHECK-LABEL: taken: ; CHECK-NEXT: gc.statepoint ; CHECK-NEXT: br label %merge - 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 0) +; A base pointer must be live if it is needed at a later statepoint, +; even if the base pointer is otherwise unused. + call void @foo() [ "deopt"() ] br label %merge -merge: +merge: ; preds = %untaken, %taken %phi = phi i64 addrspace(1)* [ %obj, %taken ], [ null, %untaken ] ret i64 addrspace(1)* %phi } -; A base pointer must be live if it is needed at a later statepoint, -; even if the base pointer is otherwise unused. define i64 addrspace(1)* @test4(i1 %cmp, i64 addrspace(1)* %obj) gc "statepoint-example" { ; CHECK-LABEL: @test4 entry: @@ -106,54 +105,55 @@ entry: ; CHECK-NEXT: %obj.relocated = ; CHECK-NEXT: bitcast ; CHECK-NEXT: gc.statepoint -; CHECK-NEXT: %derived.relocated1 = +; CHECK-NEXT: %derived.relocated2 = ; CHECK-NEXT: bitcast + ; Note: It's legal to relocate obj again, but not strictly needed -; CHECK-NEXT: %obj.relocated2 = +; CHECK-NEXT: %obj.relocated3 = ; CHECK-NEXT: bitcast -; CHECK-NEXT: ret i64 addrspace(1)* %derived.relocated1.casted +; CHECK-NEXT: ret i64 addrspace(1)* %derived.relocated2.casted ; +; Make sure that a phi def visited during iteration is considered a kill. +; Also, liveness after base pointer analysis can change based on new uses, +; not just new defs. %derived = getelementptr i64, i64 addrspace(1)* %obj, i64 8 - 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 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 0) + call void @foo() [ "deopt"() ] + call void @foo() [ "deopt"() ] ret i64 addrspace(1)* %derived } -declare void @consume(...) readonly +declare void @consume(...) readonly "gc-leaf-function" -; Make sure that a phi def visited during iteration is considered a kill. -; Also, liveness after base pointer analysis can change based on new uses, -; not just new defs. define i64 addrspace(1)* @test5(i1 %cmp, i64 addrspace(1)* %obj) gc "statepoint-example" { ; CHECK-LABEL: @test5 entry: br i1 %cmp, label %taken, label %untaken -taken: +taken: ; preds = %entry ; CHECK-LABEL: taken: ; CHECK-NEXT: gc.statepoint ; CHECK-NEXT: %obj.relocated = call coldcc i8 addrspace(1)* ; CHECK-NEXT: bitcast ; CHECK-NEXT: br label %merge - 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 0) + call void @foo() [ "deopt"() ] br label %merge -untaken: +untaken: ; preds = %entry ; CHECK-LABEL: untaken: ; CHECK-NEXT: br label %merge br label %merge -merge: +merge: ; preds = %untaken, %taken ; CHECK-LABEL: merge: ; CHECK-NEXT: %.0 = phi i64 addrspace(1)* ; CHECK-NEXT: %obj2a = phi ; CHECK-NEXT: @consume ; CHECK-NEXT: br label %final - %obj2a = phi i64 addrspace(1)* [ %obj, %taken ], [null, %untaken] + %obj2a = phi i64 addrspace(1)* [ %obj, %taken ], [ null, %untaken ] call void (...) @consume(i64 addrspace(1)* %obj2a) br label %final -final: + +final: ; preds = %merge ; CHECK-LABEL: final: ; CHECK-NEXT: @consume ; CHECK-NEXT: ret i64 addrspace(1)* %.0 @@ -163,4 +163,3 @@ final: declare void @foo() -declare token @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...) diff --git a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/patchable-statepoints.ll b/test/Transforms/RewriteStatepointsForGC/patchable-statepoints.ll index 8f5c0ff4a710..924620a64678 100644 --- a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/patchable-statepoints.ll +++ b/test/Transforms/RewriteStatepointsForGC/patchable-statepoints.ll @@ -1,4 +1,4 @@ -; RUN: opt -S -rewrite-statepoints-for-gc -rs4gc-use-deopt-bundles < %s | FileCheck %s +; RUN: opt -S -rewrite-statepoints-for-gc < %s | FileCheck %s declare void @f() declare i32 @personality_function() diff --git a/test/Transforms/RewriteStatepointsForGC/preprocess.ll b/test/Transforms/RewriteStatepointsForGC/preprocess.ll index e1657497485b..df42eb14cfd6 100644 --- a/test/Transforms/RewriteStatepointsForGC/preprocess.ll +++ b/test/Transforms/RewriteStatepointsForGC/preprocess.ll @@ -1,65 +1,62 @@ ; RUN: opt -rewrite-statepoints-for-gc -S < %s | FileCheck %s -declare void @consume(...) - ; Test to make sure we destroy LCSSA's single entry phi nodes before ; running liveness + +declare void @consume(...) "gc-leaf-function" + define void @test6(i64 addrspace(1)* %obj) gc "statepoint-example" { ; CHECK-LABEL: @test6 entry: br label %next -next: +next: ; preds = %entry ; CHECK-LABEL: next: ; CHECK-NEXT: gc.statepoint ; CHECK-NEXT: gc.relocate ; CHECK-NEXT: bitcast ; CHECK-NEXT: @consume(i64 addrspace(1)* %obj.relocated.casted) ; CHECK-NEXT: @consume(i64 addrspace(1)* %obj.relocated.casted) +; Need to delete unreachable gc.statepoint call %obj2 = phi i64 addrspace(1)* [ %obj, %entry ] - 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 0) + call void @foo() [ "deopt"() ] call void (...) @consume(i64 addrspace(1)* %obj2) call void (...) @consume(i64 addrspace(1)* %obj) ret void } -declare void @some_call(i64 addrspace(1)*) - -; Need to delete unreachable gc.statepoint call define void @test7() gc "statepoint-example" { ; CHECK-LABEL: test7 ; CHECK-NOT: gc.statepoint +; Need to delete unreachable gc.statepoint invoke - tested seperately given +; a correct implementation could only remove the instructions, not the block ret void -unreached: - %obj = phi i64 addrspace(1)* [null, %unreached] - 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 0) +unreached: ; preds = %unreached + %obj = phi i64 addrspace(1)* [ null, %unreached ] + call void @foo() [ "deopt"() ] call void (...) @consume(i64 addrspace(1)* %obj) br label %unreached } -; Need to delete unreachable gc.statepoint invoke - tested seperately given -; a correct implementation could only remove the instructions, not the block define void @test8() gc "statepoint-example" personality i32 ()* undef { ; CHECK-LABEL: test8 ; CHECK-NOT: gc.statepoint +; Bound the last check-not ret void -unreached: - invoke 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 0) +unreached: ; No predecessors! + invoke void @foo() [ "deopt"() ] +; CHECK-LABEL: @foo to label %normal_return unwind label %exceptional_return -normal_return: ; preds = %entry +normal_return: ; preds = %unreached ret void -exceptional_return: ; preds = %entry +exceptional_return: ; preds = %unreached %landing_pad4 = landingpad { i8*, i32 } cleanup ret void } declare void @foo() -; Bound the last check-not -; CHECK-LABEL: @foo - -declare token @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...) diff --git a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/relocate-invoke-result.ll b/test/Transforms/RewriteStatepointsForGC/relocate-invoke-result.ll index 688cf36168d4..b96ec3e3962d 100644 --- a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/relocate-invoke-result.ll +++ b/test/Transforms/RewriteStatepointsForGC/relocate-invoke-result.ll @@ -1,5 +1,5 @@ -;; RUN: opt -rewrite-statepoints-for-gc -rs4gc-use-deopt-bundles -verify -S < %s | FileCheck %s +;; RUN: opt -rewrite-statepoints-for-gc -verify -S < %s | FileCheck %s ;; This test is to verify that RewriteStatepointsForGC correctly relocates values ;; defined by invoke instruction results. diff --git a/test/Transforms/RewriteStatepointsForGC/relocate_invoke_result.ll b/test/Transforms/RewriteStatepointsForGC/relocate_invoke_result.ll deleted file mode 100644 index d11441e9346f..000000000000 --- a/test/Transforms/RewriteStatepointsForGC/relocate_invoke_result.ll +++ /dev/null @@ -1,33 +0,0 @@ -;; RUN: opt -rewrite-statepoints-for-gc -verify -S < %s | FileCheck %s - -;; This test is to verify that RewriteStatepointsForGC correctly relocates values -;; defined by invoke instruction results. - -declare i64* addrspace(1)* @non_gc_call() - -declare void @gc_call() - -declare i32* @fake_personality_function() - -; Function Attrs: nounwind -define i64* addrspace(1)* @test() gc "statepoint-example" personality i32* ()* @fake_personality_function { -entry: - %obj = invoke i64* addrspace(1)* @non_gc_call() - to label %normal_dest unwind label %unwind_dest - -unwind_dest: - %lpad = landingpad { i8*, i32 } - cleanup - resume { i8*, i32 } undef - -normal_dest: -;; CHECK-LABEL: normal_dest: -;; CHECK-NEXT: gc.statepoint -;; CHECK-NEXT: %obj.relocated = call coldcc i8 addrspace(1)* -;; CHECK-NEXT: bitcast - %safepoint_token = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @gc_call, i32 0, i32 0, i32 0, i32 5, i32 0, i32 -1, i32 0, i32 0, i32 0) - ret i64* addrspace(1)* %obj -} - -declare token @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...) - diff --git a/test/Transforms/RewriteStatepointsForGC/relocation.ll b/test/Transforms/RewriteStatepointsForGC/relocation.ll index deea377c5a28..eaa826c52dc2 100644 --- a/test/Transforms/RewriteStatepointsForGC/relocation.ll +++ b/test/Transforms/RewriteStatepointsForGC/relocation.ll @@ -1,27 +1,28 @@ -; RUN: opt %s -rewrite-statepoints-for-gc -spp-rematerialization-threshold=0 -S 2>&1 | FileCheck %s +; RUN: opt < %s -rewrite-statepoints-for-gc -spp-rematerialization-threshold=0 -S | FileCheck %s declare void @foo() -declare void @use(...) + +declare void @use(...) "gc-leaf-function" define i64 addrspace(1)* @test1(i64 addrspace(1)* %obj, i64 addrspace(1)* %obj2, i1 %condition) gc "statepoint-example" { -entry: ; CHECK-LABEL: @test1 ; CHECK-DAG: %obj.relocated ; CHECK-DAG: %obj2.relocated - %safepoint_token = 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 0) +entry: + call void @foo() [ "deopt"() ] br label %joint -joint: +joint: ; preds = %joint2, %entry ; CHECK-LABEL: joint: ; CHECK: %phi1 = phi i64 addrspace(1)* [ %obj.relocated.casted, %entry ], [ %obj3, %joint2 ] %phi1 = phi i64 addrspace(1)* [ %obj, %entry ], [ %obj3, %joint2 ] br i1 %condition, label %use, label %joint2 -use: +use: ; preds = %joint br label %joint2 -joint2: +joint2: ; preds = %use, %joint ; CHECK-LABEL: joint2: ; CHECK: %phi2 = phi i64 addrspace(1)* [ %obj.relocated.casted, %use ], [ %obj2.relocated.casted, %joint ] ; CHECK: %obj3 = getelementptr i64, i64 addrspace(1)* %obj2.relocated.casted, i32 1 @@ -30,11 +31,11 @@ joint2: br label %joint } -declare i64 addrspace(1)* @generate_obj() +declare i64 addrspace(1)* @generate_obj() "gc-leaf-function" -declare void @consume_obj(i64 addrspace(1)*) +declare void @consume_obj(i64 addrspace(1)*) "gc-leaf-function" -declare i1 @rt() +declare i1 @rt() "gc-leaf-function" define void @test2() gc "statepoint-example" { ; CHECK-LABEL: @test2 @@ -43,60 +44,61 @@ entry: %obj = getelementptr i64, i64 addrspace(1)* %obj_init, i32 42 br label %loop -loop: +loop: ; preds = %loop.backedge, %entry ; CHECK: loop: ; CHECK-DAG: [ %obj_init.relocated.casted, %loop.backedge ] ; CHECK-DAG: [ %obj_init, %entry ] ; CHECK-DAG: [ %obj.relocated.casted, %loop.backedge ] ; CHECK-DAG: [ %obj, %entry ] - %index = phi i32 [ 0, %entry ], [ %index.inc, %loop.backedge ] ; CHECK-NOT: %location = getelementptr i64, i64 addrspace(1)* %obj, i32 %index + %index = phi i32 [ 0, %entry ], [ %index.inc, %loop.backedge ] %location = getelementptr i64, i64 addrspace(1)* %obj, i32 %index call void @consume_obj(i64 addrspace(1)* %location) %index.inc = add i32 %index, 1 %condition = call i1 @rt() br i1 %condition, label %loop_x, label %loop_y -loop_x: +loop_x: ; preds = %loop br label %loop.backedge -loop.backedge: - %safepoint_token = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0) +loop.backedge: ; preds = %loop_y, %loop_x + call void @do_safepoint() [ "deopt"() ] br label %loop -loop_y: +loop_y: ; preds = %loop br label %loop.backedge } -declare void @some_call(i8 addrspace(1)*) +declare void @some_call(i8 addrspace(1)*) "gc-leaf-function" define void @relocate_merge(i1 %cnd, i8 addrspace(1)* %arg) gc "statepoint-example" { ; CHECK-LABEL: @relocate_merge + bci_0: br i1 %cnd, label %if_branch, label %else_branch -if_branch: +if_branch: ; preds = %bci_0 ; CHECK-LABEL: if_branch: ; CHECK: gc.statepoint ; CHECK: gc.relocate - %safepoint_token = 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 0) + call void @foo() [ "deopt"() ] br label %join -else_branch: +else_branch: ; preds = %bci_0 ; CHECK-LABEL: else_branch: ; CHECK: gc.statepoint ; CHECK: gc.relocate - %safepoint_token1 = 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 0) +; We need to end up with a single relocation phi updated from both paths + call void @foo() [ "deopt"() ] br label %join -join: -; We need to end up with a single relocation phi updated from both paths +join: ; preds = %else_branch, %if_branch ; CHECK-LABEL: join: ; CHECK: phi i8 addrspace(1)* ; CHECK-DAG: [ %arg.relocated, %if_branch ] -; CHECK-DAG: [ %arg.relocated4, %else_branch ] +; CHECK-DAG: [ %arg.relocated2, %else_branch ] ; CHECK-NOT: phi - call void (i8 addrspace(1)*) @some_call(i8 addrspace(1)* %arg) + call void @some_call(i8 addrspace(1)* %arg) ret void } @@ -104,14 +106,14 @@ join: ; This is basically just making sure that statepoints aren't accidentally ; treated specially. define void @test3(i64 addrspace(1)* %obj) gc "statepoint-example" { -entry: ; CHECK-LABEL: @test3 ; CHECK: gc.statepoint ; CHECK-NEXT: gc.relocate ; CHECK-NEXT: bitcast ; CHECK-NEXT: gc.statepoint - %safepoint_token = call token (i64, i32, void (i64)*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidi64f(i64 0, i32 0, void (i64)* undef, i32 1, i32 0, i64 undef, i32 0, i32 5, i32 0, i32 -1, i32 0, i32 0, i32 0) - %safepoint_token1 = call token (i64, i32, i32 (i64 addrspace(1)*)*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_i32p1i64f(i64 0, i32 0, i32 (i64 addrspace(1)*)* undef, i32 1, i32 0, i64 addrspace(1)* %obj, i32 0, i32 5, i32 0, i32 -1, i32 0, i32 0, i32 0) +entry: + call void undef(i64 undef) [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ] + %0 = call i32 undef(i64 addrspace(1)* %obj) [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ] ret void } @@ -122,30 +124,28 @@ define void @test4() gc "statepoint-example" { ; CHECK: gc.statepoint ; CHECK: gc.result ; CHECK: gc.statepoint -; CHECK: gc.relocate -; CHECK: @use(i8 addrspace(1)* %res.relocated) - %safepoint_token2 = tail call token (i64, i32, i8 addrspace(1)* ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_p1i8f(i64 0, i32 0, i8 addrspace(1)* ()* undef, i32 0, i32 0, i32 0, i32 0) - %res = call i8 addrspace(1)* @llvm.experimental.gc.result.p1i8(token %safepoint_token2) - call token (i64, i32, i8 addrspace(1)* ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_p1i8f(i64 0, i32 0, i8 addrspace(1)* ()* undef, i32 0, i32 0, i32 0, i32 0) - call void (...) @use(i8 addrspace(1)* %res) +; CHECK: [[RELOCATED:%[^ ]+]] = call {{.*}}gc.relocate +; CHECK: @use(i8 addrspace(1)* [[RELOCATED]]) + %1 = call i8 addrspace(1)* undef() [ "deopt"() ] + %2 = call i8 addrspace(1)* undef() [ "deopt"() ] + call void (...) @use(i8 addrspace(1)* %1) unreachable } - ; Test updating a phi where not all inputs are live to begin with define void @test5(i8 addrspace(1)* %arg) gc "statepoint-example" { ; CHECK-LABEL: test5 entry: - call token (i64, i32, i8 addrspace(1)* ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_p1i8f(i64 0, i32 0, i8 addrspace(1)* ()* undef, i32 0, i32 0, i32 0, i32 0) + %0 = call i8 addrspace(1)* undef() [ "deopt"() ] switch i32 undef, label %kill [ i32 10, label %merge i32 13, label %merge ] -kill: +kill: ; preds = %entry br label %merge -merge: +merge: ; preds = %kill, %entry, %entry ; CHECK: merge: ; CHECK: %test = phi i8 addrspace(1) ; CHECK-DAG: [ null, %kill ] @@ -156,24 +156,22 @@ merge: unreachable } - ; Check to make sure we handle values live over an entry statepoint -define void @test6(i8 addrspace(1)* %arg1, i8 addrspace(1)* %arg2, - i8 addrspace(1)* %arg3) gc "statepoint-example" { +define void @test6(i8 addrspace(1)* %arg1, i8 addrspace(1)* %arg2, i8 addrspace(1)* %arg3) gc "statepoint-example" { ; CHECK-LABEL: @test6 entry: br i1 undef, label %gc.safepoint_poll.exit2, label %do_safepoint -do_safepoint: +do_safepoint: ; preds = %entry ; CHECK-LABEL: do_safepoint: ; CHECK: gc.statepoint ; CHECK: arg1.relocated = ; CHECK: arg2.relocated = ; CHECK: arg3.relocated = - 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 3, i8 addrspace(1)* %arg1, i8 addrspace(1)* %arg2, i8 addrspace(1)* %arg3) + call void @foo() [ "deopt"(i8 addrspace(1)* %arg1, i8 addrspace(1)* %arg2, i8 addrspace(1)* %arg3) ] br label %gc.safepoint_poll.exit2 -gc.safepoint_poll.exit2: +gc.safepoint_poll.exit2: ; preds = %do_safepoint, %entry ; CHECK-LABEL: gc.safepoint_poll.exit2: ; CHECK: phi i8 addrspace(1)* ; CHECK-DAG: [ %arg3, %entry ] @@ -190,44 +188,42 @@ gc.safepoint_poll.exit2: ; Check relocation in a loop nest where a relocation happens in the outer ; but not the inner loop -define void @test_outer_loop(i8 addrspace(1)* %arg1, i8 addrspace(1)* %arg2, - i1 %cmp) gc "statepoint-example" { +define void @test_outer_loop(i8 addrspace(1)* %arg1, i8 addrspace(1)* %arg2, i1 %cmp) gc "statepoint-example" { ; CHECK-LABEL: @test_outer_loop + bci_0: br label %outer-loop -outer-loop: +outer-loop: ; preds = %outer-inc, %bci_0 ; CHECK-LABEL: outer-loop: ; CHECK: phi i8 addrspace(1)* [ %arg2, %bci_0 ], [ %arg2.relocated, %outer-inc ] ; CHECK: phi i8 addrspace(1)* [ %arg1, %bci_0 ], [ %arg1.relocated, %outer-inc ] br label %inner-loop -inner-loop: +inner-loop: ; preds = %inner-loop, %outer-loop br i1 %cmp, label %inner-loop, label %outer-inc -outer-inc: +outer-inc: ; preds = %inner-loop ; CHECK-LABEL: outer-inc: ; CHECK: %arg1.relocated ; CHECK: %arg2.relocated - %safepoint_token = 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 2, i8 addrspace(1)* %arg1, i8 addrspace(1)* %arg2) + call void @foo() [ "deopt"(i8 addrspace(1)* %arg1, i8 addrspace(1)* %arg2) ] br label %outer-loop } ; Check that both inner and outer loops get phis when relocation is in ; inner loop -define void @test_inner_loop(i8 addrspace(1)* %arg1, i8 addrspace(1)* %arg2, - i1 %cmp) gc "statepoint-example" { +define void @test_inner_loop(i8 addrspace(1)* %arg1, i8 addrspace(1)* %arg2, i1 %cmp) gc "statepoint-example" { ; CHECK-LABEL: @test_inner_loop + bci_0: br label %outer-loop -outer-loop: +outer-loop: ; preds = %outer-inc, %bci_0 ; CHECK-LABEL: outer-loop: ; CHECK: phi i8 addrspace(1)* [ %arg2, %bci_0 ], [ %arg2.relocated, %outer-inc ] ; CHECK: phi i8 addrspace(1)* [ %arg1, %bci_0 ], [ %arg1.relocated, %outer-inc ] br label %inner-loop - -inner-loop: ; CHECK-LABEL: inner-loop ; CHECK: phi i8 addrspace(1)* ; CHECK-DAG: %outer-loop ] @@ -238,42 +234,40 @@ inner-loop: ; CHECK: gc.statepoint ; CHECK: %arg1.relocated ; CHECK: %arg2.relocated - %safepoint_token = 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 2, i8 addrspace(1)* %arg1, i8 addrspace(1)* %arg2) + +inner-loop: ; preds = %inner-loop, %outer-loop + call void @foo() [ "deopt"(i8 addrspace(1)* %arg1, i8 addrspace(1)* %arg2) ] br i1 %cmp, label %inner-loop, label %outer-inc -outer-inc: +outer-inc: ; preds = %inner-loop ; CHECK-LABEL: outer-inc: +; This test shows why updating just those uses of the original value being +; relocated dominated by the inserted relocation is not always sufficient. br label %outer-loop } - -; This test shows why updating just those uses of the original value being -; relocated dominated by the inserted relocation is not always sufficient. define i64 addrspace(1)* @test7(i64 addrspace(1)* %obj, i64 addrspace(1)* %obj2, i1 %condition) gc "statepoint-example" { ; CHECK-LABEL: @test7 entry: br i1 %condition, label %branch2, label %join -branch2: +branch2: ; preds = %entry br i1 %condition, label %callbb, label %join2 -callbb: - %safepoint_token = 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) +callbb: ; preds = %branch2 + call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ] br label %join -join: +join: ; preds = %callbb, %entry ; CHECK-LABEL: join: ; CHECK: phi i64 addrspace(1)* [ %obj.relocated.casted, %callbb ], [ %obj, %entry ] ; CHECK: phi i64 addrspace(1)* ; CHECK-DAG: [ %obj, %entry ] ; CHECK-DAG: [ %obj2.relocated.casted, %callbb ] - ; This is a phi outside the dominator region of the new defs inserted by - ; the safepoint, BUT we can't stop the search here or we miss the second - ; phi below. %phi1 = phi i64 addrspace(1)* [ %obj, %entry ], [ %obj2, %callbb ] br label %join2 -join2: +join2: ; preds = %join, %branch2 ; CHECK-LABEL: join2: ; CHECK: phi2 = phi i64 addrspace(1)* ; CHECK-DAG: %join ] @@ -282,14 +276,4 @@ join2: ret i64 addrspace(1)* %phi2 } - declare void @do_safepoint() - -declare token @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...) -declare token @llvm.experimental.gc.statepoint.p0f_p1i8f(i64, i32, i8 addrspace(1)* ()*, i32, i32, ...) -declare token @llvm.experimental.gc.statepoint.p0f_isVoidi64f(i64, i32, void (i64)*, i32, i32, ...) -declare token @llvm.experimental.gc.statepoint.p0f_i32p1i64f(i64, i32, i32 (i64 addrspace(1)*)*, i32, i32, ...) -declare i8 addrspace(1)* @llvm.experimental.gc.result.p1i8(token) #3 - - - diff --git a/test/Transforms/RewriteStatepointsForGC/rematerialize-derived-pointers.ll b/test/Transforms/RewriteStatepointsForGC/rematerialize-derived-pointers.ll index 445ab7bd768d..c4ec2ce5bf77 100644 --- a/test/Transforms/RewriteStatepointsForGC/rematerialize-derived-pointers.ll +++ b/test/Transforms/RewriteStatepointsForGC/rematerialize-derived-pointers.ll @@ -1,256 +1,261 @@ -; RUN: opt %s -rewrite-statepoints-for-gc -S 2>&1 | FileCheck %s +; RUN: opt < %s -rewrite-statepoints-for-gc -S | FileCheck %s + + +declare void @use_obj16(i16 addrspace(1)*) "gc-leaf-function" +declare void @use_obj32(i32 addrspace(1)*) "gc-leaf-function" +declare void @use_obj64(i64 addrspace(1)*) "gc-leaf-function" -declare void @use_obj16(i16 addrspace(1)*) -declare void @use_obj32(i32 addrspace(1)*) -declare void @use_obj64(i64 addrspace(1)*) declare void @do_safepoint() -define void @"test_gep_const"(i32 addrspace(1)* %base) gc "statepoint-example" { +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 - %sp = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0) - ; CHECK: %base.relocated = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token %sp, 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 +; 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 } -define void @"test_gep_idx"(i32 addrspace(1)* %base, i32 %idx) gc "statepoint-example" { +define void @test_gep_idx(i32 addrspace(1)* %base, i32 %idx) gc "statepoint-example" { ; CHECK-LABEL: test_gep_idx entry: %ptr = getelementptr i32, i32 addrspace(1)* %base, i32 %idx - ; CHECK: getelementptr - %sp = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0) - ; CHECK: %base.relocated = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token %sp, 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 +; 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 } -define void @"test_bitcast"(i32 addrspace(1)* %base) gc "statepoint-example" { +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)* - %sp = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0) - ; CHECK: %base.relocated = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token %sp, 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 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" { +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)* - %sp = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0) - ; CHECK: %base.relocated = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token %sp, 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)* +; 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" { +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)* - %sp = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0) - ; CHECK: %base.relocated = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token %sp, 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 %sp, i32 7, i32 8) - ; CHECK: %ptr2.relocated.casted = bitcast i8 addrspace(1)* %ptr2.relocated 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: %ptr2.relocated = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token %statepoint_token, i32 8, i32 7) +; CHECK: %ptr2.relocated.casted = bitcast i8 addrspace(1)* %ptr2.relocated to i32 addrspace(1)* +; CHECK: %base.relocated = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token %statepoint_token, i32 8, i32 8) +; CHECK: %base.relocated.casted = bitcast i8 addrspace(1)* %base.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" { +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: getelementptr +; CHECK: bitcast i32 addrspace(1)* %ptr.gep to i64 addrspace(1)* %ptr.cast = bitcast i32 addrspace(1)* %ptr.gep to i64 addrspace(1)* - ; CHECK: bitcast - %sp = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0) - ; CHECK: gc.relocate - ; CHECK: bitcast - ; CHECK: getelementptr - ; CHECK: bitcast + 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 } -define void @"test_intersecting_chains"(i32 addrspace(1)* %base, i32 %idx) gc "statepoint-example" { +define void @test_intersecting_chains(i32 addrspace(1)* %base, i32 %idx) gc "statepoint-example" { ; CHECK-LABEL: test_intersecting_chains entry: %ptr.gep = getelementptr i32, i32 addrspace(1)* %base, i32 15 - ; CHECK: getelementptr +; CHECK: getelementptr %ptr.cast = bitcast i32 addrspace(1)* %ptr.gep to i64 addrspace(1)* - ; CHECK: bitcast +; CHECK: bitcast %ptr.cast2 = bitcast i32 addrspace(1)* %ptr.gep to i16 addrspace(1)* - ; CHECK: bitcast - %sp = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0) - ; CHECK: getelementptr - ; CHECK: bitcast - ; CHECK: getelementptr - ; CHECK: bitcast +; 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 } -define void @"test_cost_threshold"(i32 addrspace(1)* %base, i32 %idx1, i32 %idx2, i32 %idx3) gc "statepoint-example" { +define void @test_cost_threshold(i32 addrspace(1)* %base, i32 %idx1, i32 %idx2, i32 %idx3) gc "statepoint-example" { ; CHECK-LABEL: test_cost_threshold entry: %ptr.gep = getelementptr i32, i32 addrspace(1)* %base, i32 15 - ; CHECK: getelementptr +; CHECK: getelementptr %ptr.gep2 = getelementptr i32, i32 addrspace(1)* %ptr.gep, i32 %idx1 - ; CHECK: getelementptr +; CHECK: getelementptr %ptr.gep3 = getelementptr i32, i32 addrspace(1)* %ptr.gep2, i32 %idx2 - ; CHECK: getelementptr +; CHECK: getelementptr %ptr.gep4 = getelementptr i32, i32 addrspace(1)* %ptr.gep3, i32 %idx3 - ; CHECK: getelementptr +; CHECK: getelementptr %ptr.cast = bitcast i32 addrspace(1)* %ptr.gep4 to i64 addrspace(1)* - ; CHECK: bitcast - %sp = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0) - ; CHECK: gc.relocate - ; CHECK: bitcast - ; CHECK: gc.relocate - ; CHECK: bitcast + 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 } -define void @"test_two_derived"(i32 addrspace(1)* %base) gc "statepoint-example" { +define void @test_two_derived(i32 addrspace(1)* %base) gc "statepoint-example" { ; CHECK-LABEL: test_two_derived entry: %ptr = getelementptr i32, i32 addrspace(1)* %base, i32 15 %ptr2 = getelementptr i32, i32 addrspace(1)* %base, i32 12 - ; CHECK: getelementptr - ; CHECK: getelementptr - %sp = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0) - ; CHECK: gc.relocate - ; CHECK: bitcast - ; CHECK: getelementptr - ; CHECK: getelementptr +; 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 } -define void @"test_gep_smallint_array"([3 x i32] addrspace(1)* %base) gc "statepoint-example" { +define void @test_gep_smallint_array([3 x i32] addrspace(1)* %base) gc "statepoint-example" { ; CHECK-LABEL: test_gep_smallint_array entry: %ptr = getelementptr [3 x i32], [3 x i32] addrspace(1)* %base, i32 0, i32 2 - ; CHECK: getelementptr - %sp = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0) - ; CHECK: gc.relocate - ; CHECK: bitcast - ; CHECK: getelementptr +; CHECK: getelementptr + call void @do_safepoint() [ "deopt"() ] + +; CHECK: gc.relocate +; CHECK: bitcast +; CHECK: getelementptr call void @use_obj32(i32 addrspace(1)* %ptr) ret void } declare i32 @fake_personality_function() -define void @"test_invoke"(i32 addrspace(1)* %base) gc "statepoint-example" personality i32 ()* @fake_personality_function { +define void @test_invoke(i32 addrspace(1)* %base) gc "statepoint-example" personality i32 ()* @fake_personality_function { ; CHECK-LABEL: test_invoke entry: %ptr.gep = getelementptr i32, i32 addrspace(1)* %base, i32 15 - ; CHECK: getelementptr +; CHECK: getelementptr %ptr.cast = bitcast i32 addrspace(1)* %ptr.gep to i64 addrspace(1)* - ; CHECK: bitcast +; CHECK: bitcast %ptr.cast2 = bitcast i32 addrspace(1)* %ptr.gep to i16 addrspace(1)* - ; CHECK: bitcast - %sp = invoke token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0) - to label %normal unwind label %exception +; CHECK: bitcast + invoke void @do_safepoint() [ "deopt"() ] + to label %normal unwind label %exception normal: - ; CHECK-LABEL: normal: - ; CHECK: gc.relocate - ; CHECK: bitcast - ; CHECK: getelementptr - ; CHECK: bitcast - ; CHECK: getelementptr - ; CHECK: bitcast +; 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: - ; CHECK-LABEL: exception: +; CHECK: exception: %landing_pad4 = landingpad token cleanup - ; CHECK: gc.relocate - ; CHECK: bitcast - ; CHECK: getelementptr - ; CHECK: bitcast - ; CHECK: getelementptr - ; CHECK: bitcast +; 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 } -define void @"test_loop"(i32 addrspace(1)* %base) gc "statepoint-example" { +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 +; CHECK: getelementptr br label %loop -loop: - ; CHECK: phi i32 addrspace(1)* [ %ptr.gep, %entry ], [ %ptr.gep.remat, %loop ] - ; CHECK: phi i32 addrspace(1)* [ %base, %entry ], [ %base.relocated.casted, %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) - %sp = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0) - ; CHECK: gc.relocate - ; CHECK: bitcast - ; CHECK: getelementptr + call void @do_safepoint() [ "deopt"() ] +; CHECK: gc.relocate +; CHECK: bitcast +; CHECK: getelementptr br label %loop } -define void @"test_too_long"(i32 addrspace(1)* %base) gc "statepoint-example" { +define void @test_too_long(i32 addrspace(1)* %base) gc "statepoint-example" { ; CHECK-LABEL: test_too_long entry: - %ptr.gep = getelementptr i32, i32 addrspace(1)* %base, i32 15 - %ptr.gep1 = getelementptr i32, i32 addrspace(1)* %ptr.gep, i32 15 - %ptr.gep2 = getelementptr i32, i32 addrspace(1)* %ptr.gep1, i32 15 - %ptr.gep3 = getelementptr i32, i32 addrspace(1)* %ptr.gep2, i32 15 - %ptr.gep4 = getelementptr i32, i32 addrspace(1)* %ptr.gep3, i32 15 - %ptr.gep5 = getelementptr i32, i32 addrspace(1)* %ptr.gep4, i32 15 - %ptr.gep6 = getelementptr i32, i32 addrspace(1)* %ptr.gep5, i32 15 - %ptr.gep7 = getelementptr i32, i32 addrspace(1)* %ptr.gep6, i32 15 - %ptr.gep8 = getelementptr i32, i32 addrspace(1)* %ptr.gep7, i32 15 - %ptr.gep9 = getelementptr i32, i32 addrspace(1)* %ptr.gep8, i32 15 + %ptr.gep = getelementptr i32, i32 addrspace(1)* %base, i32 15 + %ptr.gep1 = getelementptr i32, i32 addrspace(1)* %ptr.gep, i32 15 + %ptr.gep2 = getelementptr i32, i32 addrspace(1)* %ptr.gep1, i32 15 + %ptr.gep3 = getelementptr i32, i32 addrspace(1)* %ptr.gep2, i32 15 + %ptr.gep4 = getelementptr i32, i32 addrspace(1)* %ptr.gep3, i32 15 + %ptr.gep5 = getelementptr i32, i32 addrspace(1)* %ptr.gep4, i32 15 + %ptr.gep6 = getelementptr i32, i32 addrspace(1)* %ptr.gep5, i32 15 + %ptr.gep7 = getelementptr i32, i32 addrspace(1)* %ptr.gep6, i32 15 + %ptr.gep8 = getelementptr i32, i32 addrspace(1)* %ptr.gep7, i32 15 + %ptr.gep9 = getelementptr i32, i32 addrspace(1)* %ptr.gep8, i32 15 %ptr.gep10 = getelementptr i32, i32 addrspace(1)* %ptr.gep9, i32 15 %ptr.gep11 = getelementptr i32, i32 addrspace(1)* %ptr.gep10, i32 15 - %sp = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0) - ; CHECK: gc.relocate - ; CHECK: bitcast - ; CHECK: gc.relocate - ; CHECK: bitcast + 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 } - - -declare token @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...) diff --git a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/rewrite-invoke.ll b/test/Transforms/RewriteStatepointsForGC/rewrite-invoke.ll index e1d0140c1dcd..91d4fa303b1b 100644 --- a/test/Transforms/RewriteStatepointsForGC/deopt-bundles/rewrite-invoke.ll +++ b/test/Transforms/RewriteStatepointsForGC/rewrite-invoke.ll @@ -1,4 +1,4 @@ -; RUN: opt -rewrite-statepoints-for-gc -rs4gc-use-deopt-bundles -verify -S < %s | FileCheck %s +; RUN: opt -rewrite-statepoints-for-gc -verify -S < %s | FileCheck %s declare i8 addrspace(1)* @gc_call() diff --git a/test/Transforms/RewriteStatepointsForGC/statepoint-calling-conventions.ll b/test/Transforms/RewriteStatepointsForGC/statepoint-calling-conventions.ll new file mode 100644 index 000000000000..f40ff8f3a7d1 --- /dev/null +++ b/test/Transforms/RewriteStatepointsForGC/statepoint-calling-conventions.ll @@ -0,0 +1,42 @@ +; RUN: opt -rewrite-statepoints-for-gc -S < %s | FileCheck %s + +; Ensure that the gc.statepoint calls / invokes we generate carry over +; the right calling conventions. + +define i64 addrspace(1)* @test_invoke_format(i64 addrspace(1)* %obj, i64 addrspace(1)* %obj1) gc "statepoint-example" personality i32 ()* @personality { +; CHECK-LABEL: @test_invoke_format( +; CHECK-LABEL: entry: +; CHECK: invoke coldcc token (i64, i32, i64 addrspace(1)* (i64 addrspace(1)*)*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_p1i64p1i64f(i64 2882400000, i32 0, i64 addrspace(1)* (i64 addrspace(1)*)* @callee, i32 1, i32 0, i64 addrspace(1)* %obj, i32 0, i32 0 +entry: + %ret_val = invoke coldcc i64 addrspace(1)* @callee(i64 addrspace(1)* %obj) + to label %normal_return unwind label %exceptional_return + +normal_return: + ret i64 addrspace(1)* %ret_val + +exceptional_return: + %landing_pad4 = landingpad token + cleanup + ret i64 addrspace(1)* %obj1 +} + +define i64 addrspace(1)* @test_call_format(i64 addrspace(1)* %obj, i64 addrspace(1)* %obj1) gc "statepoint-example" { +; CHECK-LABEL: @test_call_format( +; CHECK-LABEL: entry: +; CHECK: call coldcc token (i64, i32, i64 addrspace(1)* (i64 addrspace(1)*)*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_p1i64p1i64f(i64 2882400000, i32 0, i64 addrspace(1)* (i64 addrspace(1)*)* @callee, i32 1, i32 0, i64 addrspace(1)* %obj, i32 0, i32 0 +entry: + %ret_val = call coldcc i64 addrspace(1)* @callee(i64 addrspace(1)* %obj) + ret i64 addrspace(1)* %ret_val +} + +; 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 +} + +declare coldcc i64 addrspace(1)* @callee(i64 addrspace(1)*) +declare i32 @personality() diff --git a/test/Transforms/RewriteStatepointsForGC/statepoint-coreclr.ll b/test/Transforms/RewriteStatepointsForGC/statepoint-coreclr.ll new file mode 100644 index 000000000000..a19196eab5cf --- /dev/null +++ b/test/Transforms/RewriteStatepointsForGC/statepoint-coreclr.ll @@ -0,0 +1,31 @@ +; RUN: opt < %s -S -rewrite-statepoints-for-gc | FileCheck %s + +; Basic test to make sure that safepoints are placed +; for CoreCLR GC + +declare void @foo() + +define void @test_simple_call() gc "coreclr" { +; CHECK-LABEL: test_simple_call +entry: + br label %other +other: +; CHECK-LABEL: other +; CHECK: statepoint +; CHECK-NOT: gc.result + call void @foo() + ret void +} + +; This function is inlined when inserting a poll. To avoid recursive +; issues, make sure we don't place safepoints in it. +declare void @do_safepoint() +define void @gc.safepoint_poll() { +; CHECK-LABEL: gc.safepoint_poll +; CHECK-LABEL: entry +; CHECK-NEXT: do_safepoint +; CHECK-NEXT: ret void +entry: + call void @do_safepoint() + ret void +} diff --git a/test/Transforms/RewriteStatepointsForGC/statepoint-format.ll b/test/Transforms/RewriteStatepointsForGC/statepoint-format.ll new file mode 100644 index 000000000000..029864e3efa0 --- /dev/null +++ b/test/Transforms/RewriteStatepointsForGC/statepoint-format.ll @@ -0,0 +1,42 @@ +; RUN: opt -rewrite-statepoints-for-gc -S < %s | FileCheck %s + +; Ensure that the gc.statepoint calls / invokes we generate have the +; set of arguments we expect it to have. + +define i64 addrspace(1)* @test_invoke_format(i64 addrspace(1)* %obj, i64 addrspace(1)* %obj1) gc "statepoint-example" personality i32 ()* @personality { +; CHECK-LABEL: @test_invoke_format( +; CHECK-LABEL: entry: +; CHECK: invoke token (i64, i32, i64 addrspace(1)* (i64 addrspace(1)*)*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_p1i64p1i64f(i64 2882400000, i32 0, i64 addrspace(1)* (i64 addrspace(1)*)* @callee, i32 1, i32 0, i64 addrspace(1)* %obj, i32 0, i32 0, i64 addrspace(1)* %obj1, i64 addrspace(1)* %obj) +entry: + %ret_val = invoke i64 addrspace(1)* @callee(i64 addrspace(1)* %obj) + to label %normal_return unwind label %exceptional_return + +normal_return: + ret i64 addrspace(1)* %ret_val + +exceptional_return: + %landing_pad4 = landingpad token + cleanup + ret i64 addrspace(1)* %obj1 +} + +define i64 addrspace(1)* @test_call_format(i64 addrspace(1)* %obj, i64 addrspace(1)* %obj1) gc "statepoint-example" { +; CHECK-LABEL: @test_call_format( +; CHECK-LABEL: entry: +; CHECK: call token (i64, i32, i64 addrspace(1)* (i64 addrspace(1)*)*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_p1i64p1i64f(i64 2882400000, i32 0, i64 addrspace(1)* (i64 addrspace(1)*)* @callee, i32 1, i32 0, i64 addrspace(1)* %obj, i32 0, i32 0, i64 addrspace(1)* %obj) +entry: + %ret_val = call i64 addrspace(1)* @callee(i64 addrspace(1)* %obj) + ret i64 addrspace(1)* %ret_val +} + +; 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 +} + +declare i64 addrspace(1)* @callee(i64 addrspace(1)*) +declare i32 @personality() diff --git a/test/Transforms/RewriteStatepointsForGC/two-invokes-one-landingpad.ll b/test/Transforms/RewriteStatepointsForGC/two-invokes-one-landingpad.ll index d3d3c5a8d1ab..f35a3668a6b1 100644 --- a/test/Transforms/RewriteStatepointsForGC/two-invokes-one-landingpad.ll +++ b/test/Transforms/RewriteStatepointsForGC/two-invokes-one-landingpad.ll @@ -1,12 +1,12 @@ -; RUN: opt %s -rewrite-statepoints-for-gc -rs4gc-use-deopt-bundles -S | FileCheck %s +; RUN: opt < %s -rewrite-statepoints-for-gc -S | FileCheck %s declare void @some_call(i64 addrspace(1)*) -declare i32 @"dummy_personality_function"() +declare i32 @dummy_personality_function() define i64 addrspace(1)* @test(i64 addrspace(1)* %obj, i64 addrspace(1)* %obj1) gc "statepoint-example" - personality i32 ()* @"dummy_personality_function" { + personality i32 ()* @dummy_personality_function { entry: invoke void @some_call(i64 addrspace(1)* %obj) [ "deopt"() ] to label %second_invoke unwind label %exceptional_return |