Revert "Reapply "[llvm-jitlink] Use concurrent linking by default." with fixes. ...
[llvm-project.git] / clang / test / CodeGen / libcalls-fno-builtin.c
blob6aef0efa1d9b7cffb13186c6724b64a24789e520
1 // RUN: %clang_cc1 -emit-llvm -fno-builtin -o - %s | FileCheck --check-prefixes=GLOBAL,CHECK %s
2 // RUN: %clang_cc1 -emit-llvm -fno-builtin-ceil -fno-builtin-copysign -fno-builtin-cos \
3 // RUN: -fno-builtin-fabs -fno-builtin-floor -fno-builtin-strcat -fno-builtin-strncat \
4 // RUN: -fno-builtin-strchr -fno-builtin-strrchr -fno-builtin-strcmp -fno-builtin-strncmp \
5 // RUN: -fno-builtin-strcpy -fno-builtin-stpcpy -fno-builtin-strncpy -fno-builtin-strlen \
6 // RUN: -fno-builtin-strpbrk -fno-builtin-strspn -fno-builtin-strtod -fno-builtin-strtof \
7 // RUN: -fno-builtin-strtold -fno-builtin-strtol -fno-builtin-strtoll -fno-builtin-strtoul \
8 // RUN: -fno-builtin-strtoull -fno-builtin-fread -fno-builtin-fwrite -fno-builtin-fopen \
9 // RUN: -o - %s | FileCheck --check-prefixes=INDIVIDUAL,CHECK %s
10 // RUN: %clang_cc1 -S -O3 -fno-builtin -o - %s | FileCheck --check-prefix=ASM %s
11 // RUN: %clang_cc1 -S -O3 -fno-builtin-ceil -o - %s | FileCheck --check-prefix=ASM-INDIV %s
13 typedef __SIZE_TYPE__ size_t;
14 typedef struct FILE FILE;
16 double ceil(double x);
17 double copysign(double,double);
18 double cos(double x);
19 double fabs(double x);
20 double floor(double x);
21 char *strcat(char *s1, const char *s2);
22 char *strncat(char *s1, const char *s2, size_t n);
23 char *strchr(const char *s, int c);
24 char *strrchr(const char *s, int c);
25 int strcmp(const char *s1, const char *s2);
26 int strncmp(const char *s1, const char *s2, size_t n);
27 char *strcpy(char *s1, const char *s2);
28 char *stpcpy(char *s1, const char *s2);
29 char *strncpy(char *s1, const char *s2, size_t n);
30 size_t strlen(const char *s);
31 char *strpbrk(const char *s1, const char *s2);
32 size_t strspn(const char *s1, const char *s2);
33 double strtod(const char *nptr, char **endptr);
34 float strtof(const char *nptr, char **endptr);
35 long double strtold(const char *nptr, char **endptr);
36 long int strtol(const char *nptr, char **endptr, int base);
37 long long int strtoll(const char *nptr, char **endptr, int base);
38 unsigned long int strtoul(const char *nptr, char **endptr, int base);
39 unsigned long long int strtoull(const char *nptr, char **endptr, int base);
40 size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream);
41 size_t fwrite(const void *ptr, size_t size, size_t nmemb,
42 FILE *stream);
43 FILE *fopen(const char *path, const char *mode);
45 double t1(double x) { return ceil(x); }
46 // CHECK-LABEL: t1
47 // CHECK: call{{.*}}@ceil{{.*}} [[ATTR:#[0-9]+]]
49 // ASM: t1
50 // ASM: ceil
52 // ASM-INDIV: t1
53 // ASM-INDIV: ceil
55 double t2(double x, double y) { return copysign(x,y); }
56 // CHECK-LABEL: t2
57 // CHECK: call{{.*}}@copysign{{.*}} #2
59 double t3(double x) { return cos(x); }
60 // CHECK-LABEL: t3
61 // CHECK: call{{.*}}@cos{{.*}} #2
63 double t4(double x) { return fabs(x); }
64 // CHECK-LABEL: t4
65 // CHECK: call{{.*}}@fabs{{.*}} #2
67 double t5(double x) { return floor(x); }
68 // CHECK-LABEL: t5
69 // CHECK: call{{.*}}@floor{{.*}} #2
71 char *t6(char *x) { return strcat(x, ""); }
72 // CHECK-LABEL: t6
73 // CHECK: call{{.*}}@strcat{{.*}} #2
75 char *t7(char *x) { return strncat(x, "", 1); }
76 // CHECK-LABEL: t7
77 // CHECK: call{{.*}}@strncat{{.*}} #2
79 char *t8(void) { return strchr("hello, world", 'w'); }
80 // CHECK-LABEL: t8
81 // CHECK: call{{.*}}@strchr{{.*}} #2
83 char *t9(void) { return strrchr("hello, world", 'w'); }
84 // CHECK-LABEL: t9
85 // CHECK: call{{.*}}@strrchr{{.*}} #2
87 int t10(void) { return strcmp("foo", "bar"); }
88 // CHECK-LABEL: t10
89 // CHECK: call{{.*}}@strcmp{{.*}} #2
91 int t11(void) { return strncmp("foo", "bar", 3); }
92 // CHECK-LABEL: t11
93 // CHECK: call{{.*}}@strncmp{{.*}} #2
95 char *t12(char *x) { return strcpy(x, "foo"); }
96 // CHECK-LABEL: t12
97 // CHECK: call{{.*}}@strcpy{{.*}} #2
99 char *t13(char *x) { return stpcpy(x, "foo"); }
100 // CHECK-LABEL: t13
101 // CHECK: call{{.*}}@stpcpy{{.*}} #2
103 char *t14(char *x) { return strncpy(x, "foo", 3); }
104 // CHECK-LABEL: t14
105 // CHECK: call{{.*}}@strncpy{{.*}} #2
107 size_t t15(void) { return strlen("foo"); }
108 // CHECK-LABEL: t15
109 // CHECK: call{{.*}}@strlen{{.*}} #2
111 char *t16(char *x) { return strpbrk(x, ""); }
112 // CHECK-LABEL: t16
113 // CHECK: call{{.*}}@strpbrk{{.*}} #2
115 size_t t17(char *x) { return strspn(x, ""); }
116 // CHECK-LABEL: t17
117 // CHECK: call{{.*}}@strspn{{.*}} #2
119 double t18(char **x) { return strtod("123.4", x); }
120 // CHECK-LABEL: t18
121 // CHECK: call{{.*}}@strtod{{.*}} #2
123 float t19(char **x) { return strtof("123.4", x); }
124 // CHECK-LABEL: t19
125 // CHECK: call{{.*}}@strtof{{.*}} #2
127 long double t20(char **x) { return strtold("123.4", x); }
128 // CHECK-LABEL: t20
129 // CHECK: call{{.*}}@strtold{{.*}} #2
131 long int t21(char **x) { return strtol("1234", x, 10); }
132 // CHECK-LABEL: t21
133 // CHECK: call{{.*}}@strtol{{.*}} #2
135 long int t22(char **x) { return strtoll("1234", x, 10); }
136 // CHECK-LABEL: t22
137 // CHECK: call{{.*}}@strtoll{{.*}} #2
139 long int t23(char **x) { return strtoul("1234", x, 10); }
140 // CHECK-LABEL: t23
141 // CHECK: call{{.*}}@strtoul{{.*}} #2
143 long int t24(char **x) { return strtoull("1234", x, 10); }
144 // CHECK-LABEL: t24
145 // CHECK: call{{.*}}@strtoull{{.*}} #2
147 void t25(FILE *fp, int *buf) {
148 size_t x = fwrite(buf, sizeof(int), 10, fp);
149 size_t y = fread(buf, sizeof(int), 10, fp);
151 // CHECK-LABEL: t25
152 // CHECK: call{{.*}}@fwrite{{.*}} #2
153 // CHECK: call{{.*}}@fread{{.*}} #2
155 FILE *t26(const char *path, const char *mode) {
156 return fopen(path, mode);
158 // CHECK-LABEL: t26
159 // CHECK: call{{.*}}@fopen{{.*}} #2
161 // GLOBAL: #2 = { nobuiltin "no-builtins" }
162 // INDIVIDUAL: #2 = { nobuiltin "no-builtin-ceil" "no-builtin-copysign" "no-builtin-cos" "no-builtin-fabs" "no-builtin-floor" "no-builtin-fopen" "no-builtin-fread" "no-builtin-fwrite" "no-builtin-stpcpy" "no-builtin-strcat" "no-builtin-strchr" "no-builtin-strcmp" "no-builtin-strcpy" "no-builtin-strlen" "no-builtin-strncat" "no-builtin-strncmp" "no-builtin-strncpy" "no-builtin-strpbrk" "no-builtin-strrchr" "no-builtin-strspn" "no-builtin-strtod" "no-builtin-strtof" "no-builtin-strtol" "no-builtin-strtold" "no-builtin-strtoll" "no-builtin-strtoul" "no-builtin-strtoull" }