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,15 +0,0 @@
; RUN: opt < %s -ipconstprop -S | grep "ret i32 %r"
; Should not propagate the result of a weak function.
; PR2411
define weak i32 @foo() nounwind {
entry:
ret i32 1
}
define i32 @main() nounwind {
entry:
%r = call i32 @foo( ) nounwind
ret i32 %r
}

View File

@ -1,40 +0,0 @@
; RUN: opt < %s -ipsccp -S | FileCheck %s
; Don't constant-propagate byval pointers, since they are not pointers!
; PR5038
%struct.MYstr = type { i8, i32 }
@mystr = internal global %struct.MYstr zeroinitializer ; <%struct.MYstr*> [#uses=3]
define internal void @vfu1(%struct.MYstr* byval align 4 %u) nounwind {
entry:
%0 = getelementptr %struct.MYstr, %struct.MYstr* %u, i32 0, i32 1 ; <i32*> [#uses=1]
store i32 99, i32* %0, align 4
; CHECK: %struct.MYstr* %u
%1 = getelementptr %struct.MYstr, %struct.MYstr* %u, i32 0, i32 0 ; <i8*> [#uses=1]
store i8 97, i8* %1, align 4
; CHECK: %struct.MYstr* %u
br label %return
return: ; preds = %entry
ret void
}
define internal i32 @vfu2(%struct.MYstr* byval align 4 %u) nounwind readonly {
entry:
%0 = getelementptr %struct.MYstr, %struct.MYstr* %u, i32 0, i32 1 ; <i32*> [#uses=1]
%1 = load i32, i32* %0
; CHECK: load i32, i32* getelementptr inbounds (%struct.MYstr, %struct.MYstr* @mystr, i32 0, i32 1)
%2 = getelementptr %struct.MYstr, %struct.MYstr* %u, i32 0, i32 0 ; <i8*> [#uses=1]
%3 = load i8, i8* %2
; CHECK: load i8, i8* getelementptr inbounds (%struct.MYstr, %struct.MYstr* @mystr, i32 0, i32 0)
%4 = zext i8 %3 to i32
%5 = add i32 %4, %1
ret i32 %5
}
define i32 @unions() nounwind {
entry:
call void @vfu1(%struct.MYstr* byval align 4 @mystr) nounwind
%result = call i32 @vfu2(%struct.MYstr* byval align 4 @mystr) nounwind
ret i32 %result
}

View File

@ -1,26 +0,0 @@
; RUN: opt < %s -S -ipsccp | FileCheck %s
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
define i64 @fn2() {
entry:
%conv = sext i32 undef to i64
%div = sdiv i64 8, %conv
%call2 = call i64 @fn1(i64 %div)
ret i64 %call2
}
; CHECK-DAG: define i64 @fn2(
; CHECK: %[[CALL:.*]] = call i64 @fn1(i64 undef)
define internal i64 @fn1(i64 %p1) {
entry:
%tobool = icmp ne i64 %p1, 0
%cond = select i1 %tobool, i64 %p1, i64 %p1
ret i64 %cond
}
; CHECK-DAG: define internal i64 @fn1(
; CHECK: %[[SEL:.*]] = select i1 undef, i64 undef, i64 undef
; CHECK: ret i64 %[[SEL]]

View File

@ -1,31 +0,0 @@
; RUN: opt < %s -S -ipsccp | FileCheck %s
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
define void @fn2() {
entry:
br label %if.end
for.cond1: ; preds = %if.end, %for.end
br i1 undef, label %if.end, label %if.end
if.end: ; preds = %lbl, %for.cond1
%e.2 = phi i32* [ undef, %entry ], [ null, %for.cond1 ], [ null, %for.cond1 ]
%0 = load i32, i32* %e.2, align 4
%call = call i32 @fn1(i32 %0)
br label %for.cond1
}
define internal i32 @fn1(i32 %p1) {
entry:
%tobool = icmp ne i32 %p1, 0
%cond = select i1 %tobool, i32 %p1, i32 %p1
ret i32 %cond
}
; CHECK-LABEL: define void @fn2(
; CHECK: call i32 @fn1(i32 undef)
; CHECK-LABEL: define internal i32 @fn1(
; CHECK:%[[COND:.*]] = select i1 undef, i32 undef, i32 undef
; CHECK: ret i32 %[[COND]]

View File

@ -1,28 +0,0 @@
; RUN: opt < %s -ipconstprop -S | FileCheck %s
; See PR26774
define i32 @baz() {
ret i32 10
}
; We can const-prop @baz's return value *into* @foo, but cannot
; constprop @foo's return value into bar.
define linkonce_odr i32 @foo() {
; CHECK-LABEL: @foo(
; CHECK-NEXT: %val = call i32 @baz()
; CHECK-NEXT: ret i32 10
%val = call i32 @baz()
ret i32 %val
}
define i32 @bar() {
; CHECK-LABEL: @bar(
; CHECK-NEXT: %val = call i32 @foo()
; CHECK-NEXT: ret i32 %val
%val = call i32 @foo()
ret i32 %val
}

View File

@ -1,42 +0,0 @@
; RUN: opt < %s -internalize -ipsccp -S | FileCheck %s
; PR5569
; IPSCCP should prove that the blocks are dead and delete them, and
; properly handle the dangling blockaddress constants.
; CHECK: @bar.l = internal constant [2 x i8*] [i8* inttoptr (i32 1 to i8*), i8* inttoptr (i32 1 to i8*)]
@code = global [5 x i32] [i32 0, i32 0, i32 0, i32 0, i32 1], align 4 ; <[5 x i32]*> [#uses=0]
@bar.l = internal constant [2 x i8*] [i8* blockaddress(@bar, %lab0), i8* blockaddress(@bar, %end)] ; <[2 x i8*]*> [#uses=1]
define void @foo(i32 %x) nounwind readnone {
entry:
%b = alloca i32, align 4 ; <i32*> [#uses=1]
store volatile i32 -1, i32* %b
ret void
}
define void @bar(i32* nocapture %pc) nounwind readonly {
entry:
br label %indirectgoto
lab0: ; preds = %indirectgoto
%indvar.next = add i32 %indvar, 1 ; <i32> [#uses=1]
br label %indirectgoto
end: ; preds = %indirectgoto
ret void
indirectgoto: ; preds = %lab0, %entry
%indvar = phi i32 [ %indvar.next, %lab0 ], [ 0, %entry ] ; <i32> [#uses=2]
%pc.addr.0 = getelementptr i32, i32* %pc, i32 %indvar ; <i32*> [#uses=1]
%tmp1.pn = load i32, i32* %pc.addr.0 ; <i32> [#uses=1]
%indirect.goto.dest.in = getelementptr inbounds [2 x i8*], [2 x i8*]* @bar.l, i32 0, i32 %tmp1.pn ; <i8**> [#uses=1]
%indirect.goto.dest = load i8*, i8** %indirect.goto.dest.in ; <i8*> [#uses=1]
indirectbr i8* %indirect.goto.dest, [label %lab0, label %end]
}
define i32 @main() nounwind readnone {
entry:
ret i32 0
}

View File

@ -1,6 +0,0 @@
; RUN: opt < %s -ipconstprop -disable-output
define internal void @foo(i32 %X) {
call void @foo( i32 %X )
ret void
}

View File

@ -1,52 +0,0 @@
; RUN: opt -S -ipsccp < %s | FileCheck %s
target datalayout = "E-m:e-i64:64-n32:64"
target triple = "powerpc64-bgq-linux"
define void @test(i32 signext %n) {
; CHECK-LABEL: @test
entry:
br i1 undef, label %if.then, label %if.end
if.then: ; preds = %entry
ret void
if.end: ; preds = %entry
br i1 undef, label %if.then2, label %if.end4
if.then2: ; preds = %if.end
unreachable
if.end4: ; preds = %if.end
%sub.n = select i1 undef, i32 undef, i32 %n
switch i32 %sub.n, label %if.else14 [
i32 0, label %if.then9
i32 1, label %if.then12
]
if.then9: ; preds = %if.end4
unreachable
if.then12: ; preds = %if.end4
unreachable
if.else14: ; preds = %if.end4
br label %do.body
do.body: ; preds = %do.body, %if.else14
%scale.0 = phi ppc_fp128 [ 0xM3FF00000000000000000000000000000, %if.else14 ], [ %scale.0, %do.body ]
br i1 undef, label %do.body, label %if.then33
if.then33: ; preds = %do.body
br i1 undef, label %_ZN5boost4math4signIgEEiRKT_.exit30, label %cond.false.i28
cond.false.i28: ; preds = %if.then33
%0 = bitcast ppc_fp128 %scale.0 to i128
%tobool.i26 = icmp slt i128 %0, 0
br label %_ZN5boost4math4signIgEEiRKT_.exit30
_ZN5boost4math4signIgEEiRKT_.exit30: ; preds = %cond.false.i28, %if.then33
unreachable
}

View File

@ -1,27 +0,0 @@
; RUN: opt < %s -S -passes=ipsccp | FileCheck %s
; RUN: opt < %s -S -ipsccp | FileCheck %s
@_ZL6test1g = internal global i32 42, align 4
define void @_Z7test1f1v() nounwind {
entry:
%tmp = load i32, i32* @_ZL6test1g, align 4
%cmp = icmp eq i32 %tmp, 0
br i1 %cmp, label %if.then, label %if.end
if.then: ; preds = %entry
store i32 0, i32* @_ZL6test1g, align 4
br label %if.end
if.end: ; preds = %if.then, %entry
ret void
}
; CHECK: @_Z7test1f2v()
; CHECK: entry:
; CHECK-NEXT: ret i32 42
define i32 @_Z7test1f2v() nounwind {
entry:
%tmp = load i32, i32* @_ZL6test1g, align 4
ret i32 %tmp
}

View File

@ -1,58 +0,0 @@
; RUN: opt < %s -ipsccp -S | FileCheck %s
; PR36485
; musttail call result can\'t be replaced with a constant, unless the call
; can be removed
declare i32 @external()
define i8* @start(i8 %v) {
%c1 = icmp eq i8 %v, 0
br i1 %c1, label %true, label %false
true:
; CHECK: %ca = musttail call i8* @side_effects(i8 %v)
; CHECK: ret i8* %ca
%ca = musttail call i8* @side_effects(i8 %v)
ret i8* %ca
false:
%c2 = icmp eq i8 %v, 1
br i1 %c2, label %c2_true, label %c2_false
c2_true:
; CHECK: %ca1 = musttail call i8* @no_side_effects(i8 %v)
; CHECK: ret i8* %ca1
%ca1 = musttail call i8* @no_side_effects(i8 %v)
ret i8* %ca1
c2_false:
; CHECK: %ca2 = musttail call i8* @dont_zap_me(i8 %v)
; CHECK: ret i8* %ca2
%ca2 = musttail call i8* @dont_zap_me(i8 %v)
ret i8* %ca2
}
define internal i8* @side_effects(i8 %v) {
%i1 = call i32 @external()
; since this goes back to `start` the SCPP should be see that the return value
; is always `null`.
; The call can't be removed due to `external` call above, though.
; CHECK: %ca = musttail call i8* @start(i8 %v)
%ca = musttail call i8* @start(i8 %v)
; Thus the result must be returned anyway
; CHECK: ret i8* %ca
ret i8* %ca
}
define internal i8* @no_side_effects(i8 %v) readonly nounwind {
; CHECK: ret i8* null
ret i8* null
}
define internal i8* @dont_zap_me(i8 %v) {
%i1 = call i32 @external()
; The call to this function cannot be removed due to side effects. Thus the
; return value should stay as it is, and should not be zapped.
; CHECK: ret i8* null
ret i8* null
}

View File

@ -1,29 +0,0 @@
; RUN: opt -ipsccp -S %s | FileCheck %s
; RUN: opt -ipconstprop -S %s | FileCheck %s
target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
target triple = "i686-pc-windows-msvc19.0.24215"
define i32 @dipsy(i32, i32) local_unnamed_addr #0 {
BasicBlock0:
call void asm "\0D\0Apushl %ebp\0D\0Amovl 8(%esp),%eax\0D\0Amovl 12(%esp), %ebp\0D\0Acalll *%eax\0D\0Apopl %ebp\0D\0Aretl\0D\0A", ""()
ret i32 0
}
define void @tinkywinky(i32, i32, i32) local_unnamed_addr #0 {
BasicBlock1:
call void asm "\0D\0A movl 12(%esp), %ebp\0D\0A movl 4(%esp), %eax\0D\0A movl 8(%esp), %esp\0D\0A jmpl *%eax\0D\0A", ""()
ret void
}
define void @patatino(i32, i32, i32) local_unnamed_addr #1 {
bb:
%3 = tail call i32 @dipsy(i32 %0, i32 %1) #0
; Check that we don't accidentally propagate zero.
; CHECK: @tinkywinky(i32 %3, i32 %2, i32 %1) #0
tail call void @tinkywinky(i32 %3, i32 %2, i32 %1) #0
ret void
}
attributes #0 = { naked }
attributes #1 = { "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" }

View File

@ -1,12 +0,0 @@
; RUN: opt < %s -ipconstprop -deadargelim -S | not grep %X
define internal i32 @foo(i32 %X) {
%Y = call i32 @foo( i32 %X ) ; <i32> [#uses=1]
%Z = add i32 %Y, 1 ; <i32> [#uses=1]
ret i32 %Z
}
define void @bar() {
call i32 @foo( i32 17 ) ; <i32>:1 [#uses=0]
ret void
}

View File

@ -1,57 +0,0 @@
; RUN: opt < %s -ipconstprop -S > %t
; RUN: cat %t | grep "store i32 %Z, i32\* %Q"
; RUN: cat %t | grep "add i32 1, 3"
;; This function returns its second argument on all return statements
define internal i32* @incdec(i1 %C, i32* %V) {
%X = load i32, i32* %V
br i1 %C, label %T, label %F
T: ; preds = %0
%X1 = add i32 %X, 1
store i32 %X1, i32* %V
ret i32* %V
F: ; preds = %0
%X2 = sub i32 %X, 1
store i32 %X2, i32* %V
ret i32* %V
}
;; This function returns its first argument as a part of a multiple return
;; value
define internal { i32, i32 } @foo(i32 %A, i32 %B) {
%X = add i32 %A, %B
%Y = insertvalue { i32, i32 } undef, i32 %A, 0
%Z = insertvalue { i32, i32 } %Y, i32 %X, 1
ret { i32, i32 } %Z
}
define void @caller(i1 %C) personality i32 (...)* @__gxx_personality_v0 {
%Q = alloca i32
;; Call incdec to see if %W is properly replaced by %Q
%W = call i32* @incdec(i1 %C, i32* %Q ) ; <i32> [#uses=1]
;; Call @foo twice, to prevent the arguments from propagating into the
;; function (so we can check the returned argument is properly
;; propagated per-caller).
%S1 = call { i32, i32 } @foo(i32 1, i32 2)
%X1 = extractvalue { i32, i32 } %S1, 0
%S2 = invoke { i32, i32 } @foo(i32 3, i32 4) to label %OK unwind label %LPAD
OK:
%X2 = extractvalue { i32, i32 } %S2, 0
;; Do some stuff with the returned values which we can grep for
%Z = add i32 %X1, %X2
store i32 %Z, i32* %W
br label %RET
LPAD:
%exn = landingpad {i8*, i32}
cleanup
br label %RET
RET:
ret void
}
declare i32 @__gxx_personality_v0(...)

View File

@ -1,29 +0,0 @@
; RUN: opt < %s -ipconstprop -instcombine -S | grep "ret i1 true" | count 2
define internal i32 @foo(i1 %C) {
br i1 %C, label %T, label %F
T: ; preds = %0
ret i32 52
F: ; preds = %0
ret i32 52
}
define i1 @caller(i1 %C) {
%X = call i32 @foo( i1 %C ) ; <i32> [#uses=1]
%Y = icmp ne i32 %X, 0 ; <i1> [#uses=1]
ret i1 %Y
}
define i1 @invokecaller(i1 %C) personality i32 (...)* @__gxx_personality_v0 {
%X = invoke i32 @foo( i1 %C ) to label %OK unwind label %FAIL ; <i32> [#uses=1]
OK:
%Y = icmp ne i32 %X, 0 ; <i1> [#uses=1]
ret i1 %Y
FAIL:
%exn = landingpad {i8*, i32}
cleanup
ret i1 false
}
declare i32 @__gxx_personality_v0(...)

View File

@ -1,46 +0,0 @@
; RUN: opt < %s -ipconstprop -S > %t
;; Check that the 21 constants got propagated properly
; RUN: cat %t | grep "%M = add i32 21, 21"
;; Check that the second return values didn't get propagated
; RUN: cat %t | grep "%N = add i32 %B, %D"
%0 = type { i32, i32 }
define internal %0 @foo(i1 %Q) {
br i1 %Q, label %T, label %F
T: ; preds = %0
%mrv = insertvalue %0 undef, i32 21, 0
%mrv1 = insertvalue %0 %mrv, i32 22, 1
ret %0 %mrv1
F: ; preds = %0
%mrv2 = insertvalue %0 undef, i32 21, 0
%mrv3 = insertvalue %0 %mrv2, i32 23, 1
ret %0 %mrv3
}
define internal %0 @bar(i1 %Q) {
%A = insertvalue %0 undef, i32 21, 0
br i1 %Q, label %T, label %F
T: ; preds = %0
%B = insertvalue %0 %A, i32 22, 1
ret %0 %B
F: ; preds = %0
%C = insertvalue %0 %A, i32 23, 1
ret %0 %C
}
define %0 @caller(i1 %Q) {
%X = call %0 @foo(i1 %Q)
%A = extractvalue %0 %X, 0
%B = extractvalue %0 %X, 1
%Y = call %0 @bar(i1 %Q)
%C = extractvalue %0 %Y, 0
%D = extractvalue %0 %Y, 1
%M = add i32 %A, %C
%N = add i32 %B, %D
ret %0 %X
}

View File

@ -1,34 +0,0 @@
; RUN: opt < %s -S -ipsccp | FileCheck %s
; PR5596
; IPSCCP should propagate the 0 argument, eliminate the switch, and propagate
; the result.
; CHECK: define i32 @main() #0 {
; CHECK-NEXT: entry:
; CHECK-NEXT: %call2 = tail call i32 @wwrite(i64 0) [[NUW:#[0-9]+]]
; CHECK-NEXT: ret i32 123
define i32 @main() noreturn nounwind {
entry:
%call2 = tail call i32 @wwrite(i64 0) nounwind
ret i32 %call2
}
define internal i32 @wwrite(i64 %i) nounwind readnone {
entry:
switch i64 %i, label %sw.default [
i64 3, label %return
i64 10, label %return
]
sw.default:
ret i32 123
return:
ret i32 0
}
; CHECK: attributes #0 = { noreturn nounwind }
; CHECK: attributes #1 = { nounwind readnone }
; CHECK: attributes [[NUW]] = { nounwind }