Imported Upstream version 6.4.0.137

Former-commit-id: 943baa9f16a098c33e129777827f3a9d20da00d6
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2019-07-26 19:53:28 +00:00
parent e9207cf623
commit ef583813eb
2712 changed files with 74169 additions and 40587 deletions

View File

@@ -0,0 +1,16 @@
; RUN: opt -deadargelim -S < %s | FileCheck %s
; PR36441
; Dead arguments should not be removed in presence of `musttail` calls.
; CHECK-LABEL: define internal void @test(i32 %a, i32 %b)
; CHECK: musttail call void @foo(i32 %a, i32 0)
; FIXME: we should replace those with `undef`s
define internal void @test(i32 %a, i32 %b) {
musttail call void @foo(i32 %a, i32 0)
ret void
}
; CHECK-LABEL: define internal void @foo(i32 %a, i32 %b)
define internal void @foo(i32 %a, i32 %b) {
ret void
}

View File

@@ -32,3 +32,22 @@ entry:
ret void
}
declare void @escape_alloca(i16*)
; check that addrspacecast is not ignored (leading to an assertion failure)
; when trying to mark a GEP as inbounds
define { i8, i8 } @inbounds_after_addrspacecast() {
top:
; CHECK-LABEL: @inbounds_after_addrspacecast
%0 = alloca i16, align 2
call void @escape_alloca(i16* %0)
%tmpcast = bitcast i16* %0 to [2 x i8]*
; CHECK: addrspacecast [2 x i8]* %tmpcast to [2 x i8] addrspace(11)*
%1 = addrspacecast [2 x i8]* %tmpcast to [2 x i8] addrspace(11)*
; CHECK: getelementptr [2 x i8], [2 x i8] addrspace(11)* %1, i64 0, i64 1
%2 = getelementptr [2 x i8], [2 x i8] addrspace(11)* %1, i64 0, i64 1
; CHECK: addrspace(11)
%3 = load i8, i8 addrspace(11)* %2, align 1
%.fca.1.insert = insertvalue { i8, i8 } zeroinitializer, i8 %3, 1
ret { i8, i8 } %.fca.1.insert
}

View File

@@ -0,0 +1,99 @@
; RUN: opt -S -jump-threading < %s | FileCheck %s
; Check that the heuristic for avoiding accidental introduction of irreducible
; loops doesn't also prevent us from threading simple constructs where this
; isn't a problem.
declare void @opaque_body()
define void @jump_threading_loopheader() {
; CHECK-LABEL: @jump_threading_loopheader
top:
br label %entry
entry:
%ind = phi i32 [0, %top], [%nextind, %latch]
%nextind = add i32 %ind, 1
%cmp = icmp ule i32 %ind, 10
; CHECK: br i1 %cmp, label %latch, label %exit
br i1 %cmp, label %body, label %latch
body:
call void @opaque_body()
; CHECK: br label %entry
br label %latch
latch:
%cond = phi i2 [1, %entry], [2, %body]
switch i2 %cond, label %unreach [
i2 2, label %entry
i2 1, label %exit
]
unreach:
unreachable
exit:
ret void
}
; We also need to check the opposite order of the branches, in the switch
; instruction because jump-threading relies on that to decide which edge to
; try to thread first.
define void @jump_threading_loopheader2() {
; CHECK-LABEL: @jump_threading_loopheader2
top:
br label %entry
entry:
%ind = phi i32 [0, %top], [%nextind, %latch]
%nextind = add i32 %ind, 1
%cmp = icmp ule i32 %ind, 10
; CHECK: br i1 %cmp, label %exit, label %latch
br i1 %cmp, label %body, label %latch
body:
call void @opaque_body()
; CHECK: br label %entry
br label %latch
latch:
%cond = phi i2 [1, %entry], [2, %body]
switch i2 %cond, label %unreach [
i2 1, label %entry
i2 2, label %exit
]
unreach:
unreachable
exit:
ret void
}
; Check if we can handle undef branch condition.
define void @jump_threading_loopheader3() {
; CHECK-LABEL: @jump_threading_loopheader3
top:
br label %entry
entry:
%ind = phi i32 [0, %top], [%nextind, %latch]
%nextind = add i32 %ind, 1
%cmp = icmp ule i32 %ind, 10
; CHECK: br i1 %cmp, label %latch, label %exit
br i1 %cmp, label %body, label %latch
body:
call void @opaque_body()
; CHECK: br label %entry
br label %latch
latch:
%phi = phi i32 [undef, %entry], [0, %body]
%cmp1 = icmp eq i32 %phi, 0
br i1 %cmp1, label %entry, label %exit
exit:
ret void
}

View File

@@ -0,0 +1,53 @@
; RUN: opt -mergefunc -S < %s | FileCheck %s
; CHECK-LABEL: @int_ptr_arg_different
; CHECK-NEXT: call void asm
; CHECK-LABEL: @int_ptr_arg_same
; CHECK-NEXT: %2 = bitcast i32* %0 to float*
; CHECK-NEXT: tail call void @float_ptr_arg_same(float* %2)
; CHECK-LABEL: @int_ptr_null
; CHECK-NEXT: tail call void @float_ptr_null()
; Used to satisfy minimum size limit
declare void @stuff()
; Can be merged
define void @float_ptr_null() {
call void asm "nop", "r"(float* null)
call void @stuff()
ret void
}
define void @int_ptr_null() {
call void asm "nop", "r"(i32* null)
call void @stuff()
ret void
}
; Can be merged (uses same argument differing by pointer type)
define void @float_ptr_arg_same(float*) {
call void asm "nop", "r"(float* %0)
call void @stuff()
ret void
}
define void @int_ptr_arg_same(i32*) {
call void asm "nop", "r"(i32* %0)
call void @stuff()
ret void
}
; Can not be merged (uses different arguments)
define void @float_ptr_arg_different(float*, float*) {
call void asm "nop", "r"(float* %0)
call void @stuff()
ret void
}
define void @int_ptr_arg_different(i32*, i32*) {
call void asm "nop", "r"(i32* %1)
call void @stuff()
ret void
}

View File

@@ -0,0 +1,16 @@
; RUN: opt -mergefunc -S < %s | FileCheck %s
; Weak functions too small for merging to be profitable
; CHECK: define weak i32 @foo(i8*, i32)
; CHECK-NEXT: ret i32 %1
; CHECK: define weak i32 @bar(i8*, i32)
; CHECK-NEXT: ret i32 %1
define weak i32 @foo(i8*, i32) #0 {
ret i32 %1
}
define weak i32 @bar(i8*, i32) #0 {
ret i32 %1
}