[compiler-rt] r264665 - [libprofile] Handle '\\' in __llvm_profile_recursive_mkdir
Sean Silva via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 28 14:32:47 PDT 2016
Author: silvas
Date: Mon Mar 28 16:32:46 2016
New Revision: 264665
URL: http://llvm.org/viewvc/llvm-project?rev=264665&view=rev
Log:
[libprofile] Handle '\\' in __llvm_profile_recursive_mkdir
This is implicitly needed at least by gcc-flag-compatibility.test
The thing that needs it is the `\` preceding the "default.profraw"
appended internally by clang when doing `-fprofile-use=`.
Clang uses `\` because is uses sys::path::append which will use `\` on a
Windows host. This is wrong, but I don't think there's an easy way to
solve it (maybe just always using `/` since places that accept `\` also
tend to accept `/`, but not the other way around).
Modified:
compiler-rt/trunk/lib/profile/InstrProfilingFile.c
compiler-rt/trunk/lib/profile/InstrProfilingUtil.c
Modified: compiler-rt/trunk/lib/profile/InstrProfilingFile.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/InstrProfilingFile.c?rev=264665&r1=264664&r2=264665&view=diff
==============================================================================
--- compiler-rt/trunk/lib/profile/InstrProfilingFile.c (original)
+++ compiler-rt/trunk/lib/profile/InstrProfilingFile.c Mon Mar 28 16:32:46 2016
@@ -79,7 +79,7 @@ static void truncateCurrentFile(void) {
return;
/* Create the directory holding the file, if needed. */
- if (strchr(Filename, '/')) {
+ if (strchr(Filename, '/') || strchr(Filename, '\\')) {
char *Copy = malloc(strlen(Filename) + 1);
strcpy(Copy, Filename);
__llvm_profile_recursive_mkdir(Copy);
Modified: compiler-rt/trunk/lib/profile/InstrProfilingUtil.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/InstrProfilingUtil.c?rev=264665&r1=264664&r2=264665&view=diff
==============================================================================
--- compiler-rt/trunk/lib/profile/InstrProfilingUtil.c (original)
+++ compiler-rt/trunk/lib/profile/InstrProfilingUtil.c Mon Mar 28 16:32:46 2016
@@ -28,14 +28,16 @@ void __llvm_profile_recursive_mkdir(char
int i;
for (i = 1; path[i] != '\0'; ++i) {
- if (path[i] != '/') continue;
+ char save = path[i];
+ if (!(path[i] == '/' || path[i] == '\\'))
+ continue;
path[i] = '\0';
#ifdef _WIN32
_mkdir(path);
#else
mkdir(path, 0755); /* Some of these will fail, ignore it. */
#endif
- path[i] = '/';
+ path[i] = save;
}
}
More information about the llvm-commits
mailing list