r333156 - Add Builtins.def support for fread and fwrite to ensure that -fno-builtin-
Eric Christopher via cfe-commits
cfe-commits at lists.llvm.org
Wed May 23 23:09:28 PDT 2018
Author: echristo
Date: Wed May 23 23:09:28 2018
New Revision: 333156
URL: http://llvm.org/viewvc/llvm-project?rev=333156&view=rev
Log:
Add Builtins.def support for fread and fwrite to ensure that -fno-builtin-
works with them and test accordingly.
Modified:
cfe/trunk/include/clang/Basic/Builtins.def
cfe/trunk/test/CodeGen/libcalls-fno-builtin.c
Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=333156&r1=333155&r2=333156&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Wed May 23 23:09:28 2018
@@ -847,6 +847,7 @@ LIBBUILTIN(memset, "v*v*iz", "f",
LIBBUILTIN(strerror, "c*i", "f", "string.h", ALL_LANGUAGES)
LIBBUILTIN(strlen, "zcC*", "f", "string.h", ALL_LANGUAGES)
// C99 stdio.h
+// FIXME: This list is incomplete.
LIBBUILTIN(printf, "icC*.", "fp:0:", "stdio.h", ALL_LANGUAGES)
LIBBUILTIN(fprintf, "iP*cC*.", "fp:1:", "stdio.h", ALL_LANGUAGES)
LIBBUILTIN(snprintf, "ic*zcC*.", "fp:2:", "stdio.h", ALL_LANGUAGES)
@@ -861,6 +862,9 @@ LIBBUILTIN(sscanf, "icC*RcC*R.", "fs:1:
LIBBUILTIN(vscanf, "icC*Ra", "fS:0:", "stdio.h", ALL_LANGUAGES)
LIBBUILTIN(vfscanf, "iP*RcC*Ra", "fS:1:", "stdio.h", ALL_LANGUAGES)
LIBBUILTIN(vsscanf, "icC*RcC*Ra", "fS:1:", "stdio.h", ALL_LANGUAGES)
+LIBBUILTIN(fread, "zv*zzP*", "f", "stdio.h", ALL_LANGUAGES)
+LIBBUILTIN(fwrite, "zvC*zzP*", "f", "stdio.h", ALL_LANGUAGES)
+
// C99 ctype.h
LIBBUILTIN(isalnum, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
LIBBUILTIN(isalpha, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
Modified: cfe/trunk/test/CodeGen/libcalls-fno-builtin.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/libcalls-fno-builtin.c?rev=333156&r1=333155&r2=333156&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/libcalls-fno-builtin.c (original)
+++ cfe/trunk/test/CodeGen/libcalls-fno-builtin.c Wed May 23 23:09:28 2018
@@ -5,12 +5,14 @@
// 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 \
-// RUN: -fno-builtin-strtoull -o - %s | FileCheck %s
+// RUN: -fno-builtin-strtoull -fno-builtin-fread -fno-builtin-fwrite -o - %s | FileCheck %s
// 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
+
// rdar://10551066
typedef __SIZE_TYPE__ size_t;
+typedef struct FILE FILE;
double ceil(double x);
double copysign(double,double);
@@ -36,6 +38,9 @@ long int strtol(const char *nptr, char *
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);
+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);
double t1(double x) { return ceil(x); }
// CHECK-LABEL: t1
@@ -139,4 +144,12 @@ long int t24(char **x) { return strtoull
// CHECK-LABEL: t24
// CHECK: call{{.*}}@strtoull{{.*}} [[ATTR]]
+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
+// CHECK: call{{.*}}@fwrite{{.*}} [[ATTR]]
+// CHECK: call{{.*}}@fread{{.*}} [[ATTR]]
+
// CHECK: [[ATTR]] = { nobuiltin }
More information about the cfe-commits
mailing list