aboutsummaryrefslogtreecommitdiff
path: root/test/CodeGen/builtin-memfns.c
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2011-04-17 00:40:24 +0000
committerChris Lattner <sabre@nondot.org>2011-04-17 00:40:24 +0000
commita5e5e0f41e1dcee4603244ccea3d3956c55c23ac (patch)
treea5e450a8f3a27ad181a0656084c3b89cf6a197b9 /test/CodeGen/builtin-memfns.c
parentc6bea67efc38b075c401ebdb6ae97afa08cbb51d (diff)
fold memcpy/set/move_chk to llvm.memcpy/set/move when the sizes
are trivial. This exposes opportunities earlier, and allows fastisel to do good things with these at -O0. This addresses rdar://9289468 - clang doesn't fold memset_chk at -O0 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129651 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen/builtin-memfns.c')
-rw-r--r--test/CodeGen/builtin-memfns.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/test/CodeGen/builtin-memfns.c b/test/CodeGen/builtin-memfns.c
index e8c407fd6f..2ea6793654 100644
--- a/test/CodeGen/builtin-memfns.c
+++ b/test/CodeGen/builtin-memfns.c
@@ -1,12 +1,13 @@
// RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm < %s| FileCheck %s
+// CHECK: @test1
// CHECK: call void @llvm.memset.p0i8.i32
// CHECK: call void @llvm.memset.p0i8.i32
// CHECK: call void @llvm.memcpy.p0i8.p0i8.i32
// CHECK: call void @llvm.memmove.p0i8.p0i8.i32
// CHECK-NOT: __builtin
// CHECK: ret
-int main(int argc, char **argv) {
+int test1(int argc, char **argv) {
unsigned char a = 0x11223344;
unsigned char b = 0x11223344;
__builtin_bzero(&a, sizeof(a));
@@ -15,3 +16,29 @@ int main(int argc, char **argv) {
__builtin_memmove(&a, &b, sizeof(a));
return 0;
}
+
+// rdar://9289468
+
+// CHECK: @test2
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i32
+char* test2(char* a, char* b) {
+ return __builtin_memcpy(a, b, 4);
+}
+
+// CHECK: @test3
+// CHECK: call void @llvm.memset
+void test3(char *P) {
+ __builtin___memset_chk(P, 42, 128, 128);
+}
+
+// CHECK: @test4
+// CHECK: call void @llvm.memcpy
+void test4(char *P, char *Q) {
+ __builtin___memcpy_chk(P, Q, 128, 128);
+}
+
+// CHECK: @test5
+// CHECK: call void @llvm.memmove
+void test5(char *P, char *Q) {
+ __builtin___memmove_chk(P, Q, 128, 128);
+}