summaryrefslogtreecommitdiff
path: root/lib/profile/GCDAProfiling.c
diff options
context:
space:
mode:
authorDiego Novillo <dnovillo@google.com>2015-07-09 17:21:52 +0000
committerDiego Novillo <dnovillo@google.com>2015-07-09 17:21:52 +0000
commit01c26f865212b6dad85afe66ceb19ea93817c416 (patch)
treeef8e0aab9d0ee3f4ce84984bf4ab0f39a9f104dc /lib/profile/GCDAProfiling.c
parent0ea4c414a97f8101a7cf90f90e98a42d50a1b935 (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@241824 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/profile/GCDAProfiling.c')
-rw-r--r--lib/profile/GCDAProfiling.c28
1 files changed, 3 insertions, 25 deletions
diff --git a/lib/profile/GCDAProfiling.c b/lib/profile/GCDAProfiling.c
index e32e97fdb..aec232856 100644
--- a/lib/profile/GCDAProfiling.c
+++ b/lib/profile/GCDAProfiling.c
@@ -20,6 +20,8 @@
|*
\*===----------------------------------------------------------------------===*/
+#include "InstrProfilingUtil.h"
+
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
@@ -27,17 +29,9 @@
#include <string.h>
#include <sys/mman.h>
#include <sys/file.h>
-#ifdef _WIN32
-#include <direct.h>
-#endif
#define I386_FREEBSD (defined(__FreeBSD__) && defined(__i386__))
-#if !I386_FREEBSD
-#include <sys/stat.h>
-#include <sys/types.h>
-#endif
-
#if !defined(_MSC_VER) && !I386_FREEBSD
#include <stdint.h>
#endif
@@ -52,7 +46,6 @@ typedef unsigned long long uint64_t;
typedef unsigned char uint8_t;
typedef unsigned int uint32_t;
typedef unsigned long long uint64_t;
-int mkdir(const char*, unsigned short);
#endif
/* #define DEBUG_GCDAPROFILING */
@@ -209,21 +202,6 @@ static char *mangle_filename(const char *orig_filename) {
return new_filename;
}
-static void 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] = '/';
- }
-}
-
static int map_file() {
fseek(output_file, 0L, SEEK_END);
file_size = ftell(output_file);
@@ -283,7 +261,7 @@ void llvm_gcda_start_file(const char *orig_filename, const char version[4],
fd = open(filename, O_RDWR | O_CREAT, 0644);
if (fd == -1) {
/* Try creating the directories first then opening the file. */
- recursive_mkdir(filename);
+ __llvm_profile_recursive_mkdir(filename);
fd = open(filename, O_RDWR | O_CREAT, 0644);
if (fd == -1) {
/* Bah! It's hopeless. */