diff options
author | Bill Wendling <isanbard@gmail.com> | 2013-05-03 00:25:49 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2013-05-03 00:25:49 +0000 |
commit | d83a6d8bafbf2afa3ebcf9e006bf0c7414f9b2dc (patch) | |
tree | 0bd04f2d76770370749cf1fd28807bf61741f83e | |
parent | 2b26c909424953af8fa443d075e27e68c1571be4 (diff) |
Use unbuffered I/O. This reduces the runtime by about half. Our implementation is now only about 5 times slower than gcc's.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@180980 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | SDKs/darwin/usr/include/stdio.h | 1 | ||||
-rw-r--r-- | SDKs/linux/usr/include/stdio.h | 1 | ||||
-rw-r--r-- | lib/profile/GCDAProfiling.c | 3 |
3 files changed, 5 insertions, 0 deletions
diff --git a/SDKs/darwin/usr/include/stdio.h b/SDKs/darwin/usr/include/stdio.h index 63b10a86b..5bbd8a55b 100644 --- a/SDKs/darwin/usr/include/stdio.h +++ b/SDKs/darwin/usr/include/stdio.h @@ -74,6 +74,7 @@ size_t fwrite(const void * __restrict, size_t, size_t, FILE * __restrict) size_t fread(void * __restrict, size_t, size_t, FILE * __restrict); long ftell(FILE *); int fseek(FILE *, long, int); +void setbuf(FILE * __restrict, char * __restrict); int snprintf(char * __restrict, size_t, const char * __restrict, ...); diff --git a/SDKs/linux/usr/include/stdio.h b/SDKs/linux/usr/include/stdio.h index 7c258d2ac..0ca10fabe 100644 --- a/SDKs/linux/usr/include/stdio.h +++ b/SDKs/linux/usr/include/stdio.h @@ -38,5 +38,6 @@ extern size_t fwrite(const void * restrict, size_t, size_t, FILE * restrict); extern size_t fread(void * restrict, size_t, size_t, FILE * restrict); extern long ftell(FILE *); extern int fseek(FILE *, long, int); +extern void setbuf(FILE * restrict, char * restrict); #endif /* __STDIO_H__ */ diff --git a/lib/profile/GCDAProfiling.c b/lib/profile/GCDAProfiling.c index 653f641f7..3e0fff25f 100644 --- a/lib/profile/GCDAProfiling.c +++ b/lib/profile/GCDAProfiling.c @@ -194,6 +194,9 @@ void llvm_gcda_start_file(const char *orig_filename, const char version[4]) { } } + /* Make the file I/O unbuffered. */ + setbuf(output_file, (char*)NULL); + /* gcda file, version, stamp LLVM. */ fwrite("adcg", 4, 1, output_file); fwrite(version, 4, 1, output_file); |