summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGen/init.c
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-12-02 01:58:41 +0000
committerChris Lattner <sabre@nondot.org>2010-12-02 01:58:41 +0000
commite6af88628fabe91b8a63b98b82006dd07bd50df5 (patch)
treea9c2aab57a24cee170c139a5a0ad4872e51edf08 /clang/test/CodeGen/init.c
parent68324f756d63845d81cb3ed946d0f08a3678f8b9 (diff)
downloadbcm5719-llvm-e6af88628fabe91b8a63b98b82006dd07bd50df5.tar.gz
bcm5719-llvm-e6af88628fabe91b8a63b98b82006dd07bd50df5.zip
Enhance the init generation logic to emit a memset followed by a few stores when
a global is larger than 32 bytes and has fewer than 6 non-zero values in the initializer. Previously we'd turn something like this: char test8(int X) { char str[10000] = "abc"; into a 10K global variable which we then memcpy'd from. Now we generate: %str = alloca [10000 x i8], align 16 %tmp = getelementptr inbounds [10000 x i8]* %str, i64 0, i64 0 call void @llvm.memset.p0i8.i64(i8* %tmp, i8 0, i64 10000, i32 16, i1 false) store i8 97, i8* %tmp, align 16 %0 = getelementptr [10000 x i8]* %str, i64 0, i64 1 store i8 98, i8* %0, align 1 %1 = getelementptr [10000 x i8]* %str, i64 0, i64 2 store i8 99, i8* %1, align 2 Which is much smaller in space and also likely faster. This is part of PR279 llvm-svn: 120645
Diffstat (limited to 'clang/test/CodeGen/init.c')
-rw-r--r--clang/test/CodeGen/init.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/test/CodeGen/init.c b/clang/test/CodeGen/init.c
index dc9f82a6c1a..2dee0432efc 100644
--- a/clang/test/CodeGen/init.c
+++ b/clang/test/CodeGen/init.c
@@ -58,3 +58,15 @@ struct a7 {
};
struct a7 test7 = { .b = 0, .v = "bar" };
+
+
+// PR279 comment #3
+char test8(int X) {
+ char str[100000] = "abc"; // tail should be memset.
+ return str[X];
+// CHECK: @test8(
+// CHECK: call void @llvm.memset
+// CHECK: store i8 97
+// CHECK: store i8 98
+// CHECK: store i8 99
+}
OpenPOWER on IntegriCloud