summaryrefslogtreecommitdiff
path: root/lib/profile/InstrProfilingFile.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/profile/InstrProfilingFile.c')
-rw-r--r--lib/profile/InstrProfilingFile.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/profile/InstrProfilingFile.c b/lib/profile/InstrProfilingFile.c
index 0102a2533..940223829 100644
--- a/lib/profile/InstrProfilingFile.c
+++ b/lib/profile/InstrProfilingFile.c
@@ -8,6 +8,7 @@
\*===----------------------------------------------------------------------===*/
#include "InstrProfiling.h"
+#include "InstrProfilingUtil.h"
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
@@ -84,6 +85,13 @@ static void truncateCurrentFile(void) {
if (!Filename || !Filename[0])
return;
+ /* Create the directory holding the file, if needed. */
+ if (strchr(Filename, '/')) {
+ char *Copy = malloc(strlen(Filename) + 1);
+ strcpy(Copy, Filename);
+ __llvm_profile_recursive_mkdir(Copy);
+ }
+
/* Truncate the file. Later we'll reopen and append. */
File = fopen(Filename, "w");
if (!File)