Imported Upstream version 6.10.0.49

Former-commit-id: 1d6753294b2993e1fbf92de9366bb9544db4189b
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2020-01-16 16:38:04 +00:00
parent d94e79959b
commit 468663ddbb
48518 changed files with 2789335 additions and 61176 deletions

View File

@@ -0,0 +1,77 @@
; RUN: opt < %s -S -place-safepoints | FileCheck %s
; Do we insert a simple entry safepoint?
define void @test_entry() gc "statepoint-example" {
; CHECK-LABEL: @test_entry
entry:
; CHECK-LABEL: entry
; CHECK: call void @do_safepoint
ret void
}
; On a non-gc function, we should NOT get an entry safepoint
define void @test_negative() {
; CHECK-LABEL: @test_negative
entry:
; CHECK-NOT: do_safepoint
ret void
}
; Do we insert a backedge safepoint in a statically
; infinite loop?
define void @test_backedge() gc "statepoint-example" {
; CHECK-LABEL: test_backedge
entry:
; CHECK-LABEL: entry
; This statepoint is technically not required, but we don't exploit that yet.
; CHECK: call void @do_safepoint
br label %other
; CHECK-LABEL: other
; CHECK: call void @do_safepoint
other:
br label %other
}
; Check that we remove an unreachable block rather than trying
; to insert a backedge safepoint
define void @test_unreachable() gc "statepoint-example" {
; CHECK-LABEL: test_unreachable
entry:
; CHECK-LABEL: entry
; CHECK: call void @do_safepoint
ret void
; CHECK-NOT: other
; CHECK-NOT: do_safepoint
other:
br label %other
}
declare void @foo()
declare zeroext i1 @i1_return_i1(i1)
define i1 @test_call_with_result() gc "statepoint-example" {
; CHECK-LABEL: test_call_with_result
; This is checking that a statepoint_poll is inserted for a function
; that takes 1 argument.
; CHECK: call void @do_safepoint
entry:
%call1 = tail call i1 (i1) @i1_return_i1(i1 false)
ret i1 %call1
}
; 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
}

View File

@@ -0,0 +1,30 @@
; If there's a call in the loop which dominates the backedge, we
; don't need a safepoint poll (since the callee must contain a
; poll test).
;; RUN: opt < %s -place-safepoints -S | FileCheck %s
declare void @foo()
define void @test1() gc "statepoint-example" {
; CHECK-LABEL: test1
entry:
; CHECK-LABEL: entry
; CHECK: call void @do_safepoint
br label %loop
loop:
; CHECK-LABEL: loop
; CHECK-NOT: call void @do_safepoint
call void @foo()
br label %loop
}
; 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
}

View File

@@ -0,0 +1,143 @@
; Tests to ensure that we are not placing backedge safepoints in
; loops which are clearly finite.
;; RUN: opt < %s -place-safepoints -spp-counted-loop-trip-width=32 -S | FileCheck %s
;; RUN: opt < %s -place-safepoints -spp-counted-loop-trip-width=64 -S | FileCheck %s -check-prefix=COUNTED-64
; A simple counted loop with trivially known range
define void @test1(i32) gc "statepoint-example" {
; CHECK-LABEL: test1
; CHECK-LABEL: entry
; CHECK: call void @do_safepoint
; CHECK-LABEL: loop
; CHECK-NOT: call void @do_safepoint
; CHECK-LABEL: exit
entry:
br label %loop
loop:
%counter = phi i32 [ 0 , %entry ], [ %counter.inc , %loop ]
%counter.inc = add i32 %counter, 1
%counter.cmp = icmp slt i32 %counter.inc, 16
br i1 %counter.cmp, label %loop, label %exit
exit:
ret void
}
; The same counted loop, but with an unknown early exit
define void @test2(i32) gc "statepoint-example" {
; CHECK-LABEL: test2
; CHECK-LABEL: entry
; CHECK: call void @do_safepoint
; CHECK-LABEL: loop
; CHECK-NOT: call void @do_safepoint
; CHECK-LABEL: exit
entry:
br label %loop
loop:
%counter = phi i32 [ 0 , %entry ], [ %counter.inc , %continue ]
%counter.inc = add i32 %counter, 1
%counter.cmp = icmp slt i32 %counter.inc, 16
br i1 undef, label %continue, label %exit
continue:
br i1 %counter.cmp, label %loop, label %exit
exit:
ret void
}
; The range is a 8 bit value and we can't overflow
define void @test3(i8 %upper) gc "statepoint-example" {
; CHECK-LABEL: test3
; CHECK-LABEL: entry
; CHECK: call void @do_safepoint
; CHECK-LABEL: loop
; CHECK-NOT: call void @do_safepoint
; CHECK-LABEL: exit
entry:
br label %loop
loop:
%counter = phi i8 [ 0 , %entry ], [ %counter.inc , %loop ]
%counter.inc = add nsw i8 %counter, 1
%counter.cmp = icmp slt i8 %counter.inc, %upper
br i1 %counter.cmp, label %loop, label %exit
exit:
ret void
}
; The range is a 64 bit value
define void @test4(i64 %upper) gc "statepoint-example" {
; CHECK-LABEL: test4
; CHECK-LABEL: entry
; CHECK: call void @do_safepoint
; CHECK-LABEL: loop
; CHECK: call void @do_safepoint
; CHECK-LABEL: exit
; COUNTED-64-LABEL: test4
; COUNTED-64-LABEL: entry
; COUNTED-64: call void @do_safepoint
; COUNTED-64-LABEL: loop
; COUNTED-64-NOT: call void @do_safepoint
; COUNTED-64-LABEL: exit
entry:
br label %loop
loop:
%counter = phi i64 [ 0 , %entry ], [ %counter.inc , %loop ]
%counter.inc = add i64 %counter, 1
%counter.cmp = icmp slt i64 %counter.inc, %upper
br i1 %counter.cmp, label %loop, label %exit
exit:
ret void
}
; This loop can run infinitely (for %upper == INT64_MAX) so it needs a
; safepoint.
define void @test5(i64 %upper) gc "statepoint-example" {
; CHECK-LABEL: test5
; CHECK-LABEL: entry
; CHECK: call void @do_safepoint
; CHECK-LABEL: loop
; CHECK: call void @do_safepoint
; CHECK-LABEL: exit
; COUNTED-64-LABEL: test5
; COUNTED-64-LABEL: entry
; COUNTED-64: call void @do_safepoint
; COUNTED-64-LABEL: loop
; COUNTED-64: call void @do_safepoint
; COUNTED-64-LABEL: exit
entry:
br label %loop
loop:
%counter = phi i64 [ 0 , %entry ], [ %counter.inc , %loop ]
%counter.inc = add i64 %counter, 1
%counter.cmp = icmp sle i64 %counter.inc, %upper
br i1 %counter.cmp, label %loop, label %exit
exit:
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
}

View File

@@ -0,0 +1,37 @@
; RUN: opt -S -place-safepoints < %s | FileCheck %s
; Libcalls will not contain a safepoint poll, so check that we insert
; a safepoint in a loop containing a libcall.
declare double @ldexp(double %x, i32 %n) nounwind readnone
define double @test_libcall(double %x) gc "statepoint-example" {
; CHECK-LABEL: test_libcall
entry:
; CHECK: entry
; CHECK-NEXT: call void @do_safepoint
; CHECK-NEXT: br label %loop
br label %loop
loop:
; CHECK: loop
; CHECK-NEXT: %x_loop = phi double [ %x, %entry ], [ %x_exp, %loop ]
; CHECK-NEXT: %x_exp = call double @ldexp(double %x_loop, i32 5)
; CHECK-NEXT: %done = fcmp ogt double %x_exp, 1.5
; CHECK-NEXT: call void @do_safepoint
%x_loop = phi double [ %x, %entry ], [ %x_exp, %loop ]
%x_exp = call double @ldexp(double %x_loop, i32 5) nounwind readnone
%done = fcmp ogt double %x_exp, 1.5
br i1 %done, label %end, label %loop
end:
%x_end = phi double [%x_exp, %loop]
ret double %x_end
}
; 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
}

View File

@@ -0,0 +1,20 @@
; RUN: opt < %s -S -place-safepoints | FileCheck %s
define void @test(i32, i8 addrspace(1)* %ptr) gc "statepoint-example" {
; CHECK-LABEL: @test
; CHECK-NEXT: llvm.memset
; CHECK: do_safepoint
; CHECK: @foo
call void @llvm.memset.p1i8.i64(i8 addrspace(1)* %ptr, i8 0, i64 24, i32 8, i1 false)
call void @foo()
ret void
}
declare void @foo()
declare void @llvm.memset.p1i8.i64(i8 addrspace(1)*, i8, i64, i32, i1)
declare void @do_safepoint()
define void @gc.safepoint_poll() {
call void @do_safepoint()
ret void
}

View File

@@ -0,0 +1,23 @@
; RUN: opt -S -place-safepoints < %s | FileCheck %s
declare void @callee()
define void @test() gc "statepoint-example" {
; CHECK-LABEL: test(
entry:
; CHECK: entry:
; CHECK: call void @do_safepoint()
br label %other
other:
; CHECK: other:
call void @callee() "gc-leaf-function"
; CHECK: call void @do_safepoint()
br label %other
}
declare void @do_safepoint()
define void @gc.safepoint_poll() {
call void @do_safepoint()
ret void
}

View File

@@ -0,0 +1,46 @@
;; A very basic test to make sure that splitting the backedge keeps working
;; RUN: opt < %s -place-safepoints -spp-split-backedge=1 -S | FileCheck %s
define void @test(i32, i1 %cond) gc "statepoint-example" {
; CHECK-LABEL: @test
; CHECK-LABEL: loop.loop_crit_edge
; CHECK: call void @do_safepoint
; CHECK-NEXT: br label %loop
entry:
br label %loop
loop:
br i1 %cond, label %loop, label %exit
exit:
ret void
}
; Test for the case where a single conditional branch jumps to two
; different loop header blocks. Since we're currently using LoopSimplfy
; this doesn't hit the interesting case, but once we remove that, we need
; to be sure this keeps working.
define void @test2(i32, i1 %cond) gc "statepoint-example" {
; CHECK-LABEL: @test2
; CHECK-LABEL: loop2.loop2_crit_edge:
; CHECK: call void @do_safepoint
; CHECK-NEXT: br label %loop2
; CHECK-LABEL: loop2.loop_crit_edge:
; CHECK: call void @do_safepoint
; CHECK-NEXT: br label %loop
entry:
br label %loop
loop:
br label %loop2
loop2:
br i1 %cond, label %loop, label %loop2
}
declare void @do_safepoint()
define void @gc.safepoint_poll() {
entry:
call void @do_safepoint()
ret void
}

View File

@@ -0,0 +1,29 @@
; RUN: opt < %s -S -place-safepoints | 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:
; CHECK: call void @do_safepoint
br label %other
other:
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
}

View File

@@ -0,0 +1,29 @@
; RUN: opt < %s -S -place-safepoints | FileCheck %s
declare void @llvm.localescape(...)
; Do we insert the entry safepoint after the localescape intrinsic?
define void @parent() gc "statepoint-example" {
; CHECK-LABEL: @parent
entry:
; CHECK-LABEL: entry
; CHECK-NEXT: alloca
; CHECK-NEXT: localescape
; CHECK-NEXT: call void @do_safepoint
%ptr = alloca i32
call void (...) @llvm.localescape(i32* %ptr)
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
}