Imported Upstream version 5.18.0.167

Former-commit-id: 289509151e0fee68a1b591a20c9f109c3c789d3a
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2018-10-20 08:25:10 +00:00
parent e19d552987
commit b084638f15
28489 changed files with 184 additions and 3866856 deletions

View File

@ -1,61 +0,0 @@
; RUN: opt -basicaa -memdep -mldst-motion -S < %s | FileCheck %s
; RUN: opt -aa-pipeline=basic-aa -passes='require<memdep>',mldst-motion \
; RUN: -S < %s | FileCheck %s
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
@r = common global i32 0, align 4
@s = common global i32 0, align 4
; CHECK-LABEL: define void @test1(
define void @test1(i1 %cmp, i32* noalias %p) {
entry:
br i1 %cmp, label %if.then, label %if.else
if.then: ; preds = %entry
call void @may_exit() nounwind
%arrayidx = getelementptr inbounds i32, i32* %p, i64 1
%0 = load i32, i32* %arrayidx, align 4
store i32 %0, i32* @r, align 4
br label %if.end
; CHECK: call void @may_exit()
; CHECK-NEXT: %[[gep:.*]] = getelementptr inbounds i32, i32* %p, i64 1
; CHECK-NEXT: %[[load:.*]] = load i32, i32* %[[gep]], align 4
; CHECK-NEXT: store i32 %[[load]], i32* @r, align 4
if.else: ; preds = %entry
%arrayidx1 = getelementptr inbounds i32, i32* %p, i64 1
%1 = load i32, i32* %arrayidx1, align 4
store i32 %1, i32* @s, align 4
br label %if.end
if.end: ; preds = %if.else, %if.then
ret void
}
; CHECK-LABEL: define void @test2(
define void @test2(i1 %cmp, i32* noalias %p) {
entry:
br i1 %cmp, label %if.then, label %if.else
if.then: ; preds = %entry
%arrayidx = getelementptr inbounds i32, i32* %p, i64 1
store i32 1, i32* %arrayidx, align 4
call void @may_throw()
; CHECK: %[[gep:.*]] = getelementptr inbounds i32, i32* %p, i64 1
; CHECK-NEXT: store i32 1, i32* %[[gep]], align 4
; CHECK-NEXT: call void @may_throw()
br label %if.end
if.else: ; preds = %entry
%arrayidx1 = getelementptr inbounds i32, i32* %p, i64 1
store i32 2, i32* %arrayidx1, align 4
br label %if.end
if.end: ; preds = %if.else, %if.then
ret void
}
declare void @may_throw()
declare void @may_exit() nounwind

View File

@ -1,43 +0,0 @@
; Test to make sure that a function call that needs to be a barrier to sinking stores is indeed a barrier.
; Stores sunks into the footer.
; RUN: opt -basicaa -memdep -mldst-motion -S < %s | FileCheck %s
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
%struct.node = type { i32, %struct.node*, %struct.node*, %struct.node*, i32, i32, i32, i32 }
declare i32 @foo(i32 %x)
; Function Attrs: nounwind uwtable
define void @sink_store(%struct.node* nocapture %r, i32 %index) {
entry:
%node.0.in16 = getelementptr inbounds %struct.node, %struct.node* %r, i64 0, i32 2
%node.017 = load %struct.node*, %struct.node** %node.0.in16, align 8
%index.addr = alloca i32, align 4
store i32 %index, i32* %index.addr, align 4
%0 = load i32, i32* %index.addr, align 4
%cmp = icmp slt i32 %0, 0
br i1 %cmp, label %if.then, label %if.else
; CHECK: if.then
if.then: ; preds = %entry
%1 = load i32, i32* %index.addr, align 4
%p1 = getelementptr inbounds %struct.node, %struct.node* %node.017, i32 0, i32 6
; CHECK: store i32
store i32 %1, i32* %p1, align 4
br label %if.end
; CHECK: if.else
if.else: ; preds = %entry
%2 = load i32, i32* %index.addr, align 4
%add = add nsw i32 %2, 1
%p3 = getelementptr inbounds %struct.node, %struct.node* %node.017, i32 0, i32 6
; CHECK: store i32
store i32 %add, i32* %p3, align 4
call i32 @foo(i32 5) ;barrier
br label %if.end
; CHECK: if.end
if.end: ; preds = %if.else, %if.then
; CHECK-NOT: store
ret void
}

View File

@ -1,106 +0,0 @@
; ModuleID = 'bug.c'
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
; RUN: opt -O2 -S < %s | FileCheck %s
; CHECK-LABEL: main
; CHECK: if.end
; CHECK: store
; CHECK: memset
; CHECK: if.then
; CHECK: store
; CHECK: memset
@d = common global i32 0, align 4
@b = common global i32 0, align 4
@f = common global [1 x [3 x i8]] zeroinitializer, align 1
@e = common global i32 0, align 4
@c = common global i32 0, align 4
@a = common global i32 0, align 4
; Function Attrs: nounwind uwtable
define void @fn1() {
entry:
store i32 0, i32* @d, align 4
br label %for.cond
for.cond: ; preds = %for.inc8, %entry
%0 = load i32, i32* @d, align 4
%cmp = icmp slt i32 %0, 2
br i1 %cmp, label %for.body, label %for.end10
for.body: ; preds = %for.cond
%1 = load i32, i32* @d, align 4
%idxprom = sext i32 %1 to i64
%2 = load i32, i32* @b, align 4
%idxprom1 = sext i32 %2 to i64
%arrayidx = getelementptr inbounds [1 x [3 x i8]], [1 x [3 x i8]]* @f, i32 0, i64 %idxprom1
%arrayidx2 = getelementptr inbounds [3 x i8], [3 x i8]* %arrayidx, i32 0, i64 %idxprom
store i8 0, i8* %arrayidx2, align 1
store i32 0, i32* @e, align 4
br label %for.cond3
for.cond3: ; preds = %for.inc, %for.body
%3 = load i32, i32* @e, align 4
%cmp4 = icmp slt i32 %3, 3
br i1 %cmp4, label %for.body5, label %for.end
for.body5: ; preds = %for.cond3
%4 = load i32, i32* @c, align 4
%tobool = icmp ne i32 %4, 0
br i1 %tobool, label %if.then, label %if.end
if.then: ; preds = %for.body5
%5 = load i32, i32* @a, align 4
%dec = add nsw i32 %5, -1
store i32 %dec, i32* @a, align 4
br label %if.end
if.end: ; preds = %if.then, %for.body5
%6 = load i32, i32* @e, align 4
%idxprom6 = sext i32 %6 to i64
%arrayidx7 = getelementptr inbounds [3 x i8], [3 x i8]* getelementptr inbounds ([1 x [3 x i8]], [1 x [3 x i8]]* @f, i32 0, i64 0), i32 0, i64 %idxprom6
store i8 1, i8* %arrayidx7, align 1
br label %for.inc
for.inc: ; preds = %if.end
%7 = load i32, i32* @e, align 4
%inc = add nsw i32 %7, 1
store i32 %inc, i32* @e, align 4
br label %for.cond3
for.end: ; preds = %for.cond3
br label %for.inc8
for.inc8: ; preds = %for.end
%8 = load i32, i32* @d, align 4
%inc9 = add nsw i32 %8, 1
store i32 %inc9, i32* @d, align 4
br label %for.cond
for.end10: ; preds = %for.cond
ret void
}
; Function Attrs: nounwind uwtable
define i32 @main() {
entry:
%retval = alloca i32, align 4
store i32 0, i32* %retval
call void @fn1()
%0 = load i8, i8* getelementptr inbounds ([1 x [3 x i8]], [1 x [3 x i8]]* @f, i32 0, i64 0, i64 1), align 1
%conv = sext i8 %0 to i32
%cmp = icmp ne i32 %conv, 1
br i1 %cmp, label %if.then, label %if.end
if.then: ; preds = %entry
call void @abort()
unreachable
if.end: ; preds = %entry
ret i32 0
}
; Function Attrs: noreturn nounwind
declare void @abort()

View File

@ -1,45 +0,0 @@
; Test to make sure that stores in a diamond get merged with a non barrier function call after the store instruction
; Stores sunks into the footer.
; RUN: opt -basicaa -memdep -mldst-motion -S < %s | FileCheck %s
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
%struct.node = type { i32, %struct.node*, %struct.node*, %struct.node*, i32, i32, i32, i32 }
declare i32 @foo(i32 %x) #0
; Function Attrs: nounwind uwtable
define void @sink_store(%struct.node* nocapture %r, i32 %index) {
entry:
%node.0.in16 = getelementptr inbounds %struct.node, %struct.node* %r, i64 0, i32 2
%node.017 = load %struct.node*, %struct.node** %node.0.in16, align 8
%index.addr = alloca i32, align 4
store i32 %index, i32* %index.addr, align 4
%0 = load i32, i32* %index.addr, align 4
%cmp = icmp slt i32 %0, 0
br i1 %cmp, label %if.then, label %if.else
; CHECK: if.then
if.then: ; preds = %entry
%1 = load i32, i32* %index.addr, align 4
%p1 = getelementptr inbounds %struct.node, %struct.node* %node.017, i32 0, i32 6
; CHECK-NOT: store i32
store i32 %1, i32* %p1, align 4
br label %if.end
; CHECK: if.else
if.else: ; preds = %entry
%2 = load i32, i32* %index.addr, align 4
%add = add nsw i32 %2, 1
%p3 = getelementptr inbounds %struct.node, %struct.node* %node.017, i32 0, i32 6
; CHECK-NOT: store i32
store i32 %add, i32* %p3, align 4
call i32 @foo(i32 5) nounwind ;not a barrier
br label %if.end
; CHECK: if.end
if.end: ; preds = %if.else, %if.then
; CHECK: store
ret void
}
attributes #0 = { readnone }

View File

@ -1,43 +0,0 @@
; Test to make sure that stores in a diamond get merged with a non barrier load after the store instruction
; Stores sunks into the footer.
; RUN: opt -basicaa -memdep -mldst-motion -S < %s | FileCheck %s
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
%struct.node = type { i32, %struct.node*, %struct.node*, %struct.node*, i32, i32, i32, i32 }
; Function Attrs: nounwind uwtable
define void @sink_store(%struct.node* nocapture %r, i32 %index) {
entry:
%node.0.in16 = getelementptr inbounds %struct.node, %struct.node* %r, i64 0, i32 2
%node.017 = load %struct.node*, %struct.node** %node.0.in16, align 8
%index.addr = alloca i32, align 4
store i32 %index, i32* %index.addr, align 4
%0 = load i32, i32* %index.addr, align 4
%cmp = icmp slt i32 %0, 0
br i1 %cmp, label %if.then, label %if.else
; CHECK: if.then
if.then: ; preds = %entry
%1 = load i32, i32* %index.addr, align 4
%p1 = getelementptr inbounds %struct.node, %struct.node* %node.017, i32 0, i32 6
; CHECK-NOT: store i32
store i32 %1, i32* %p1, align 4
%p2 = getelementptr inbounds %struct.node, %struct.node* %node.017, i32 5, i32 6
; CHECK: load i32, i32*
%not_barrier = load i32 , i32 * %p2, align 4
br label %if.end
; CHECK: if.else
if.else: ; preds = %entry
%2 = load i32, i32* %index.addr, align 4
%add = add nsw i32 %2, 1
%p3 = getelementptr inbounds %struct.node, %struct.node* %node.017, i32 0, i32 6
; CHECK-NOT: store i32
store i32 %add, i32* %p3, align 4
br label %if.end
; CHECK: if.end
if.end: ; preds = %if.else, %if.then
; CHECK: store
ret void
}

View File

@ -1,42 +0,0 @@
; Test to make sure that stores in a diamond get merged with a non barrier store after the store instruction to be sunk
; Stores sunks into the footer.
; RUN: opt -basicaa -memdep -mldst-motion -S < %s | FileCheck %s
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
%struct.node = type { i32, %struct.node*, %struct.node*, %struct.node*, i32, i32, i32, i32 }
; Function Attrs: nounwind uwtable
define void @sink_store(%struct.node* nocapture %r, i32 %index) {
entry:
%node.0.in16 = getelementptr inbounds %struct.node, %struct.node* %r, i64 0, i32 2
%node.017 = load %struct.node*, %struct.node** %node.0.in16, align 8
%index.addr = alloca i32, align 4
store i32 %index, i32* %index.addr, align 4
%0 = load i32, i32* %index.addr, align 4
%cmp = icmp slt i32 %0, 0
br i1 %cmp, label %if.then, label %if.else
; CHECK: if.then
if.then: ; preds = %entry
%1 = load i32, i32* %index.addr, align 4
%p1 = getelementptr inbounds %struct.node, %struct.node* %node.017, i32 0, i32 6
; CHECK-NOT: store i32
store i32 %1, i32* %p1, align 4
br label %if.end
; CHECK: if.else
if.else: ; preds = %entry
%2 = load i32, i32* %index.addr, align 4
%add = add nsw i32 %2, 1
%p2 = getelementptr inbounds %struct.node, %struct.node* %node.017, i32 0, i32 6
store i32 %add, i32* %p2, align 4
%p3 = getelementptr inbounds %struct.node, %struct.node* %node.017, i32 5, i32 6
; CHECK: store i32
store i32 %add, i32* %p3, align 4 ; This is not a barrier
br label %if.end
; CHECK: if.end
if.end: ; preds = %if.else, %if.then
; CHECK: store
ret void
}

View File

@ -1,47 +0,0 @@
; Test to make sure that stores in a diamond get merged
; Stores sunks into the footer.
; RUN: opt -basicaa -memdep -mldst-motion -S < %s | FileCheck %s
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
%struct.node = type { i32, %struct.node*, %struct.node*, %struct.node*, i32, i32, i32, i32 }
; Function Attrs: nounwind uwtable
define void @sink_store(%struct.node* nocapture %r, i32 %index) {
entry:
%node.0.in16 = getelementptr inbounds %struct.node, %struct.node* %r, i64 0, i32 2
%node.017 = load %struct.node*, %struct.node** %node.0.in16, align 8
%index.addr = alloca i32, align 4
store i32 %index, i32* %index.addr, align 4
%0 = load i32, i32* %index.addr, align 4
%cmp = icmp slt i32 %0, 0
br i1 %cmp, label %if.then, label %if.else
; CHECK: if.then
if.then: ; preds = %entry
%1 = load i32, i32* %index.addr, align 4
%p1 = getelementptr inbounds %struct.node, %struct.node* %node.017, i32 0, i32 6
; CHECK-NOT: store i32
store i32 %1, i32* %p1, align 4
%p2 = getelementptr inbounds %struct.node, %struct.node* %node.017, i32 4, i32 6
; CHECK-NOT: store i32
store i32 %1, i32* %p2, align 4
br label %if.end
; CHECK: if.else
if.else: ; preds = %entry
%2 = load i32, i32* %index.addr, align 4
%add = add nsw i32 %2, 1
%p3 = getelementptr inbounds %struct.node, %struct.node* %node.017, i32 0, i32 6
; CHECK-NOT: store i32
store i32 %add, i32* %p3, align 4
%p4 = getelementptr inbounds %struct.node, %struct.node* %node.017, i32 4, i32 6
; CHECK-NOT: store i32
store i32 %2, i32* %p4, align 4
br label %if.end
; CHECK: if.end
if.end: ; preds = %if.else, %if.then
; CHECK: store
; CHECK: store
ret void
}

View File

@ -1,42 +0,0 @@
; Test to make sure that load from the same address as a store and appears after the store prevents the store from being sunk
; RUN: opt -basicaa -memdep -mldst-motion -S < %s | FileCheck %s
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
%struct.node = type { i32, %struct.node*, %struct.node*, %struct.node*, i32, i32, i32, i32 }
; Function Attrs: nounwind uwtable
define void @sink_store(%struct.node* nocapture %r, i32 %index) {
entry:
%node.0.in16 = getelementptr inbounds %struct.node, %struct.node* %r, i64 0, i32 2
%node.017 = load %struct.node*, %struct.node** %node.0.in16, align 8
%index.addr = alloca i32, align 4
store i32 %index, i32* %index.addr, align 4
%0 = load i32, i32* %index.addr, align 4
%cmp = icmp slt i32 %0, 0
br i1 %cmp, label %if.then, label %if.else
; CHECK: if.then
if.then: ; preds = %entry
%1 = load i32, i32* %index.addr, align 4
%p1 = getelementptr inbounds %struct.node, %struct.node* %node.017, i32 0, i32 6
; CHECK: store i32
store i32 %1, i32* %p1, align 4
%p2 = getelementptr inbounds %struct.node, %struct.node* %node.017, i32 0, i32 6
; CHECK: load i32, i32*
%barrier = load i32 , i32 * %p2, align 4
br label %if.end
; CHECK: if.else
if.else: ; preds = %entry
%2 = load i32, i32* %index.addr, align 4
%add = add nsw i32 %2, 1
%p3 = getelementptr inbounds %struct.node, %struct.node* %node.017, i32 0, i32 6
; CHECK: store i32
store i32 %add, i32* %p3, align 4
br label %if.end
; CHECK: if.end
if.end: ; preds = %if.else, %if.then
; CHECK-NOT: store
ret void
}