Imported Upstream version 5.18.0.234

Former-commit-id: 8071ec1a8c5eaa9be24b41745add19297608001f
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2019-01-08 08:22:36 +00:00
parent f32dbaf0b2
commit 212f6bafcb
28494 changed files with 359 additions and 3867025 deletions

View File

@@ -1,11 +0,0 @@
; RUN: opt < %s -globaldce
;
define internal void @func() {
ret void
}
define void @main() {
%X = bitcast void ()* @func to i32* ; <i32*> [#uses=0]
ret void
}

View File

@@ -1,13 +0,0 @@
; RUN: opt < %s -globaldce
;
@X = global void ()* @func ; <void ()**> [#uses=0]
; Not dead, can be reachable via X
define internal void @func() {
ret void
}
define void @main() {
ret void
}

View File

@@ -1,18 +0,0 @@
; Make sure that functions are removed successfully if they are referred to by
; a global that is dead. Make sure any globals they refer to die as well.
; RUN: opt < %s -globaldce -S | FileCheck %s
; CHECK-NOT: foo
;; Unused, kills %foo
@b = internal global i32 ()* @foo ; <i32 ()**> [#uses=0]
;; Should die when function %foo is killed
@foo.upgrd.1 = internal global i32 7 ; <i32*> [#uses=1]
;; dies when %b dies.
define internal i32 @foo() {
%ret = load i32, i32* @foo.upgrd.1 ; <i32> [#uses=1]
ret i32 %ret
}

View File

@@ -1,14 +0,0 @@
; This testcase tests that a worklist is being used, and that globals can be
; removed if they are the subject of a constexpr and ConstantPointerRef
; RUN: opt < %s -globaldce -S | FileCheck %s
; CHECK-NOT: global
@t0 = internal global [4 x i8] c"foo\00" ; <[4 x i8]*> [#uses=1]
@t1 = internal global [4 x i8] c"bar\00" ; <[4 x i8]*> [#uses=1]
@s1 = internal global [1 x i8*] [ i8* getelementptr ([4 x i8], [4 x i8]* @t0, i32 0, i32 0) ] ; <[1 x i8*]*> [#uses=0]
@s2 = internal global [1 x i8*] [ i8* getelementptr ([4 x i8], [4 x i8]* @t1, i64 0, i64 0) ] ; <[1 x i8*]*> [#uses=0]
@b = internal global i32* @a ; <i32**> [#uses=0]
@a = internal global i32 7 ; <i32*> [#uses=1]

View File

@@ -1,11 +0,0 @@
; RUN: opt < %s -globaldce
;; Should die when function %foo is killed
@foo.upgrd.1 = internal global i32 7 ; <i32*> [#uses=3]
@bar = internal global [2 x { i32*, i32 }] [ { i32*, i32 } { i32* @foo.upgrd.1, i32 7 }, { i32*, i32 } { i32* @foo.upgrd.1, i32 1 } ] ; <[2 x { i32*, i32 }]*> [#uses=0]
define internal i32 @foo() {
%ret = load i32, i32* @foo.upgrd.1 ; <i32> [#uses=1]
ret i32 %ret
}

View File

@@ -1,13 +0,0 @@
; distilled from 255.vortex
; RUN: opt < %s -globaldce -S | FileCheck %s
; CHECK-NOT: testfunc
declare i1 ()* @getfunc()
define internal i1 @testfunc() {
%F = call i1 ()* () @getfunc( ) ; <i1 ()*> [#uses=1]
%c = icmp eq i1 ()* %F, @testfunc ; <i1> [#uses=1]
ret i1 %c
}

View File

@@ -1,6 +0,0 @@
; Weak variables should be preserved by global DCE!
; RUN: opt < %s -globaldce -S | FileCheck %s
; CHECK: @A
@A = weak global i32 54

View File

@@ -1,18 +0,0 @@
; RUN: opt < %s -globaldce -S > %t
; RUN: FileCheck %s < %t
; RUN: FileCheck --check-prefix=DEAD %s < %t
@A = global i32 0
; CHECK: @A = global i32 0
@D = internal alias i32, i32* @A
; DEAD-NOT: @D
@L1 = alias i32, i32* @A
; CHECK: @L1 = alias i32, i32* @A
@L2 = internal alias i32, i32* @L1
; CHECK: @L2 = internal alias i32, i32* @L1
@L3 = alias i32, i32* @L2
; CHECK: @L3 = alias i32, i32* @L2

View File

@@ -1,4 +0,0 @@
; RUN: opt < %s -globaldce
@A = internal alias void (), void ()* @F
define internal void @F() { ret void }

View File

@@ -1,6 +0,0 @@
; RUN: opt < %s -passes=globaldce -S | FileCheck %s
; CHECK-NOT: global
@X = external global i32
@Y = internal global i32 7

View File

@@ -1,178 +0,0 @@
; Test the behavior of GlobalDCE in conjunction with comdats.
;
; RUN: opt < %s -globaldce -S | FileCheck %s
; First test checks that if one function in a comdat group is used, both other
; functions and other globals even if unused will be preserved.
$test1_c = comdat any
; CHECK: $test1_c = comdat any
; Second test checks that if one function in a comdat group is used, both other
; functions and other globals even if unused will be preserved.
$test2_c = comdat any
; CHECK: $test2_c = comdat any
; Third test checks that calling a function in a comdat group with an alias
; preserves the alias.
$test3_c = comdat any
; CHECK: $test3_c = comdat any
; Fourth test checks that calling an alias in a comdat group with a function
; preserves the function. (This is the trivial case as the alias uses the
; function.)
$test4_c = comdat any
; CHECK: $test4_c = comdat any
; Fifth test checks that calling a function in a comdat group that is used as
; the resolver of an ifunc doesn't preserve that ifunc. ifunc symbols don't
; participate in the comdat group of their resolver function as they are
; considered separate objects.
$test5_c = comdat any
; CHECK: $test5_c = comdat any
; Sixth test checks that calling an ifunc whose resolver is in a comdat group
; preserves the resolver. This is the trivial case as the ifunc uses the
; resolver.
$test6_c = comdat any
; CHECK: $test6_c = comdat any
; Seventh test checks that we can eliminate a comdat when it has only one dead function participant.
$test7_c = comdat any
; CHECK-NOT: $test7_c = comdat any
; Eighth test checks that we can eliminate a comdat when it has only one dead global participant.
$test8_c = comdat any
; CHECK-NOT: $test8_c = comdat any
; Ninth test checks that we can eliminate a comdat when there are multiple
; dead participants.
$test9_c = comdat any
; CHECK-NOT: $test9_c = comdat any
; Tenth test checks that we can eliminate a comdat when it has multiple
; participants that form internal cyclic uses but are never used externally and
; thus the entire ifunc can safely be eliminated.
$test10_c = comdat any
; CHECK-NOT: $test10_c = comdat any
@test1_gv = linkonce_odr unnamed_addr global i32 42, comdat($test1_c)
; CHECK: @test1_gv = linkonce_odr unnamed_addr global
@test2_used = linkonce_odr unnamed_addr global i32 42, comdat($test2_c)
; CHECK: @test2_used = linkonce_odr unnamed_addr global
@test2_gv = linkonce_odr unnamed_addr global i32 42, comdat($test2_c)
; CHECK: @test2_gv = linkonce_odr unnamed_addr global
@test8_gv = linkonce_odr unnamed_addr global i32 42, comdat($test8_c)
; CHECK-NOT: @test8_gv
@test9_gv = linkonce_odr unnamed_addr global i32 42, comdat($test9_c)
; CHECK-NOT: @test9_gv
@test10_gv = linkonce_odr unnamed_addr global void ()* @test10_f, comdat($test10_c)
; CHECK-NOT: @test10_gv
@test3_a = linkonce_odr unnamed_addr alias void (), void ()* @test3_f
; CHECK: @test3_a = linkonce_odr unnamed_addr alias
@test4_a = linkonce_odr unnamed_addr alias void (), void ()* @test4_f
; CHECK: @test4_a = linkonce_odr unnamed_addr alias
@test10_a = linkonce_odr unnamed_addr alias void (), void ()* @test10_g
; CHECK-NOT: @test10_a
@test5_if = linkonce_odr ifunc void (), void ()* ()* @test5_f
; CHECK-NOT: @test5_if
@test6_if = linkonce_odr ifunc void (), void ()* ()* @test6_f
; CHECK: @test6_if = linkonce_odr ifunc
; This function is directly used and so cannot be eliminated.
define linkonce_odr void @test1_used() comdat($test1_c) {
; CHECK: define linkonce_odr void @test1_used()
entry:
ret void
}
define linkonce_odr void @test1_f() comdat($test1_c) {
; CHECK: define linkonce_odr void @test1_f()
entry:
ret void
}
; Now test that a function, global variable, alias, and ifunc in the same
; comdat are kept.
define linkonce_odr void @test2_f() comdat($test2_c) {
; CHECK: define linkonce_odr void @test2_f()
entry:
ret void
}
define linkonce_odr void @test3_f() comdat($test3_c) {
; CHECK: define linkonce_odr void @test3_f()
entry:
ret void
}
define linkonce_odr void @test4_f() comdat($test4_c) {
; CHECK: define linkonce_odr void @test4_f()
entry:
ret void
}
declare void @test_external()
define linkonce_odr void ()* @test5_f() comdat($test5_c) {
; CHECK: define linkonce_odr void ()* @test5_f()
entry:
ret void ()* @test_external
}
define linkonce_odr void ()* @test6_f() comdat($test6_c) {
; CHECK: define linkonce_odr void ()* @test6_f()
entry:
ret void ()* @test_external
}
define linkonce_odr void @test7_f() comdat($test7_c) {
; CHECK-NOT: @test7_f
entry:
ret void
}
define linkonce_odr void @test9_f() comdat($test9_c) {
; CHECK-NOT: @test9_f
entry:
ret void
}
define linkonce_odr void @test10_f() comdat($test10_c) {
; CHECK-NOT: @test10_f
entry:
%gv = load void ()*, void ()** @test10_gv
call void @test10_a()
ret void
}
define linkonce_odr void @test10_g() comdat($test10_c) {
; CHECK-NOT: @test10_g
entry:
call void @test10_f()
ret void
}
; An external function to pin as "used" various things above that shouldn't be
; eliminated.
define void @external_user() {
call void @test1_used()
%gv = load i32, i32* @test2_used
call void @test3_f()
call void @test4_a()
%fptr = call void() *@test5_f()
call void @test6_if()
ret void
}

View File

@@ -1,97 +0,0 @@
; RUN: opt -O2 -disable-output < %s
; PR15714
%struct.ham = type { i32 }
@global5 = common global i32 0, align 4
@global6 = common global i32 0, align 4
@global7 = common global i32 0, align 4
@global = common global i32 0, align 4
@global8 = common global %struct.ham zeroinitializer, align 4
@global9 = common global i32 0, align 4
@global10 = common global i32 0, align 4
@global11 = common global i32 0, align 4
define void @zot12() {
bb:
store i32 0, i32* @global5, align 4
store i32 0, i32* @global6, align 4
br label %bb2
bb1: ; preds = %bb11
%tmp = load i32, i32* @global5, align 4
br label %bb2
bb2: ; preds = %bb1, %bb
%tmp3 = phi i32 [ %tmp, %bb1 ], [ 0, %bb ]
%tmp4 = xor i32 %tmp3, zext (i1 icmp ne (i64 ptrtoint (i32* @global5 to i64), i64 1) to i32)
store i32 %tmp4, i32* @global5, align 4
%tmp5 = icmp eq i32 %tmp3, zext (i1 icmp ne (i64 ptrtoint (i32* @global5 to i64), i64 1) to i32)
br i1 %tmp5, label %bb8, label %bb6
bb6: ; preds = %bb2
%tmp7 = tail call i32 @quux13()
br label %bb8
bb8: ; preds = %bb6, %bb2
%tmp9 = load i32, i32* @global7, align 4
%tmp10 = icmp eq i32 %tmp9, 0
br i1 %tmp10, label %bb11, label %bb15
bb11: ; preds = %bb8
%tmp12 = load i32, i32* @global6, align 4
%tmp13 = add nsw i32 %tmp12, 1
store i32 %tmp13, i32* @global6, align 4
%tmp14 = icmp slt i32 %tmp13, 42
br i1 %tmp14, label %bb1, label %bb15
bb15: ; preds = %bb11, %bb8
ret void
}
define i32 @quux13() {
bb:
store i32 1, i32* @global5, align 4
ret i32 1
}
define void @wombat() {
bb:
tail call void @zot12()
ret void
}
define void @wombat14() {
bb:
tail call void @blam()
ret void
}
define void @blam() {
bb:
store i32 ptrtoint (i32* @global to i32), i32* getelementptr inbounds (%struct.ham, %struct.ham* @global8, i64 0, i32 0), align 4
store i32 0, i32* @global9, align 4
%tmp = load i32, i32* getelementptr inbounds (%struct.ham, %struct.ham* @global8, i64 0, i32 0), align 4
br label %bb1
bb1: ; preds = %bb1, %bb
%tmp2 = phi i32 [ 0, %bb ], [ %tmp11, %bb1 ]
%tmp3 = phi i32 [ %tmp, %bb ], [ %tmp10, %bb1 ]
%tmp4 = icmp sgt i32 %tmp3, 0
%tmp5 = zext i1 %tmp4 to i32
%tmp6 = urem i32 %tmp5, 5
%tmp7 = mul i32 %tmp3, -80
%tmp8 = or i32 %tmp7, %tmp6
%tmp9 = icmp eq i32 %tmp8, 0
%tmp10 = zext i1 %tmp9 to i32
%tmp11 = add nsw i32 %tmp2, 1
%tmp12 = icmp eq i32 %tmp11, 20
br i1 %tmp12, label %bb13, label %bb1
bb13: ; preds = %bb1
store i32 %tmp10, i32* getelementptr inbounds (%struct.ham, %struct.ham* @global8, i64 0, i32 0), align 4
store i32 0, i32* @global10, align 4
store i32 %tmp6, i32* @global11, align 4
store i32 20, i32* @global9, align 4
ret void
}

View File

@@ -1,24 +0,0 @@
; Make sure that if a pass like jump threading populates a function analysis
; like LVI with asserting handles into the body of a function, those don't begin
; to assert when global DCE deletes the body of the function.
;
; RUN: opt -disable-output < %s -passes='module(function(jump-threading),globaldce)'
; RUN: opt -disable-output < %s -passes='module(rpo-functionattrs,globaldce)'
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
declare i32 @bar()
define internal i32 @foo() {
entry:
%call4 = call i32 @bar()
%cmp5 = icmp eq i32 %call4, 0
br i1 %cmp5, label %if.then6, label %if.end8
if.then6:
ret i32 0
if.end8:
ret i32 1
}

View File

@@ -1,16 +0,0 @@
; RUN: opt -globaldce -simplifycfg -S < %s | FileCheck %s
; Tests whether globaldce does the right cleanup while removing @bar
; so that a dead BlockAddress reference to foo won't prevent other passes
; to work properly, e.g. simplifycfg
@bar = internal unnamed_addr constant i8* blockaddress(@foo, %L1)
; CHECK-LABEL: foo
; CHECK-NOT: br label %L1
; CHECK: ret void
define void @foo() {
entry:
br label %L1
L1:
ret void
}

View File

@@ -1,21 +0,0 @@
; RUN: opt < %s -globaldce -S | FileCheck %s
; test_global should not be emitted to the .s file.
; CHECK-NOT: @test_global =
@test_global = available_externally global i32 4
; test_global2 is a normal global using an available externally function.
; CHECK: @test_global2 =
@test_global2 = global i32 ()* @test_function2
; test_function should not be emitted to the .s file.
; CHECK-NOT: define {{.*}} @test_function()
define available_externally i32 @test_function() {
ret i32 4
}
; test_function2 isn't actually dead even though it's available externally.
; CHECK: define available_externally i32 @test_function2()
define available_externally i32 @test_function2() {
ret i32 4
}

View File

@@ -1,13 +0,0 @@
; RUN: opt -S -globaldce < %s | FileCheck %s
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
@if = ifunc void (), void ()* @fn
define internal void @fn() {
entry:
ret void
}
; CHECK-DAG: @if = ifunc void (), void ()* @fn
; CHECK-DAG: define internal void @fn(

View File

@@ -1,14 +0,0 @@
; RUN: opt -S -globaldce < %s | FileCheck %s
; CHECK: @llvm.global_ctors = appending global [1 x { i32, void ()* }] [{ i32, void ()* } { i32 65535, void ()* @_notremovable }]
; CHECK-NOT: @_GLOBAL__I_a
declare void @_notremovable()
@llvm.global_ctors = appending global [2 x { i32, void ()* }] [{ i32, void ()* } { i32 65535, void ()* @_GLOBAL__I_a }, { i32, void ()* } { i32 65535, void ()* @_notremovable }]
; Function Attrs: nounwind readnone
define internal void @_GLOBAL__I_a() #1 section "__TEXT,__StaticInit,regular,pure_instructions" {
entry:
ret void
}

View File

@@ -1,45 +0,0 @@
; RUN: opt -S -O2 < %s | FileCheck %s
; This test checks that -O2 is able to delete constructors that become empty
; only after some optimization passes have run, even if the pass structure
; changes.
; CHECK-NOT: @_GLOBAL__I_a
%class.Foo = type { i32 }
@foo = global %class.Foo zeroinitializer, align 4
@_ZN3Bar18LINKER_INITIALIZEDE = external constant i32
@llvm.global_ctors = appending global [1 x { i32, void ()* }] [{ i32, void ()* } { i32 65535, void ()* @_GLOBAL__I_a }]
define internal void @__cxx_global_var_init() section "__TEXT,__StaticInit,regular,pure_instructions" {
%1 = load i32, i32* @_ZN3Bar18LINKER_INITIALIZEDE, align 4
call void @_ZN3FooC1E17LinkerInitialized(%class.Foo* @foo, i32 %1)
ret void
}
; Function Attrs: ssp uwtable
define linkonce_odr void @_ZN3FooC1E17LinkerInitialized(%class.Foo* %this, i32) unnamed_addr #0 align 2 {
%2 = alloca %class.Foo*, align 8
%3 = alloca i32, align 4
store %class.Foo* %this, %class.Foo** %2, align 8
store i32 %0, i32* %3, align 4
%4 = load %class.Foo*, %class.Foo** %2
%5 = load i32, i32* %3, align 4
call void @_ZN3FooC2E17LinkerInitialized(%class.Foo* %4, i32 %5)
ret void
}
; Function Attrs: nounwind ssp uwtable
define linkonce_odr void @_ZN3FooC2E17LinkerInitialized(%class.Foo* %this, i32) unnamed_addr #1 align 2 {
%2 = alloca %class.Foo*, align 8
%3 = alloca i32, align 4
store %class.Foo* %this, %class.Foo** %2, align 8
store i32 %0, i32* %3, align 4
%4 = load %class.Foo*, %class.Foo** %2
ret void
}
define internal void @_GLOBAL__I_a() section "__TEXT,__StaticInit,regular,pure_instructions" {
call void @__cxx_global_var_init()
ret void
}

View File

@@ -1,18 +0,0 @@
; RUN: opt -S -globaldce < %s | FileCheck %s
@L = internal unnamed_addr constant [3 x i8*] [i8* blockaddress(@test1, %L1), i8* blockaddress(@test1, %L2), i8* null], align 16
; CHECK: @L = internal unnamed_addr constant
define void @test1(i32 %idx) {
entry:
br label %L1
L1:
%arrayidx = getelementptr inbounds [3 x i8*], [3 x i8*]* @L, i32 0, i32 %idx
%l = load i8*, i8** %arrayidx
indirectbr i8* %l, [label %L1, label %L2]
L2:
ret void
}