2019-12-09 19:22:27 +08:00
|
|
|
// RUN: %clang_cc1 -S -emit-llvm -fno-builtin -o - %s | FileCheck --check-prefixes=GLOBAL,CHECK %s
|
2018-05-24 14:00:50 +08:00
|
|
|
// RUN: %clang_cc1 -S -emit-llvm -fno-builtin-ceil -fno-builtin-copysign -fno-builtin-cos \
|
2016-01-06 22:35:46 +08:00
|
|
|
// RUN: -fno-builtin-fabs -fno-builtin-floor -fno-builtin-strcat -fno-builtin-strncat \
|
|
|
|
// RUN: -fno-builtin-strchr -fno-builtin-strrchr -fno-builtin-strcmp -fno-builtin-strncmp \
|
|
|
|
// RUN: -fno-builtin-strcpy -fno-builtin-stpcpy -fno-builtin-strncpy -fno-builtin-strlen \
|
|
|
|
// RUN: -fno-builtin-strpbrk -fno-builtin-strspn -fno-builtin-strtod -fno-builtin-strtof \
|
|
|
|
// RUN: -fno-builtin-strtold -fno-builtin-strtol -fno-builtin-strtoll -fno-builtin-strtoul \
|
2018-05-31 05:11:45 +08:00
|
|
|
// RUN: -fno-builtin-strtoull -fno-builtin-fread -fno-builtin-fwrite -fno-builtin-fopen \
|
2019-12-09 19:22:27 +08:00
|
|
|
// RUN: -o - %s | FileCheck --check-prefixes=INDIVIDUAL,CHECK %s
|
2018-05-24 14:00:50 +08:00
|
|
|
// RUN: %clang_cc1 -S -O3 -fno-builtin -o - %s | FileCheck --check-prefix=ASM %s
|
|
|
|
// RUN: %clang_cc1 -S -O3 -fno-builtin-ceil -o - %s | FileCheck --check-prefix=ASM-INDIV %s
|
2018-05-24 14:09:28 +08:00
|
|
|
|
2012-03-01 04:18:57 +08:00
|
|
|
// rdar://10551066
|
2012-03-01 04:14:59 +08:00
|
|
|
|
2012-11-10 11:56:55 +08:00
|
|
|
typedef __SIZE_TYPE__ size_t;
|
2018-05-24 14:09:28 +08:00
|
|
|
typedef struct FILE FILE;
|
2012-11-10 11:56:55 +08:00
|
|
|
|
2012-03-01 04:14:59 +08:00
|
|
|
double ceil(double x);
|
|
|
|
double copysign(double,double);
|
|
|
|
double cos(double x);
|
|
|
|
double fabs(double x);
|
|
|
|
double floor(double x);
|
2012-11-10 11:56:55 +08:00
|
|
|
char *strcat(char *s1, const char *s2);
|
|
|
|
char *strncat(char *s1, const char *s2, size_t n);
|
|
|
|
char *strchr(const char *s, int c);
|
|
|
|
char *strrchr(const char *s, int c);
|
|
|
|
int strcmp(const char *s1, const char *s2);
|
|
|
|
int strncmp(const char *s1, const char *s2, size_t n);
|
|
|
|
char *strcpy(char *s1, const char *s2);
|
|
|
|
char *stpcpy(char *s1, const char *s2);
|
|
|
|
char *strncpy(char *s1, const char *s2, size_t n);
|
|
|
|
size_t strlen(const char *s);
|
|
|
|
char *strpbrk(const char *s1, const char *s2);
|
|
|
|
size_t strspn(const char *s1, const char *s2);
|
|
|
|
double strtod(const char *nptr, char **endptr);
|
|
|
|
float strtof(const char *nptr, char **endptr);
|
|
|
|
long double strtold(const char *nptr, char **endptr);
|
|
|
|
long int strtol(const char *nptr, char **endptr, int base);
|
|
|
|
long long int strtoll(const char *nptr, char **endptr, int base);
|
|
|
|
unsigned long int strtoul(const char *nptr, char **endptr, int base);
|
|
|
|
unsigned long long int strtoull(const char *nptr, char **endptr, int base);
|
2018-05-24 14:09:28 +08:00
|
|
|
size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream);
|
|
|
|
size_t fwrite(const void *ptr, size_t size, size_t nmemb,
|
|
|
|
FILE *stream);
|
2018-05-31 05:11:45 +08:00
|
|
|
FILE *fopen(const char *path, const char *mode);
|
2012-03-01 04:14:59 +08:00
|
|
|
|
|
|
|
double t1(double x) { return ceil(x); }
|
2018-05-24 14:00:50 +08:00
|
|
|
// CHECK-LABEL: t1
|
|
|
|
// CHECK: call{{.*}}@ceil{{.*}} [[ATTR:#[0-9]+]]
|
|
|
|
|
|
|
|
// ASM: t1
|
|
|
|
// ASM: ceil
|
|
|
|
|
|
|
|
// ASM-INDIV: t1
|
|
|
|
// ASM-INDIV: ceil
|
2012-03-01 04:14:59 +08:00
|
|
|
|
|
|
|
double t2(double x, double y) { return copysign(x,y); }
|
2018-05-24 14:00:50 +08:00
|
|
|
// CHECK-LABEL: t2
|
2019-12-09 19:22:27 +08:00
|
|
|
// CHECK: call{{.*}}@copysign{{.*}} #2
|
2012-03-01 04:14:59 +08:00
|
|
|
|
|
|
|
double t3(double x) { return cos(x); }
|
2018-05-24 14:00:50 +08:00
|
|
|
// CHECK-LABEL: t3
|
2019-12-09 19:22:27 +08:00
|
|
|
// CHECK: call{{.*}}@cos{{.*}} #2
|
2012-03-01 04:14:59 +08:00
|
|
|
|
|
|
|
double t4(double x) { return fabs(x); }
|
2018-05-24 14:00:50 +08:00
|
|
|
// CHECK-LABEL: t4
|
2019-12-09 19:22:27 +08:00
|
|
|
// CHECK: call{{.*}}@fabs{{.*}} #2
|
2012-03-01 04:14:59 +08:00
|
|
|
|
|
|
|
double t5(double x) { return floor(x); }
|
2018-05-24 14:00:50 +08:00
|
|
|
// CHECK-LABEL: t5
|
2019-12-09 19:22:27 +08:00
|
|
|
// CHECK: call{{.*}}@floor{{.*}} #2
|
2012-11-10 11:56:55 +08:00
|
|
|
|
|
|
|
char *t6(char *x) { return strcat(x, ""); }
|
2018-05-24 14:00:50 +08:00
|
|
|
// CHECK-LABEL: t6
|
2019-12-09 19:22:27 +08:00
|
|
|
// CHECK: call{{.*}}@strcat{{.*}} #2
|
2012-11-10 11:56:55 +08:00
|
|
|
|
|
|
|
char *t7(char *x) { return strncat(x, "", 1); }
|
2018-05-24 14:00:50 +08:00
|
|
|
// CHECK-LABEL: t7
|
2019-12-09 19:22:27 +08:00
|
|
|
// CHECK: call{{.*}}@strncat{{.*}} #2
|
2012-11-10 11:56:55 +08:00
|
|
|
|
|
|
|
char *t8(void) { return strchr("hello, world", 'w'); }
|
2018-05-24 14:00:50 +08:00
|
|
|
// CHECK-LABEL: t8
|
2019-12-09 19:22:27 +08:00
|
|
|
// CHECK: call{{.*}}@strchr{{.*}} #2
|
2012-11-10 11:56:55 +08:00
|
|
|
|
|
|
|
char *t9(void) { return strrchr("hello, world", 'w'); }
|
2018-05-24 14:00:50 +08:00
|
|
|
// CHECK-LABEL: t9
|
2019-12-09 19:22:27 +08:00
|
|
|
// CHECK: call{{.*}}@strrchr{{.*}} #2
|
2012-11-10 11:56:55 +08:00
|
|
|
|
|
|
|
int t10(void) { return strcmp("foo", "bar"); }
|
2018-05-24 14:00:50 +08:00
|
|
|
// CHECK-LABEL: t10
|
2019-12-09 19:22:27 +08:00
|
|
|
// CHECK: call{{.*}}@strcmp{{.*}} #2
|
2012-11-10 11:56:55 +08:00
|
|
|
|
|
|
|
int t11(void) { return strncmp("foo", "bar", 3); }
|
2018-05-24 14:00:50 +08:00
|
|
|
// CHECK-LABEL: t11
|
2019-12-09 19:22:27 +08:00
|
|
|
// CHECK: call{{.*}}@strncmp{{.*}} #2
|
2012-11-10 11:56:55 +08:00
|
|
|
|
|
|
|
char *t12(char *x) { return strcpy(x, "foo"); }
|
2018-05-24 14:00:50 +08:00
|
|
|
// CHECK-LABEL: t12
|
2019-12-09 19:22:27 +08:00
|
|
|
// CHECK: call{{.*}}@strcpy{{.*}} #2
|
2012-11-10 11:56:55 +08:00
|
|
|
|
|
|
|
char *t13(char *x) { return stpcpy(x, "foo"); }
|
2018-05-24 14:00:50 +08:00
|
|
|
// CHECK-LABEL: t13
|
2019-12-09 19:22:27 +08:00
|
|
|
// CHECK: call{{.*}}@stpcpy{{.*}} #2
|
2012-11-10 11:56:55 +08:00
|
|
|
|
|
|
|
char *t14(char *x) { return strncpy(x, "foo", 3); }
|
2018-05-24 14:00:50 +08:00
|
|
|
// CHECK-LABEL: t14
|
2019-12-09 19:22:27 +08:00
|
|
|
// CHECK: call{{.*}}@strncpy{{.*}} #2
|
2012-11-10 11:56:55 +08:00
|
|
|
|
|
|
|
size_t t15(void) { return strlen("foo"); }
|
2018-05-24 14:00:50 +08:00
|
|
|
// CHECK-LABEL: t15
|
2019-12-09 19:22:27 +08:00
|
|
|
// CHECK: call{{.*}}@strlen{{.*}} #2
|
2012-11-10 11:56:55 +08:00
|
|
|
|
|
|
|
char *t16(char *x) { return strpbrk(x, ""); }
|
2018-05-24 14:00:50 +08:00
|
|
|
// CHECK-LABEL: t16
|
2019-12-09 19:22:27 +08:00
|
|
|
// CHECK: call{{.*}}@strpbrk{{.*}} #2
|
2012-11-10 11:56:55 +08:00
|
|
|
|
|
|
|
size_t t17(char *x) { return strspn(x, ""); }
|
2018-05-24 14:00:50 +08:00
|
|
|
// CHECK-LABEL: t17
|
2019-12-09 19:22:27 +08:00
|
|
|
// CHECK: call{{.*}}@strspn{{.*}} #2
|
2012-11-10 11:56:55 +08:00
|
|
|
|
|
|
|
double t18(char **x) { return strtod("123.4", x); }
|
2018-05-24 14:00:50 +08:00
|
|
|
// CHECK-LABEL: t18
|
2019-12-09 19:22:27 +08:00
|
|
|
// CHECK: call{{.*}}@strtod{{.*}} #2
|
2012-11-10 11:56:55 +08:00
|
|
|
|
|
|
|
float t19(char **x) { return strtof("123.4", x); }
|
2018-05-24 14:00:50 +08:00
|
|
|
// CHECK-LABEL: t19
|
2019-12-09 19:22:27 +08:00
|
|
|
// CHECK: call{{.*}}@strtof{{.*}} #2
|
2012-11-10 11:56:55 +08:00
|
|
|
|
|
|
|
long double t20(char **x) { return strtold("123.4", x); }
|
2018-05-24 14:00:50 +08:00
|
|
|
// CHECK-LABEL: t20
|
2019-12-09 19:22:27 +08:00
|
|
|
// CHECK: call{{.*}}@strtold{{.*}} #2
|
2012-11-10 11:56:55 +08:00
|
|
|
|
|
|
|
long int t21(char **x) { return strtol("1234", x, 10); }
|
2018-05-24 14:00:50 +08:00
|
|
|
// CHECK-LABEL: t21
|
2019-12-09 19:22:27 +08:00
|
|
|
// CHECK: call{{.*}}@strtol{{.*}} #2
|
2012-11-10 11:56:55 +08:00
|
|
|
|
|
|
|
long int t22(char **x) { return strtoll("1234", x, 10); }
|
2018-05-24 14:00:50 +08:00
|
|
|
// CHECK-LABEL: t22
|
2019-12-09 19:22:27 +08:00
|
|
|
// CHECK: call{{.*}}@strtoll{{.*}} #2
|
2012-11-10 11:56:55 +08:00
|
|
|
|
|
|
|
long int t23(char **x) { return strtoul("1234", x, 10); }
|
2018-05-24 14:00:50 +08:00
|
|
|
// CHECK-LABEL: t23
|
2019-12-09 19:22:27 +08:00
|
|
|
// CHECK: call{{.*}}@strtoul{{.*}} #2
|
2012-11-10 11:56:55 +08:00
|
|
|
|
|
|
|
long int t24(char **x) { return strtoull("1234", x, 10); }
|
2018-05-24 14:00:50 +08:00
|
|
|
// CHECK-LABEL: t24
|
2019-12-09 19:22:27 +08:00
|
|
|
// CHECK: call{{.*}}@strtoull{{.*}} #2
|
2018-05-24 14:00:50 +08:00
|
|
|
|
2018-05-24 14:09:28 +08:00
|
|
|
void t25(FILE *fp, int *buf) {
|
|
|
|
size_t x = fwrite(buf, sizeof(int), 10, fp);
|
|
|
|
size_t y = fread(buf, sizeof(int), 10, fp);
|
|
|
|
}
|
|
|
|
// CHECK-LABEL: t25
|
2019-12-09 19:22:27 +08:00
|
|
|
// CHECK: call{{.*}}@fwrite{{.*}} #2
|
|
|
|
// CHECK: call{{.*}}@fread{{.*}} #2
|
2018-05-24 14:09:28 +08:00
|
|
|
|
2018-05-31 05:11:45 +08:00
|
|
|
FILE *t26(const char *path, const char *mode) {
|
|
|
|
return fopen(path, mode);
|
|
|
|
}
|
|
|
|
// CHECK-LABEL: t26
|
2019-12-09 19:22:27 +08:00
|
|
|
// CHECK: call{{.*}}@fopen{{.*}} #2
|
2018-05-31 05:11:45 +08:00
|
|
|
|
2019-12-09 19:22:27 +08:00
|
|
|
// GLOBAL: #2 = { nobuiltin "no-builtins" }
|
|
|
|
// 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" }
|