File: no-builtin-2.c

package info (click to toggle)
llvm-toolchain-20 1%3A20.1.6-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,111,304 kB
  • sloc: cpp: 7,438,677; ansic: 1,393,822; asm: 1,012,926; python: 241,650; f90: 86,635; objc: 75,479; lisp: 42,144; pascal: 17,286; sh: 10,027; ml: 5,082; perl: 4,730; awk: 3,523; makefile: 3,349; javascript: 2,251; xml: 892; fortran: 672
file content (63 lines) | stat: -rw-r--r-- 2,160 bytes parent folder | download | duplicates (15)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s

typedef typeof(sizeof(0)) size_t;

void bar(char *s);
void *memset(void *s, int c, size_t n);
void *memcpy(void *d, const void *s, size_t n);
void *memmove(void *d, const void *s, size_t n);

// CHECK: define{{.*}} void @foo1({{.*}}) #[[NO_NOBUILTIN:[0-9]+]]
// CHECK:   call void @bar
// CHECK:   call void @llvm.memset
// CHECK:   call void @llvm.memcpy
// CHECK:   call void @llvm.memmove
void foo1(char *s, char *d, size_t n) {
  bar(s);
  memset(s, 0, n);
  memcpy(d, s, n);
  memmove(d, s, n);
}

// CHECK: define{{.*}} void @foo2({{.*}}) #[[NOBUILTIN_MEMSET:[0-9]+]]
// CHECK:   call void @bar
// CHECK:   {{.*}}call {{.*}} @memset
// CHECK:   call void @llvm.memcpy
// CHECK:   call void @llvm.memmove
void foo2(char *s, char *d, size_t n) __attribute__((no_builtin("memset"))) {
  bar(s);
  memset(s, 1, n);
  memcpy(d, s, n);
  memmove(d, s, n);
}

// CHECK: define{{.*}} void @foo3({{.*}}) #[[NOBUILTIN_MEMSET_MEMCPY:[0-9]+]]
// CHECK:   call void @bar
// CHECK:   {{.*}}call {{.*}} @memset
// CHECK:   {{.*}}call {{.*}} @memcpy
// CHECK:   call void @llvm.memmove
void foo3(char *s, char *d, size_t n) __attribute__((no_builtin("memset", "memcpy"))) {
  bar(s);
  memset(s, 2, n);
  memcpy(d, s, n);
  memmove(d, s, n);
}

// CHECK: define{{.*}} void @foo4({{.*}}) #[[NOBUILTINS:[0-9]+]]
// CHECK:   call void @bar
// CHECK:   {{.*}}call {{.*}} @memset
// CHECK:   {{.*}}call {{.*}} @memcpy
// CHECK:   {{.*}}call {{.*}} @memmove
void foo4(char *s, char *d, size_t n) __attribute__((no_builtin)) {
  bar(s);
  memset(s, 2, n);
  memcpy(d, s, n);
  memmove(s, d, n);
}

// CHECK-NOT: attributes #[[NO_NOBUILTIN]] = {{{.*}}"no-builtin-memset"{{.*}}}
// CHECK-NOT: attributes #[[NO_NOBUILTIN]] = {{{.*}}"no-builtin-memcpy"{{.*}}"no-builtin-memset"{{.*}}}
// CHECK-NOT: attributes #[[NO_NOBUILTIN]] = {{{.*}}"no-builtins"{{.*}}}
// CHECK:     attributes #[[NOBUILTIN_MEMSET]] = {{{.*}}"no-builtin-memset"{{.*}}}
// CHECK:     attributes #[[NOBUILTIN_MEMSET_MEMCPY]] = {{{.*}}"no-builtin-memcpy"{{.*}}"no-builtin-memset"{{.*}}}
// CHECK:     attributes #[[NOBUILTINS]] = {{{.*}}"no-builtins"{{.*}}}