1 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -O0 -emit-llvm -o - %s | FileCheck %s
2
3 void use(void *);
4
test_small()5 void test_small() {
6 // CHECK-LABEL: define void @test_small()
7 int a[] = {1, 2, 3, 4};
8 // CHECK: call void @llvm.memcpy.{{.*}}
9 use(a);
10 }
11
test_small_same()12 void test_small_same() {
13 // CHECK-LABEL: define void @test_small_same()
14 char a[] = {'a', 'a', 'a', 'a'};
15 // CHECK: call void @llvm.memcpy.{{.*}}
16 use(a);
17 }
18
test_different()19 void test_different() {
20 // CHECK-LABEL: define void @test_different()
21 int a[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
22 // CHECK: call void @llvm.memcpy.{{.*}}
23 use(a);
24 }
25
test_all_zeros()26 void test_all_zeros() {
27 // CHECK-LABEL: define void @test_all_zeros()
28 int a[16] = {};
29 // CHECK: call void @llvm.memset.{{.*}}
30 use(a);
31 }
32
test_all_a()33 void test_all_a() {
34 // CHECK-LABEL: define void @test_all_a()
35 char a[] = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
36 // CHECK: call void @llvm.memcpy.{{.*}}
37 use(a);
38 }
39
test_most_zeros()40 void test_most_zeros() {
41 // CHECK-LABEL: define void @test_most_zeros()
42 int a[16] = {0, 0, 1};
43 // CHECK: call void @llvm.memset.{{.*}}
44 // CHECK: store i32 1
45 use(a);
46 }
47
test_most_a()48 void test_most_a() {
49 // CHECK-LABEL: define void @test_most_a()
50 char a[] = "aaaaazaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
51 // CHECK: call void @llvm.memcpy.{{.*}}
52 use(a);
53 }
54
test_pointers()55 void test_pointers() {
56 // CHECK-LABEL: define void @test_pointers()
57 void *a[] = {&use, &use, &use, &use, &use, &use};
58 // CHECK: call void @llvm.memset.{{.*}}
59 // CHECK: store i8*
60 // CHECK: store i8*
61 // CHECK: store i8*
62 // CHECK: store i8*
63 // CHECK: store i8*
64 // CHECK: store i8*
65 use(a);
66 }
67