summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGen/decl.c
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-12-05 08:22:11 +0000
committerChris Lattner <sabre@nondot.org>2009-12-05 08:22:11 +0000
commite99c110d06545a8051c5fe47b844ed7fc1bfb96f (patch)
tree687ff93fbb8a00168a55facbacd8d2a18dfa9cb3 /clang/test/CodeGen/decl.c
parente08ea7874a5ee932d874596e51f84d9c8d9046fe (diff)
downloadbcm5719-llvm-e99c110d06545a8051c5fe47b844ed7fc1bfb96f.tar.gz
bcm5719-llvm-e99c110d06545a8051c5fe47b844ed7fc1bfb96f.zip
implement rdar://7346691 by codegen'ing struct/array initializers
to a memset or a memcpy from a global when possible. llvm-svn: 90658
Diffstat (limited to 'clang/test/CodeGen/decl.c')
-rw-r--r--clang/test/CodeGen/decl.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/clang/test/CodeGen/decl.c b/clang/test/CodeGen/decl.c
index e2d55ecaf1c..b26843132c2 100644
--- a/clang/test/CodeGen/decl.c
+++ b/clang/test/CodeGen/decl.c
@@ -1,6 +1,9 @@
// RUN: clang-cc -emit-llvm < %s | FileCheck %s
// CHECK: @test1.x = internal constant [12 x i32] [i32 1
+// CHECK: @test2.x = internal constant [13 x i32] [i32 1,
+
+#include <string.h>
void test1() {
// This should codegen as a "@test1.x" global.
@@ -10,3 +13,28 @@ void test1() {
// CHECK: @test1()
// CHECK: {{call.*@foo.*@test1.x}}
}
+
+
+// rdar://7346691
+void test2() {
+ // This should codegen as a "@test2.x" global + memcpy.
+ int x[] = { 1, 2, 3, 4, 6, 8, 9, 10, 123, 231, 123,23, 24 };
+ foo(x);
+
+ // CHECK: @test2()
+ // CHECK: %x = alloca [13 x i32]
+ // CHECK: call void @llvm.memcpy
+ // CHECK: call{{.*}}@foo{{.*}}i32* %
+}
+
+
+void test3() {
+ // This should codegen as a "@test3.x" global + memcpy.
+ int x[100] = { 0 };
+ foo(x);
+
+ // CHECK: @test3()
+ // CHECK: %x = alloca [100 x i32]
+ // CHECK: call void @llvm.memset
+}
+
OpenPOWER on IntegriCloud