From 01c26f865212b6dad85afe66ceb19ea93817c416 Mon Sep 17 00:00:00 2001 From: Diego Novillo Date: Thu, 9 Jul 2015 17:21:52 +0000 Subject: 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 --- lib/profile/GCDAProfiling.c | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) (limited to 'lib/profile/GCDAProfiling.c') 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 #include #include @@ -27,17 +29,9 @@ #include #include #include -#ifdef _WIN32 -#include -#endif #define I386_FREEBSD (defined(__FreeBSD__) && defined(__i386__)) -#if !I386_FREEBSD -#include -#include -#endif - #if !defined(_MSC_VER) && !I386_FREEBSD #include #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. */ -- cgit v1.2.1