diff options
author | Diego Novillo <dnovillo@google.com> | 2015-07-09 17:21:52 +0000 |
---|---|---|
committer | Diego Novillo <dnovillo@google.com> | 2015-07-09 17:21:52 +0000 |
commit | eae951415e1a3051666cc812838e3be2394340a0 (patch) | |
tree | 4f66a26a90d167d1fe5a590311f4082baed61fbf /compiler-rt/lib/profile/InstrProfilingUtil.c | |
parent | 216ed03ebb1c8434062687dd990cd4b487257fce (diff) | |
download | bcm5719-llvm-eae951415e1a3051666cc812838e3be2394340a0.tar.gz bcm5719-llvm-eae951415e1a3051666cc812838e3be2394340a0.zip |
Add support for generating profiles in a given directory.
When the file is initialized, this patch checks whether the path
specifies a directory. If so, it creates the directory tree before
truncating the file.
Use default.profdata instead of pgo-data for default indexed profile name.
llvm-svn: 241824
Diffstat (limited to 'compiler-rt/lib/profile/InstrProfilingUtil.c')
-rw-r--r-- | compiler-rt/lib/profile/InstrProfilingUtil.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/compiler-rt/lib/profile/InstrProfilingUtil.c b/compiler-rt/lib/profile/InstrProfilingUtil.c new file mode 100644 index 00000000000..e146dfca83c --- /dev/null +++ b/compiler-rt/lib/profile/InstrProfilingUtil.c @@ -0,0 +1,35 @@ +/*===- InstrProfilingUtil.c - Support library for PGO instrumentation -----===*\ +|* +|* The LLVM Compiler Infrastructure +|* +|* This file is distributed under the University of Illinois Open Source +|* License. See LICENSE.TXT for details. +|* +\*===----------------------------------------------------------------------===*/ + +#include "InstrProfilingUtil.h" + +#ifdef _WIN32 +#include <direct.h> +#elif I386_FREEBSD +int mkdir(const char*, unsigned short); +#else +#include <sys/stat.h> +#include <sys/types.h> +#endif + +__attribute__((visibility("hidden"))) +void __llvm_profile_recursive_mkdir(char *path) { + int i; + + for (i = 1; path[i] != '\0'; ++i) { + if (path[i] != '/') continue; + path[i] = '\0'; +#ifdef _WIN32 + _mkdir(path); +#else + mkdir(path, 0755); /* Some of these will fail, ignore it. */ +#endif + path[i] = '/'; + } +} |