summaryrefslogtreecommitdiffstats
path: root/test/Transforms/GlobalOpt
diff options
context:
space:
mode:
authorrdivacky <rdivacky@FreeBSD.org>2009-10-23 14:19:52 +0000
committerrdivacky <rdivacky@FreeBSD.org>2009-10-23 14:19:52 +0000
commit9643cca39fb9fb3b49a8912926de98acf882283c (patch)
tree22cc59e4b240d84c3a5a60531119c4eca914a256 /test/Transforms/GlobalOpt
parent1adacceba9c9ee0f16e54388e56c9a249b296f75 (diff)
downloadFreeBSD-src-9643cca39fb9fb3b49a8912926de98acf882283c.zip
FreeBSD-src-9643cca39fb9fb3b49a8912926de98acf882283c.tar.gz
Update LLVM to r84949.
Diffstat (limited to 'test/Transforms/GlobalOpt')
-rw-r--r--test/Transforms/GlobalOpt/2009-11-16-BrokenPerformHeapAllocSRoA.ll26
-rw-r--r--test/Transforms/GlobalOpt/2009-11-16-MallocSingleStoreToGlobalVar.ll30
-rw-r--r--test/Transforms/GlobalOpt/malloc-promote-2.ll4
-rw-r--r--test/Transforms/GlobalOpt/malloc-promote-3.ll4
4 files changed, 62 insertions, 2 deletions
diff --git a/test/Transforms/GlobalOpt/2009-11-16-BrokenPerformHeapAllocSRoA.ll b/test/Transforms/GlobalOpt/2009-11-16-BrokenPerformHeapAllocSRoA.ll
new file mode 100644
index 0000000..54e8f90
--- /dev/null
+++ b/test/Transforms/GlobalOpt/2009-11-16-BrokenPerformHeapAllocSRoA.ll
@@ -0,0 +1,26 @@
+; RUN: opt < %s -globalopt -S | FileCheck %s
+
+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-apple-darwin10.0"
+
+%struct.hashheader = type { i16, i16, i16, i16, i16, i16, i32, i32, i32, i32, i32, i32, i32, i32, i32, [5 x i8], [13 x i8], i8, i8, i8, [228 x i16], [228 x i8], [228 x i8], [228 x i8], [228 x i8], [228 x i8], [228 x i8], [128 x i8], [100 x [11 x i8]], [100 x i32], [100 x i32], i16 }
+%struct.strchartype = type { i8*, i8*, i8* }
+
+@hashheader = internal global %struct.hashheader zeroinitializer, align 32 ; <%struct.hashheader*> [#uses=1]
+@chartypes = internal global %struct.strchartype* null ; <%struct.strchartype**> [#uses=1]
+; CHECK-NOT: @hashheader
+; CHECK-NOT: @chartypes
+
+; based on linit in office-ispell
+define void @test() nounwind ssp {
+ %1 = load i32* getelementptr inbounds (%struct.hashheader* @hashheader, i64 0, i32 13), align 8 ; <i32> [#uses=1]
+ %2 = sext i32 %1 to i64 ; <i64> [#uses=1]
+ %3 = mul i64 %2, ptrtoint (%struct.strchartype* getelementptr (%struct.strchartype* null, i64 1) to i64) ; <i64> [#uses=1]
+ %4 = tail call i8* @malloc(i64 %3) ; <i8*> [#uses=1]
+; CHECK: call i8* @malloc(i64
+ %5 = bitcast i8* %4 to %struct.strchartype* ; <%struct.strchartype*> [#uses=1]
+ store %struct.strchartype* %5, %struct.strchartype** @chartypes, align 8
+ ret void
+}
+
+declare noalias i8* @malloc(i64)
diff --git a/test/Transforms/GlobalOpt/2009-11-16-MallocSingleStoreToGlobalVar.ll b/test/Transforms/GlobalOpt/2009-11-16-MallocSingleStoreToGlobalVar.ll
new file mode 100644
index 0000000..c43565a
--- /dev/null
+++ b/test/Transforms/GlobalOpt/2009-11-16-MallocSingleStoreToGlobalVar.ll
@@ -0,0 +1,30 @@
+; Test ensures that non-optimizable array mallocs are not optimized; specifically
+; GlobalOpt was treating a non-optimizable array malloc as a non-array malloc
+; and optimizing the global object that the malloc was stored to as a single
+; element global. The global object @TOP in this test should not be optimized.
+; RUN: opt < %s -globalopt -S | FileCheck %s
+
+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-apple-darwin10.0"
+
+@TOP = internal global i64* null ; <i64**> [#uses=2]
+; CHECK: @TOP = internal global i64* null
+@channelColumns = internal global i64 0 ; <i64*> [#uses=2]
+
+; Derived from @DescribeChannel() in yacr2
+define void @test() nounwind ssp {
+ store i64 2335, i64* @channelColumns, align 8
+ %1 = load i64* @channelColumns, align 8 ; <i64> [#uses=1]
+ %2 = shl i64 %1, 3 ; <i64> [#uses=1]
+ %3 = add i64 %2, 8 ; <i64> [#uses=1]
+ %4 = call noalias i8* @malloc(i64 %3) nounwind ; <i8*> [#uses=1]
+; CHECK: call noalias i8* @malloc
+ %5 = bitcast i8* %4 to i64* ; <i64*> [#uses=1]
+ store i64* %5, i64** @TOP, align 8
+ %6 = load i64** @TOP, align 8 ; <i64*> [#uses=1]
+ %7 = getelementptr inbounds i64* %6, i64 13 ; <i64*> [#uses=1]
+ store i64 0, i64* %7, align 8
+ ret void
+}
+
+declare noalias i8* @malloc(i64) nounwind
diff --git a/test/Transforms/GlobalOpt/malloc-promote-2.ll b/test/Transforms/GlobalOpt/malloc-promote-2.ll
index 0d03835..d3d2252 100644
--- a/test/Transforms/GlobalOpt/malloc-promote-2.ll
+++ b/test/Transforms/GlobalOpt/malloc-promote-2.ll
@@ -1,4 +1,6 @@
-; RUN: opt < %s -globalopt -S | not grep malloc
+; RUN: opt < %s -globalopt -globaldce -S | not grep malloc
+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 = "i686-apple-darwin8"
@G = internal global i32* null ; <i32**> [#uses=3]
diff --git a/test/Transforms/GlobalOpt/malloc-promote-3.ll b/test/Transforms/GlobalOpt/malloc-promote-3.ll
index d4ee4e8..a920b61 100644
--- a/test/Transforms/GlobalOpt/malloc-promote-3.ll
+++ b/test/Transforms/GlobalOpt/malloc-promote-3.ll
@@ -1,4 +1,6 @@
-; RUN: opt < %s -globalopt -S | not grep malloc
+; RUN: opt < %s -globalopt -globaldce -S | not grep malloc
+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 = "i686-apple-darwin8"
@G = internal global i32* null ; <i32**> [#uses=4]
OpenPOWER on IntegriCloud