summaryrefslogtreecommitdiff
path: root/test/Transforms/GlobalOpt
diff options
context:
space:
mode:
Diffstat (limited to 'test/Transforms/GlobalOpt')
-rw-r--r--test/Transforms/GlobalOpt/2007-05-13-Crash.ll2
-rw-r--r--test/Transforms/GlobalOpt/2008-01-13-OutOfRangeSROA.ll6
-rw-r--r--test/Transforms/GlobalOpt/2008-01-29-VolatileGlobal.ll3
-rw-r--r--test/Transforms/GlobalOpt/2008-04-26-SROA-Global-Align.ll8
-rw-r--r--test/Transforms/GlobalOpt/2008-07-17-addrspace.ll8
-rw-r--r--test/Transforms/GlobalOpt/2009-01-13-phi-user.ll3
-rw-r--r--test/Transforms/GlobalOpt/2009-03-05-dbg.ll12
-rw-r--r--test/Transforms/GlobalOpt/2009-03-06-Anonymous.ll4
-rw-r--r--test/Transforms/GlobalOpt/2009-03-07-PromotePtrToBool.ll4
-rw-r--r--test/Transforms/GlobalOpt/2010-10-19-WeakOdr.ll2
-rw-r--r--test/Transforms/GlobalOpt/GSROA-section.ll30
-rw-r--r--test/Transforms/GlobalOpt/MallocSROA-section.ll28
-rw-r--r--test/Transforms/GlobalOpt/SROA-section.ll27
-rw-r--r--test/Transforms/GlobalOpt/alias-used-address-space.ll2
-rw-r--r--test/Transforms/GlobalOpt/alias-used.ll25
-rw-r--r--test/Transforms/GlobalOpt/assume.ll2
-rw-r--r--test/Transforms/GlobalOpt/basictest.ll5
-rw-r--r--test/Transforms/GlobalOpt/constantexpr-dangle.ll5
-rw-r--r--test/Transforms/GlobalOpt/constantfold-initializers.ll12
-rw-r--r--test/Transforms/GlobalOpt/ctor-list-opt-inbounds.ll4
-rw-r--r--test/Transforms/GlobalOpt/deadglobal-2.ll4
-rw-r--r--test/Transforms/GlobalOpt/globalsra-partial.ll4
-rw-r--r--test/Transforms/GlobalOpt/globalsra-unknown-index.ll21
-rw-r--r--test/Transforms/GlobalOpt/globalsra.ll23
-rw-r--r--test/Transforms/GlobalOpt/heap-sra-phi.ll5
-rw-r--r--test/Transforms/GlobalOpt/invariant.group.barrier.ll4
-rw-r--r--test/Transforms/GlobalOpt/invoke.ll2
-rw-r--r--test/Transforms/GlobalOpt/iterate.ll4
-rw-r--r--test/Transforms/GlobalOpt/memcpy.ll4
-rw-r--r--test/Transforms/GlobalOpt/phi-select.ll8
-rw-r--r--test/Transforms/GlobalOpt/pr21191.ll4
-rw-r--r--test/Transforms/GlobalOpt/storepointer-compare.ll5
-rw-r--r--test/Transforms/GlobalOpt/storepointer.ll4
-rw-r--r--test/Transforms/GlobalOpt/trivialstore.ll4
-rw-r--r--test/Transforms/GlobalOpt/undef-init.ll4
-rw-r--r--test/Transforms/GlobalOpt/unnamed-addr.ll2
36 files changed, 218 insertions, 76 deletions
diff --git a/test/Transforms/GlobalOpt/2007-05-13-Crash.ll b/test/Transforms/GlobalOpt/2007-05-13-Crash.ll
index 90ba15c37074b..bed4fec981efa 100644
--- a/test/Transforms/GlobalOpt/2007-05-13-Crash.ll
+++ b/test/Transforms/GlobalOpt/2007-05-13-Crash.ll
@@ -8,7 +8,7 @@ target triple = "i686-apple-darwin8"
%struct.__builtin_CFString = type { i32*, i32, i8*, i32 }
@_ZZ19SFLGetVisibilityKeyvE19_kSFLLVisibilityKey = internal global %struct.__CFString* null ; <%struct.__CFString**> [#uses=2]
@_ZZ22SFLGetAlwaysVisibleKeyvE22_kSFLLAlwaysVisibleKey = internal global %struct.__CFString* null ; <%struct.__CFString**> [#uses=7]
-internal constant %struct.__builtin_CFString {
+@0 = internal constant %struct.__builtin_CFString {
i32* getelementptr ([0 x i32], [0 x i32]* @__CFConstantStringClassReference, i32 0, i32 0),
i32 1992,
i8* getelementptr ([14 x i8], [14 x i8]* @.str, i32 0, i32 0),
diff --git a/test/Transforms/GlobalOpt/2008-01-13-OutOfRangeSROA.ll b/test/Transforms/GlobalOpt/2008-01-13-OutOfRangeSROA.ll
index 8df7050b38a76..4adc9607c75bc 100644
--- a/test/Transforms/GlobalOpt/2008-01-13-OutOfRangeSROA.ll
+++ b/test/Transforms/GlobalOpt/2008-01-13-OutOfRangeSROA.ll
@@ -1,6 +1,8 @@
-; RUN: opt < %s -globalopt -S | grep "16 x .31 x double.. zeroinitializer"
+; RUN: opt < %s -globalopt -S | FileCheck %s
-; The 'X' indices could be larger than 31. Do not SROA the outer indices of this array.
+; The 'X' indices could be larger than 31. Do not SROA the outer
+; indices of this array.
+; CHECK: @mm = {{.*}} [16 x [31 x double]] zeroinitializer
@mm = internal global [16 x [31 x double]] zeroinitializer, align 32
define void @test(i32 %X) {
diff --git a/test/Transforms/GlobalOpt/2008-01-29-VolatileGlobal.ll b/test/Transforms/GlobalOpt/2008-01-29-VolatileGlobal.ll
index ac663604854d2..7818e5d642c14 100644
--- a/test/Transforms/GlobalOpt/2008-01-29-VolatileGlobal.ll
+++ b/test/Transforms/GlobalOpt/2008-01-29-VolatileGlobal.ll
@@ -1,4 +1,5 @@
-; RUN: opt < %s -globalopt -S | grep "load volatile"
+; RUN: opt < %s -globalopt -S | FileCheck %s
+; CHECK: load volatile
@t0.1441 = internal global double 0x3FD5555555555555, align 8 ; <double*> [#uses=1]
define double @foo() nounwind {
diff --git a/test/Transforms/GlobalOpt/2008-04-26-SROA-Global-Align.ll b/test/Transforms/GlobalOpt/2008-04-26-SROA-Global-Align.ll
index 934d928aa88e0..c3a6d7b57165f 100644
--- a/test/Transforms/GlobalOpt/2008-04-26-SROA-Global-Align.ll
+++ b/test/Transforms/GlobalOpt/2008-04-26-SROA-Global-Align.ll
@@ -2,9 +2,11 @@
; alignments. Elements 0 and 2 must be 16-byte aligned, and element
; 1 must be at least 8 byte aligned (but could be more).
-; RUN: opt < %s -globalopt -S | grep "@G.0 = internal unnamed_addr global .*align 16"
-; RUN: opt < %s -globalopt -S | grep "@G.1 = internal unnamed_addr global .*align 8"
-; RUN: opt < %s -globalopt -S | grep "@G.2 = internal unnamed_addr global .*align 16"
+; RUN: opt < %s -globalopt -S | FileCheck %s
+; CHECK: @G.0 = internal unnamed_addr global {{.*}}align 16
+; CHECK: @G.1 = internal unnamed_addr global {{.*}}align 8
+; CHECK: @G.2 = internal unnamed_addr global {{.*}}align 16
+
; rdar://5891920
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:32:32-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128"
diff --git a/test/Transforms/GlobalOpt/2008-07-17-addrspace.ll b/test/Transforms/GlobalOpt/2008-07-17-addrspace.ll
index d602df1e701c6..b9d2d993240e4 100644
--- a/test/Transforms/GlobalOpt/2008-07-17-addrspace.ll
+++ b/test/Transforms/GlobalOpt/2008-07-17-addrspace.ll
@@ -2,9 +2,11 @@
; values. This used to crash, because globalopt forgot to put the new var in the
; same address space as the old one.
-; RUN: opt < %s -globalopt -S > %t
+; RUN: opt < %s -globalopt -S | FileCheck %s
+
; Check that the new global values still have their address space
-; RUN: cat %t | grep 'addrspace.*global'
+; CHECK: addrspace(1) global
+; CHECK: addrspace(1) global
@struct = internal addrspace(1) global { i32, i32 } zeroinitializer
@array = internal addrspace(1) global [ 2 x i32 ] zeroinitializer
@@ -24,5 +26,3 @@ define void @bar(i32 %R) {
store i32 %R, i32 addrspace(1) * getelementptr ({ i32, i32 }, { i32, i32 } addrspace(1) * @struct, i32 0, i32 0)
ret void
}
-
-
diff --git a/test/Transforms/GlobalOpt/2009-01-13-phi-user.ll b/test/Transforms/GlobalOpt/2009-01-13-phi-user.ll
index 21ec5267b9733..7ad24b92a2dae 100644
--- a/test/Transforms/GlobalOpt/2009-01-13-phi-user.ll
+++ b/test/Transforms/GlobalOpt/2009-01-13-phi-user.ll
@@ -1,4 +1,5 @@
-; RUN: opt < %s -globalopt -S | grep "phi.*@head"
+; RUN: opt < %s -globalopt -S | FileCheck %s
+; CHECK: phi{{.*}}@head
; PR3321
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128"
target triple = "x86_64-unknown-linux-gnu"
diff --git a/test/Transforms/GlobalOpt/2009-03-05-dbg.ll b/test/Transforms/GlobalOpt/2009-03-05-dbg.ll
index f74f2081dc202..3f6e269a960bf 100644
--- a/test/Transforms/GlobalOpt/2009-03-05-dbg.ll
+++ b/test/Transforms/GlobalOpt/2009-03-05-dbg.ll
@@ -1,5 +1,6 @@
; REQUIRES: asserts
-; RUN: opt < %s -globalopt -stats -disable-output 2>&1 | grep "1 globalopt - Number of global vars shrunk to booleans"
+; RUN: opt < %s -globalopt -stats -disable-output 2>&1 | FileCheck %s
+; CHECK: 1 globalopt - Number of global vars shrunk to booleans
@Stop = internal global i32 0 ; <i32*> [#uses=3]
@@ -53,13 +54,12 @@ return: ; preds = %bb2
declare void @llvm.dbg.value(metadata, i64, metadata, metadata) nounwind readnone
-!llvm.dbg.gv = !{!0}
-
+!llvm.dbg.cu = !{!1}
!0 = !DIGlobalVariable(name: "Stop", line: 2, isLocal: true, isDefinition: true, scope: !1, file: !1, type: !2, variable: i32* @Stop)
-!1 = distinct !DICompileUnit(language: DW_LANG_C89, producer: "4.2.1 (Based on Apple Inc. build 5658) (LLVM build)", isOptimized: true, emissionKind: 0, file: !20, enums: !21, retainedTypes: !21)
+!1 = distinct !DICompileUnit(language: DW_LANG_C89, producer: "4.2.1 (Based on Apple Inc. build 5658) (LLVM build)", isOptimized: true, emissionKind: FullDebug, file: !20, enums: !21, retainedTypes: !21, globals: !{!0})
!2 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
!3 = !DILocalVariable(name: "i", line: 4, arg: 1, scope: !4, file: !1, type: !2)
-!4 = distinct !DISubprogram(name: "foo", linkageName: "foo", line: 4, isLocal: false, isDefinition: true, virtualIndex: 6, isOptimized: false, scope: !1, type: !5)
+!4 = distinct !DISubprogram(name: "foo", linkageName: "foo", line: 4, isLocal: false, isDefinition: true, virtualIndex: 6, isOptimized: false, unit: !1, scope: !1, type: !5)
!5 = !DISubroutineType(types: !6)
!6 = !{!2, !2}
!7 = !DILocation(line: 5, scope: !8)
@@ -70,7 +70,7 @@ declare void @llvm.dbg.value(metadata, i64, metadata, metadata) nounwind readnon
!12 = !DILocation(line: 11, scope: !8)
!13 = !DILocation(line: 14, scope: !14)
!14 = distinct !DILexicalBlock(line: 0, column: 0, file: !20, scope: !15)
-!15 = distinct !DISubprogram(name: "bar", linkageName: "bar", line: 13, isLocal: false, isDefinition: true, virtualIndex: 6, isOptimized: false, scope: !1, type: !16)
+!15 = distinct !DISubprogram(name: "bar", linkageName: "bar", line: 13, isLocal: false, isDefinition: true, virtualIndex: 6, isOptimized: false, unit: !1, scope: !1, type: !16)
!16 = !DISubroutineType(types: !17)
!17 = !{!2}
!18 = !DILocation(line: 15, scope: !14)
diff --git a/test/Transforms/GlobalOpt/2009-03-06-Anonymous.ll b/test/Transforms/GlobalOpt/2009-03-06-Anonymous.ll
index 930a96e2182f2..d5836ea9254a9 100644
--- a/test/Transforms/GlobalOpt/2009-03-06-Anonymous.ll
+++ b/test/Transforms/GlobalOpt/2009-03-06-Anonymous.ll
@@ -1,9 +1,9 @@
; RUN: opt < %s -globalopt -S | FileCheck %s
-global i32 0
+@0 = global i32 0
; CHECK-DAG: @0 = internal global i32 0
-private global i32 0
+@1 = private global i32 0
; CHECK-DAG: @1 = private global i32 0
define i32* @2() {
diff --git a/test/Transforms/GlobalOpt/2009-03-07-PromotePtrToBool.ll b/test/Transforms/GlobalOpt/2009-03-07-PromotePtrToBool.ll
index 469fa765c7afa..bec4891a496a1 100644
--- a/test/Transforms/GlobalOpt/2009-03-07-PromotePtrToBool.ll
+++ b/test/Transforms/GlobalOpt/2009-03-07-PromotePtrToBool.ll
@@ -1,6 +1,8 @@
-; RUN: opt < %s -globalopt -S | grep "@X = internal unnamed_addr global i32"
+; RUN: opt < %s -globalopt -S | FileCheck %s
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
target triple = "i386-apple-darwin7"
+
+; CHECK: @X = internal unnamed_addr global i32
@X = internal global i32* null ; <i32**> [#uses=2]
@Y = internal global i32 0 ; <i32*> [#uses=1]
diff --git a/test/Transforms/GlobalOpt/2010-10-19-WeakOdr.ll b/test/Transforms/GlobalOpt/2010-10-19-WeakOdr.ll
index ad5b440a5abe8..c88dc1c2d1249 100644
--- a/test/Transforms/GlobalOpt/2010-10-19-WeakOdr.ll
+++ b/test/Transforms/GlobalOpt/2010-10-19-WeakOdr.ll
@@ -2,7 +2,7 @@
; PR8389: Globals with weak_odr linkage type must not be modified
-; CHECK: weak_odr global i32 0
+; CHECK: weak_odr local_unnamed_addr global i32 0
@SomeVar = weak_odr global i32 0
diff --git a/test/Transforms/GlobalOpt/GSROA-section.ll b/test/Transforms/GlobalOpt/GSROA-section.ll
new file mode 100644
index 0000000000000..a439fa0797dee
--- /dev/null
+++ b/test/Transforms/GlobalOpt/GSROA-section.ll
@@ -0,0 +1,30 @@
+; This test lets globalopt split the global struct and array into different
+; values. The pass needs to preserve section attribute.
+
+; RUN: opt < %s -globalopt -S | FileCheck %s
+; Check that the new global values still have their section assignment.
+; CHECK: @struct
+; CHECK: section ".foo"
+; CHECK: @array
+; CHECK-NOT: section ".foo"
+
+@struct = internal global { i32, i32 } zeroinitializer, section ".foo"
+@array = internal global [ 2 x i32 ] zeroinitializer
+
+define i32 @foo() {
+ %A = load i32, i32* getelementptr ({ i32, i32 }, { i32, i32 }* @struct, i32 0, i32 0)
+ %B = load i32, i32* getelementptr ([ 2 x i32 ], [ 2 x i32 ]* @array, i32 0, i32 0)
+ ; Use the loaded values, so they won't get removed completely
+ %R = add i32 %A, %B
+ ret i32 %R
+}
+
+; We put stores in a different function, so that the global variables won't get
+; optimized away completely.
+define void @bar(i32 %R) {
+ store i32 %R, i32* getelementptr ([ 2 x i32 ], [ 2 x i32 ]* @array, i32 0, i32 0)
+ store i32 %R, i32* getelementptr ({ i32, i32 }, { i32, i32 }* @struct, i32 0, i32 0)
+ ret void
+}
+
+
diff --git a/test/Transforms/GlobalOpt/MallocSROA-section.ll b/test/Transforms/GlobalOpt/MallocSROA-section.ll
new file mode 100644
index 0000000000000..75b3cfec13732
--- /dev/null
+++ b/test/Transforms/GlobalOpt/MallocSROA-section.ll
@@ -0,0 +1,28 @@
+; RUN: opt -globalopt -S < %s | FileCheck %s
+; CHECK: @Y.f0
+; CHECK: section ".foo"
+; CHECK: @Y.f1
+; CHECK: section ".foo"
+
+%struct.xyz = type { double, i32 }
+
+@Y = internal global %struct.xyz* null ,section ".foo" ; <%struct.xyz**> [#uses=2]
+@numf2s = external global i32 ; <i32*> [#uses=1]
+
+define void @init_net() {
+entry:
+ %0 = load i32, i32* @numf2s, align 4 ; <i32> [#uses=1]
+ %mallocsize2 = shl i32 %0, 4 ; <i32> [#uses=1]
+ %malloccall3 = tail call i8* @malloc(i32 %mallocsize2) ; <i8*> [#uses=1]
+ %1 = bitcast i8* %malloccall3 to %struct.xyz* ; <%struct.xyz*> [#uses=1]
+ store %struct.xyz* %1, %struct.xyz** @Y, align 8
+ ret void
+}
+
+define void @load_train() {
+entry:
+ %0 = load %struct.xyz*, %struct.xyz** @Y, align 8 ; <%struct.xyz*> [#uses=0]
+ ret void
+}
+
+declare noalias i8* @malloc(i32)
diff --git a/test/Transforms/GlobalOpt/SROA-section.ll b/test/Transforms/GlobalOpt/SROA-section.ll
new file mode 100644
index 0000000000000..1589608a67aa9
--- /dev/null
+++ b/test/Transforms/GlobalOpt/SROA-section.ll
@@ -0,0 +1,27 @@
+; Verify that section assignment is copied during SROA
+; RUN: opt < %s -globalopt -S | FileCheck %s
+; CHECK: @G.0
+; CHECK: section ".foo"
+; CHECK: @G.1
+; CHECK: section ".foo"
+; CHECK: @G.2
+; CHECK: section ".foo"
+
+%T = type { double, double, double }
+@G = internal global %T zeroinitializer, align 16, section ".foo"
+
+define void @test() {
+ store double 1.0, double* getelementptr (%T, %T* @G, i32 0, i32 0), align 16
+ store double 2.0, double* getelementptr (%T, %T* @G, i32 0, i32 1), align 8
+ store double 3.0, double* getelementptr (%T, %T* @G, i32 0, i32 2), align 16
+ ret void
+}
+
+define double @test2() {
+ %V1 = load double, double* getelementptr (%T, %T* @G, i32 0, i32 0), align 16
+ %V2 = load double, double* getelementptr (%T, %T* @G, i32 0, i32 1), align 8
+ %V3 = load double, double* getelementptr (%T, %T* @G, i32 0, i32 2), align 16
+ %R = fadd double %V1, %V2
+ %R2 = fadd double %R, %V3
+ ret double %R2
+}
diff --git a/test/Transforms/GlobalOpt/alias-used-address-space.ll b/test/Transforms/GlobalOpt/alias-used-address-space.ll
index 367f375ec900f..08081b89ac685 100644
--- a/test/Transforms/GlobalOpt/alias-used-address-space.ll
+++ b/test/Transforms/GlobalOpt/alias-used-address-space.ll
@@ -16,7 +16,7 @@ target datalayout = "p:32:32:32-p1:16:16:16"
; CHECK-DAG: @llvm.compiler.used = appending global [1 x i8*] [i8* addrspacecast (i8 addrspace(1)* @ia to i8*)], section "llvm.metadata"
@sameAsUsed = global [1 x i8*] [i8* addrspacecast(i8 addrspace(1)* @ca to i8*)]
-; CHECK-DAG: @sameAsUsed = global [1 x i8*] [i8* addrspacecast (i8 addrspace(1)* @c to i8*)]
+; CHECK-DAG: @sameAsUsed = local_unnamed_addr global [1 x i8*] [i8* addrspacecast (i8 addrspace(1)* @c to i8*)]
@ca = internal alias i8, i8 addrspace(1)* @c
; CHECK: @ca = internal alias i8, i8 addrspace(1)* @c
diff --git a/test/Transforms/GlobalOpt/alias-used.ll b/test/Transforms/GlobalOpt/alias-used.ll
index 9ced3974ee87d..91601fb992709 100644
--- a/test/Transforms/GlobalOpt/alias-used.ll
+++ b/test/Transforms/GlobalOpt/alias-used.ll
@@ -7,16 +7,16 @@
@ia = internal alias i8, i8* @i
@llvm.used = appending global [3 x i8*] [i8* bitcast (void ()* @fa to i8*), i8* bitcast (void ()* @f to i8*), i8* @ca], section "llvm.metadata"
-; CHECK-DAG: @llvm.used = appending global [3 x i8*] [i8* @ca, i8* bitcast (void ()* @fa to i8*), i8* bitcast (void ()* @f to i8*)], section "llvm.metadata"
+; CHECK-DAG: @llvm.used = appending global [3 x i8*] [i8* @ca, i8* bitcast (void ()* @f to i8*), i8* bitcast (void ()* @fa to i8*)], section "llvm.metadata"
@llvm.compiler.used = appending global [4 x i8*] [i8* bitcast (void ()* @fa3 to i8*), i8* bitcast (void ()* @fa to i8*), i8* @ia, i8* @i], section "llvm.metadata"
; CHECK-DAG: @llvm.compiler.used = appending global [2 x i8*] [i8* bitcast (void ()* @fa3 to i8*), i8* @ia], section "llvm.metadata"
@sameAsUsed = global [3 x i8*] [i8* bitcast (void ()* @fa to i8*), i8* bitcast (void ()* @f to i8*), i8* @ca]
-; CHECK-DAG: @sameAsUsed = global [3 x i8*] [i8* bitcast (void ()* @f to i8*), i8* bitcast (void ()* @f to i8*), i8* @c]
+; CHECK-DAG: @sameAsUsed = local_unnamed_addr global [3 x i8*] [i8* bitcast (void ()* @f to i8*), i8* bitcast (void ()* @f to i8*), i8* @c]
@other = global i32* bitcast (void ()* @fa to i32*)
-; CHECK-DAG: @other = global i32* bitcast (void ()* @f to i32*)
+; CHECK-DAG: @other = local_unnamed_addr global i32* bitcast (void ()* @f to i32*)
@fa = internal alias void (), void ()* @f
; CHECK: @fa = internal alias void (), void ()* @f
@@ -45,3 +45,22 @@ define i8* @g2() {
define i8* @h() {
ret i8* @ca
}
+
+; Check that GlobalOpt doesn't try to resolve aliases with GEP operands.
+
+%struct.S = type { i32, i32, i32 }
+@s = global %struct.S { i32 1, i32 2, i32 3 }, align 4
+
+@alias1 = alias i32, i32* getelementptr inbounds (%struct.S, %struct.S* @s, i64 0, i32 1)
+@alias2 = alias i32, i32* getelementptr inbounds (%struct.S, %struct.S* @s, i64 0, i32 2)
+
+; CHECK: load i32, i32* @alias1, align 4
+; CHECK: load i32, i32* @alias2, align 4
+
+define i32 @foo1() {
+entry:
+ %0 = load i32, i32* @alias1, align 4
+ %1 = load i32, i32* @alias2, align 4
+ %add = add nsw i32 %1, %0
+ ret i32 %add
+}
diff --git a/test/Transforms/GlobalOpt/assume.ll b/test/Transforms/GlobalOpt/assume.ll
index 3f3157a38fbb8..b15106bc83ac0 100644
--- a/test/Transforms/GlobalOpt/assume.ll
+++ b/test/Transforms/GlobalOpt/assume.ll
@@ -1,6 +1,6 @@
; RUN: opt -S -globalopt < %s | FileCheck %s
-; CHECK: @tmp = global i32 42
+; CHECK: @tmp = local_unnamed_addr global i32 42
@llvm.global_ctors = appending global [1 x { i32, void ()* }] [{ i32, void ()* } { i32 65535, void ()* @_GLOBAL__I_a }]
@tmp = global i32 0
diff --git a/test/Transforms/GlobalOpt/basictest.ll b/test/Transforms/GlobalOpt/basictest.ll
index 4c25e4f9f4074..d5294820abe92 100644
--- a/test/Transforms/GlobalOpt/basictest.ll
+++ b/test/Transforms/GlobalOpt/basictest.ll
@@ -1,9 +1,10 @@
-; RUN: opt < %s -globalopt -S | not grep global
+; RUN: opt < %s -globalopt -S | FileCheck %s
+; RUN: opt < %s -passes=globalopt -S | FileCheck %s
+; CHECK-NOT: global
@X = internal global i32 4 ; <i32*> [#uses=1]
define i32 @foo() {
%V = load i32, i32* @X ; <i32> [#uses=1]
ret i32 %V
}
-
diff --git a/test/Transforms/GlobalOpt/constantexpr-dangle.ll b/test/Transforms/GlobalOpt/constantexpr-dangle.ll
index fbbfe69c15ab8..3917bfff41194 100644
--- a/test/Transforms/GlobalOpt/constantexpr-dangle.ll
+++ b/test/Transforms/GlobalOpt/constantexpr-dangle.ll
@@ -1,5 +1,5 @@
-; RUN: opt < %s -instcombine -globalopt -S | \
-; RUN: grep "internal fastcc float @foo"
+; RUN: opt < %s -instcombine -globalopt -S | FileCheck %s
+; CHECK: internal fastcc float @foo
define internal float @foo() {
ret float 0.000000e+00
@@ -10,4 +10,3 @@ define float @bar() {
%tmp2 = fmul float %tmp1, 1.000000e+01 ; <float> [#uses=1]
ret float %tmp2
}
-
diff --git a/test/Transforms/GlobalOpt/constantfold-initializers.ll b/test/Transforms/GlobalOpt/constantfold-initializers.ll
index d0c18812cd94e..3c20353d157bf 100644
--- a/test/Transforms/GlobalOpt/constantfold-initializers.ll
+++ b/test/Transforms/GlobalOpt/constantfold-initializers.ll
@@ -4,13 +4,13 @@ target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f3
@.str91250 = global [3 x i8] zeroinitializer
-; CHECK: @A = global i1 false
+; CHECK: @A = local_unnamed_addr global i1 false
@A = global i1 icmp ne (i64 sub nsw (i64 ptrtoint (i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str91250, i64 0, i64 1) to i64), i64 ptrtoint ([3 x i8]* @.str91250 to i64)), i64 1)
; PR11352
@xs = global [2 x i32] zeroinitializer, align 4
-; CHECK: @xs = global [2 x i32] [i32 1, i32 1]
+; CHECK: @xs = local_unnamed_addr global [2 x i32] [i32 1, i32 1]
; PR12642
%PR12642.struct = type { i8 }
@@ -32,7 +32,7 @@ entry:
@f = internal global %closure zeroinitializer, align 4
@m = global i32 0, align 4
; CHECK-NOT: @f
-; CHECK: @m = global i32 13
+; CHECK: @m = local_unnamed_addr global i32 13
define internal i32 @test2_helper(%closure* %this, i32 %b) {
entry:
@@ -53,7 +53,7 @@ entry:
; PR19955
@dllimportptr = global i32* null, align 4
-; CHECK: @dllimportptr = global i32* null, align 4
+; CHECK: @dllimportptr = local_unnamed_addr global i32* null, align 4
@dllimportvar = external dllimport global i32
define internal void @test3() {
entry:
@@ -62,7 +62,7 @@ entry:
}
@dllexportptr = global i32* null, align 4
-; CHECK: @dllexportptr = global i32* @dllexportvar, align 4
+; CHECK: @dllexportptr = local_unnamed_addr global i32* @dllexportvar, align 4
@dllexportvar = dllexport global i32 0, align 4
; CHECK: @dllexportvar = dllexport global i32 20, align 4
define internal void @test4() {
@@ -83,7 +83,7 @@ entry:
@test6_v1 = internal global { i32, i32 } { i32 42, i32 0 }, align 8
@test6_v2 = global i32 0, align 4
-; CHECK: @test6_v2 = global i32 42, align 4
+; CHECK: @test6_v2 = local_unnamed_addr global i32 42, align 4
define internal void @test6() {
%load = load { i32, i32 }, { i32, i32 }* @test6_v1, align 8
%xv0 = extractvalue { i32, i32 } %load, 0
diff --git a/test/Transforms/GlobalOpt/ctor-list-opt-inbounds.ll b/test/Transforms/GlobalOpt/ctor-list-opt-inbounds.ll
index 63dc783ae196f..b969345710d5b 100644
--- a/test/Transforms/GlobalOpt/ctor-list-opt-inbounds.ll
+++ b/test/Transforms/GlobalOpt/ctor-list-opt-inbounds.ll
@@ -3,8 +3,8 @@
; Don't get fooled by the inbounds keyword; it doesn't change
; the computed address.
-; CHECK: @H = global i32 2
-; CHECK: @I = global i32 2
+; CHECK: @H = local_unnamed_addr global i32 2
+; CHECK: @I = local_unnamed_addr global i32 2
@llvm.global_ctors = appending global [1 x { i32, void ()* }] [ { i32, void ()* } { i32 65535, void ()* @CTOR } ]
@addr = external global i32
diff --git a/test/Transforms/GlobalOpt/deadglobal-2.ll b/test/Transforms/GlobalOpt/deadglobal-2.ll
index 6b8717ee18315..92c0f994f3679 100644
--- a/test/Transforms/GlobalOpt/deadglobal-2.ll
+++ b/test/Transforms/GlobalOpt/deadglobal-2.ll
@@ -1,7 +1,7 @@
-; RUN: opt < %s -globalopt -S | not grep internal
-
+; RUN: opt < %s -globalopt -S | FileCheck %s
; This is a harder case to delete as the GEP has a variable index.
+; CHECK-NOT: internal
@G = internal global [4 x i32] zeroinitializer
define void @foo(i32 %X) {
diff --git a/test/Transforms/GlobalOpt/globalsra-partial.ll b/test/Transforms/GlobalOpt/globalsra-partial.ll
index 9abcce6f49312..6f24128c42b53 100644
--- a/test/Transforms/GlobalOpt/globalsra-partial.ll
+++ b/test/Transforms/GlobalOpt/globalsra-partial.ll
@@ -1,10 +1,11 @@
; In this case, the global can only be broken up by one level.
-; RUN: opt < %s -globalopt -S | not grep 12345
+; RUN: opt < %s -globalopt -S | FileCheck %s
target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128"
@G = internal global { i32, [4 x float] } zeroinitializer ; <{ i32, [4 x float] }*> [#uses=3]
+; CHECK-NOT: 12345
define void @onlystore() {
store i32 12345, i32* getelementptr ({ i32, [4 x float] }, { i32, [4 x float] }* @G, i32 0, i32 0)
ret void
@@ -21,4 +22,3 @@ define float @readval(i32 %i) {
%V = load float, float* %Ptr ; <float> [#uses=1]
ret float %V
}
-
diff --git a/test/Transforms/GlobalOpt/globalsra-unknown-index.ll b/test/Transforms/GlobalOpt/globalsra-unknown-index.ll
index 5194b2ca7413b..4607373ab2c7c 100644
--- a/test/Transforms/GlobalOpt/globalsra-unknown-index.ll
+++ b/test/Transforms/GlobalOpt/globalsra-unknown-index.ll
@@ -1,12 +1,10 @@
-; RUN: opt < %s -globalopt -S > %t
-; RUN: grep "@Y = internal unnamed_addr global \[3 x [%]struct.X\] zeroinitializer" %t
-; RUN: grep load %t | count 6
-; RUN: grep "add i32 [%]a, [%]b" %t | count 3
+; RUN: opt < %s -globalopt -S | FileCheck %s
; globalopt should not sra the global, because it can't see the index.
%struct.X = type { [3 x i32], [3 x i32] }
+; CHECK: @Y = internal unnamed_addr global [3 x %struct.X] zeroinitializer
@Y = internal global [3 x %struct.X] zeroinitializer
@addr = external global i8
@@ -15,6 +13,11 @@ define void @frob() {
store i32 1, i32* getelementptr inbounds ([3 x %struct.X], [3 x %struct.X]* @Y, i64 0, i64 0, i32 0, i64 ptrtoint (i8* @addr to i64)), align 4
ret void
}
+
+; CHECK-LABEL: @borf
+; CHECK: %a = load
+; CHECK: %b = load
+; CHECK: add i32 %a, %b
define i32 @borf(i64 %i, i64 %j) {
%p = getelementptr inbounds [3 x %struct.X], [3 x %struct.X]* @Y, i64 0, i64 0, i32 0, i64 0
%a = load i32, i32* %p
@@ -23,6 +26,11 @@ define i32 @borf(i64 %i, i64 %j) {
%c = add i32 %a, %b
ret i32 %c
}
+
+; CHECK-LABEL: @borg
+; CHECK: %a = load
+; CHECK: %b = load
+; CHECK: add i32 %a, %b
define i32 @borg(i64 %i, i64 %j) {
%p = getelementptr inbounds [3 x %struct.X], [3 x %struct.X]* @Y, i64 0, i64 1, i32 0, i64 1
%a = load i32, i32* %p
@@ -31,6 +39,11 @@ define i32 @borg(i64 %i, i64 %j) {
%c = add i32 %a, %b
ret i32 %c
}
+
+; CHECK-LABEL: @borh
+; CHECK: %a = load
+; CHECK: %b = load
+; CHECK: add i32 %a, %b
define i32 @borh(i64 %i, i64 %j) {
%p = getelementptr inbounds [3 x %struct.X], [3 x %struct.X]* @Y, i64 0, i64 2, i32 0, i64 2
%a = load i32, i32* %p
diff --git a/test/Transforms/GlobalOpt/globalsra.ll b/test/Transforms/GlobalOpt/globalsra.ll
index d593fcd9e15e7..8098ec84b2e71 100644
--- a/test/Transforms/GlobalOpt/globalsra.ll
+++ b/test/Transforms/GlobalOpt/globalsra.ll
@@ -1,4 +1,5 @@
-; RUN: opt < %s -globalopt -S | not grep global
+; RUN: opt < %s -globalopt -S | FileCheck %s
+; CHECK-NOT: global
target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128"
@G = internal global { i32, float, { double } } {
@@ -22,3 +23,23 @@ define double @constantize() {
ret double %X
}
+@G2 = internal constant { i32, float, { double } } {
+ i32 1,
+ float 1.000000e+00,
+ { double } { double 1.727000e+01 } } ; <{ i32, float, { double } }*> [#uses=3]
+
+define void @onlystore2() {
+ store i32 123, i32* getelementptr ({ i32, float, { double } }, { i32, float, { double } }* @G2, i32 0, i32 0)
+ ret void
+}
+
+define float @storeinit2() {
+ store float 1.000000e+00, float* getelementptr ({ i32, float, { double } }, { i32, float, { double } }* @G2, i32 0, i32 1)
+ %X = load float, float* getelementptr ({ i32, float, { double } }, { i32, float, { double } }* @G2, i32 0, i32 1) ; <float> [#uses=1]
+ ret float %X
+}
+
+define double @constantize2() {
+ %X = load double, double* getelementptr ({ i32, float, { double } }, { i32, float, { double } }* @G2, i32 0, i32 2, i32 0) ; <double> [#uses=1]
+ ret double %X
+}
diff --git a/test/Transforms/GlobalOpt/heap-sra-phi.ll b/test/Transforms/GlobalOpt/heap-sra-phi.ll
index bf9ca7b5311ed..995f9dc142c79 100644
--- a/test/Transforms/GlobalOpt/heap-sra-phi.ll
+++ b/test/Transforms/GlobalOpt/heap-sra-phi.ll
@@ -1,5 +1,6 @@
-; RUN: opt < %s -globalopt -S | grep "tmp.f1 = phi i32. "
-; RUN: opt < %s -globalopt -S | grep "tmp.f0 = phi i32. "
+; RUN: opt < %s -globalopt -S | FileCheck %s
+; CHECK: tmp.f1 = phi i32*
+; CHECK: tmp.f0 = phi i32*
target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128"
%struct.foo = type { i32, i32 }
diff --git a/test/Transforms/GlobalOpt/invariant.group.barrier.ll b/test/Transforms/GlobalOpt/invariant.group.barrier.ll
index 54d91d408019c..80cd411afdc78 100644
--- a/test/Transforms/GlobalOpt/invariant.group.barrier.ll
+++ b/test/Transforms/GlobalOpt/invariant.group.barrier.ll
@@ -2,8 +2,8 @@
; This test is hint, what could globalOpt optimize and what it can't
; FIXME: @tmp and @tmp2 can be safely set to 42
-; CHECK: @tmp = global i32 0
-; CHECK: @tmp2 = global i32 0
+; CHECK: @tmp = local_unnamed_addr global i32 0
+; CHECK: @tmp2 = local_unnamed_addr global i32 0
; CHECK: @tmp3 = global i32 0
@tmp = global i32 0
diff --git a/test/Transforms/GlobalOpt/invoke.ll b/test/Transforms/GlobalOpt/invoke.ll
index a0f7890a985bb..a301993973511 100644
--- a/test/Transforms/GlobalOpt/invoke.ll
+++ b/test/Transforms/GlobalOpt/invoke.ll
@@ -2,7 +2,7 @@
; rdar://11022897
; Globalopt should be able to evaluate an invoke.
-; CHECK: @tmp = global i32 1
+; CHECK: @tmp = local_unnamed_addr global i32 1
@llvm.global_ctors = appending global [1 x { i32, void ()* }] [{ i32, void ()* } { i32 65535, void ()* @_GLOBAL__I_a }]
@tmp = global i32 0
diff --git a/test/Transforms/GlobalOpt/iterate.ll b/test/Transforms/GlobalOpt/iterate.ll
index f7f34fc39d9a0..8c6543b685d32 100644
--- a/test/Transforms/GlobalOpt/iterate.ll
+++ b/test/Transforms/GlobalOpt/iterate.ll
@@ -1,4 +1,5 @@
-; RUN: opt < %s -globalopt -S | not grep %G
+; RUN: opt < %s -globalopt -S | FileCheck %s
+; CHECK-NOT: %G
@G = internal global i32 0 ; <i32*> [#uses=1]
@H = internal global { i32* } { i32* @G } ; <{ i32* }*> [#uses=1]
@@ -8,4 +9,3 @@ define i32 @loadg() {
%GV = load i32, i32* %G ; <i32> [#uses=1]
ret i32 %GV
}
-
diff --git a/test/Transforms/GlobalOpt/memcpy.ll b/test/Transforms/GlobalOpt/memcpy.ll
index 437142e8c6e19..e47497114b237 100644
--- a/test/Transforms/GlobalOpt/memcpy.ll
+++ b/test/Transforms/GlobalOpt/memcpy.ll
@@ -1,5 +1,5 @@
-; RUN: opt < %s -globalopt -S | \
-; RUN: grep "G1 = internal unnamed_addr constant"
+; RUN: opt < %s -globalopt -S | FileCheck %s
+; CHECK: G1 = internal unnamed_addr constant
@G1 = internal global [58 x i8] c"asdlfkajsdlfkajsd;lfkajds;lfkjasd;flkajsd;lkfja;sdlkfjasd\00" ; <[58 x i8]*> [#uses=1]
diff --git a/test/Transforms/GlobalOpt/phi-select.ll b/test/Transforms/GlobalOpt/phi-select.ll
index e5cb9819ca0ae..86b017c9cb34d 100644
--- a/test/Transforms/GlobalOpt/phi-select.ll
+++ b/test/Transforms/GlobalOpt/phi-select.ll
@@ -1,7 +1,8 @@
; Test that PHI nodes and select instructions do not necessarily make stuff
; non-constant.
-; RUN: opt < %s -globalopt -S | not grep global
+; RUN: opt < %s -globalopt -S | FileCheck %s
+; CHECK-NOT: global
@X = internal global i32 4 ; <i32*> [#uses=2]
@Y = internal global i32 5 ; <i32*> [#uses=2]
@@ -24,8 +25,3 @@ Cont: ; preds = %T, %0
%V = load i32, i32* %P ; <i32> [#uses=1]
ret i32 %V
}
-
-
-
-
-
diff --git a/test/Transforms/GlobalOpt/pr21191.ll b/test/Transforms/GlobalOpt/pr21191.ll
index 34e15cb3404a7..9e201b888be35 100644
--- a/test/Transforms/GlobalOpt/pr21191.ll
+++ b/test/Transforms/GlobalOpt/pr21191.ll
@@ -6,12 +6,12 @@ $c = comdat any
define linkonce_odr void @foo() comdat($c) {
ret void
}
-; CHECK: define linkonce_odr void @foo() comdat($c)
+; CHECK: define linkonce_odr void @foo() local_unnamed_addr comdat($c)
define linkonce_odr void @bar() comdat($c) {
ret void
}
-; CHECK: define linkonce_odr void @bar() comdat($c)
+; CHECK: define linkonce_odr void @bar() local_unnamed_addr comdat($c)
define void @zed() {
call void @foo()
diff --git a/test/Transforms/GlobalOpt/storepointer-compare.ll b/test/Transforms/GlobalOpt/storepointer-compare.ll
index bcf7cafd831ce..969443569c20d 100644
--- a/test/Transforms/GlobalOpt/storepointer-compare.ll
+++ b/test/Transforms/GlobalOpt/storepointer-compare.ll
@@ -1,5 +1,5 @@
-; RUN: opt < %s -globalopt -S | \
-; RUN: grep "call void @Actual"
+; RUN: opt < %s -globalopt -S | FileCheck %s
+; CHECK: call void @Actual
; Check that a comparison does not prevent an indirect call from being made
; direct. The global will still remain, but indirect call elim is still good.
@@ -27,4 +27,3 @@ DoCall: ; preds = %0
isNull: ; preds = %0
ret void
}
-
diff --git a/test/Transforms/GlobalOpt/storepointer.ll b/test/Transforms/GlobalOpt/storepointer.ll
index 9003004d431d6..8edaa64a62be9 100644
--- a/test/Transforms/GlobalOpt/storepointer.ll
+++ b/test/Transforms/GlobalOpt/storepointer.ll
@@ -1,4 +1,5 @@
-; RUN: opt < %s -globalopt -S | not grep global
+; RUN: opt < %s -globalopt -S | FileCheck %s
+; CHECK-NOT: global
@G = internal global void ()* null ; <void ()**> [#uses=2]
@@ -16,4 +17,3 @@ define void @doit() {
call void %FP( )
ret void
}
-
diff --git a/test/Transforms/GlobalOpt/trivialstore.ll b/test/Transforms/GlobalOpt/trivialstore.ll
index f907d8382d570..9a490879a41fe 100644
--- a/test/Transforms/GlobalOpt/trivialstore.ll
+++ b/test/Transforms/GlobalOpt/trivialstore.ll
@@ -1,4 +1,5 @@
-; RUN: opt < %s -globalopt -S | not grep G
+; RUN: opt < %s -globalopt -S | FileCheck %s
+; CHECK-NOT: G
@G = internal global i32 17 ; <i32*> [#uses=3]
@@ -16,4 +17,3 @@ define internal void @dead() {
store i32 123, i32* @G
ret void
}
-
diff --git a/test/Transforms/GlobalOpt/undef-init.ll b/test/Transforms/GlobalOpt/undef-init.ll
index d304821225eaf..71fad343e56d8 100644
--- a/test/Transforms/GlobalOpt/undef-init.ll
+++ b/test/Transforms/GlobalOpt/undef-init.ll
@@ -1,4 +1,5 @@
-; RUN: opt < %s -globalopt -S | not grep store
+; RUN: opt < %s -globalopt -S | FileCheck %s
+; CHECK-NOT: store
@llvm.global_ctors = appending global [1 x { i32, void ()* }] [ { i32, void ()* } { i32 65535, void ()* @_GLOBAL__I__Z3foov } ] ; <[1 x { i32, void ()* }]*> [#uses=0]
@X.0 = internal global i32 undef ; <i32*> [#uses=2]
@@ -14,4 +15,3 @@ entry:
store i32 1, i32* @X.0
ret void
}
-
diff --git a/test/Transforms/GlobalOpt/unnamed-addr.ll b/test/Transforms/GlobalOpt/unnamed-addr.ll
index de436c62a3474..9f11f1bd92c22 100644
--- a/test/Transforms/GlobalOpt/unnamed-addr.ll
+++ b/test/Transforms/GlobalOpt/unnamed-addr.ll
@@ -10,7 +10,7 @@
; CHECK: @b = internal global i32 0, align 4
; CHECK: @c = internal unnamed_addr global i32 0, align 4
; CHECK: @d = internal unnamed_addr constant [4 x i8] c"foo\00", align 1
-; CHECK: @e = linkonce_odr global i32 0
+; CHECK: @e = linkonce_odr local_unnamed_addr global i32 0
; CHECK: define internal fastcc void @used_internal() unnamed_addr {
define internal void @used_internal() {