diff options
author | dim <dim@FreeBSD.org> | 2012-04-14 13:54:10 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2012-04-14 13:54:10 +0000 |
commit | 1fc08f5e9ef733ef1ce6f363fecedc2260e78974 (patch) | |
tree | 19c69a04768629f2d440944b71cbe90adae0b615 /runtime/libprofile | |
parent | 07637c87f826cdf411f0673595e9bc92ebd793f2 (diff) | |
download | FreeBSD-src-1fc08f5e9ef733ef1ce6f363fecedc2260e78974.zip FreeBSD-src-1fc08f5e9ef733ef1ce6f363fecedc2260e78974.tar.gz |
Vendor import of llvm trunk r154661:
http://llvm.org/svn/llvm-project/llvm/trunk@r154661
Diffstat (limited to 'runtime/libprofile')
-rw-r--r-- | runtime/libprofile/CommonProfiling.c | 4 | ||||
-rw-r--r-- | runtime/libprofile/GCDAProfiling.c | 12 | ||||
-rw-r--r-- | runtime/libprofile/PathProfiling.c | 9 |
3 files changed, 16 insertions, 9 deletions
diff --git a/runtime/libprofile/CommonProfiling.c b/runtime/libprofile/CommonProfiling.c index fbc1ef4..d55f51c 100644 --- a/runtime/libprofile/CommonProfiling.c +++ b/runtime/libprofile/CommonProfiling.c @@ -46,7 +46,7 @@ int save_arguments(int argc, const char **argv) { * what to do with it. */ const char *Arg = argv[1]; - memmove(&argv[1], &argv[2], (argc-1)*sizeof(char*)); + memmove((char**)&argv[1], &argv[2], (argc-1)*sizeof(char*)); --argc; if (!strcmp(Arg, "-llvmprof-output")) { @@ -54,7 +54,7 @@ int save_arguments(int argc, const char **argv) { puts("-llvmprof-output requires a filename argument!"); else { OutputFilename = strdup(argv[1]); - memmove(&argv[1], &argv[2], (argc-1)*sizeof(char*)); + memmove((char**)&argv[1], &argv[2], (argc-1)*sizeof(char*)); --argc; } } else { diff --git a/runtime/libprofile/GCDAProfiling.c b/runtime/libprofile/GCDAProfiling.c index 4ffb12b..3a48bb2 100644 --- a/runtime/libprofile/GCDAProfiling.c +++ b/runtime/libprofile/GCDAProfiling.c @@ -113,6 +113,18 @@ void llvm_gcda_start_file(const char *orig_filename) { recursive_mkdir(filename); output_file = fopen(filename, "wb"); + if (!output_file) { + const char *cptr = strrchr(orig_filename, '/'); + output_file = fopen(cptr ? cptr + 1 : orig_filename, "wb"); + + if (!output_file) { + fprintf(stderr, "LLVM profiling runtime: while opening '%s': ", + cptr ? cptr + 1 : orig_filename); + perror(""); + exit(1); + } + } + /* gcda file, version 404*, stamp LLVM. */ #ifdef __APPLE__ fwrite("adcg*204MVLL", 12, 1, output_file); diff --git a/runtime/libprofile/PathProfiling.c b/runtime/libprofile/PathProfiling.c index 2836785..71ee944 100644 --- a/runtime/libprofile/PathProfiling.c +++ b/runtime/libprofile/PathProfiling.c @@ -26,11 +26,6 @@ #include <stdlib.h> #include <stdio.h> -/* Must use __inline in Microsoft C */ -#if defined(_MSC_VER) -#define inline __inline -#endif - /* note that this is used for functions with large path counts, but it is unlikely those paths will ALL be executed */ #define ARBITRARY_HASH_BIN_COUNT 100 @@ -112,7 +107,7 @@ void writeArrayTable(uint32_t fNumber, ftEntry_t* ft, uint32_t* funcCount) { } } -static inline uint32_t hash (uint32_t key) { +static uint32_t hash (uint32_t key) { /* this may benefit from a proper hash function */ return key%ARBITRARY_HASH_BIN_COUNT; } @@ -155,7 +150,7 @@ void writeHashTable(uint32_t functionNumber, pathHashTable_t* hashTable) { } /* Return a pointer to this path's specific path counter */ -static inline uint32_t* getPathCounter(uint32_t functionNumber, +static uint32_t* getPathCounter(uint32_t functionNumber, uint32_t pathNumber) { pathHashTable_t* hashTable; pathHashEntry_t* hashEntry; |