summaryrefslogtreecommitdiff
path: root/lib/profile/InstrProfilingFile.c
diff options
context:
space:
mode:
authorXinliang David Li <davidxl@google.com>2017-08-14 16:51:05 +0000
committerXinliang David Li <davidxl@google.com>2017-08-14 16:51:05 +0000
commit3caa058f838394a73e896a500784a21915f209ef (patch)
tree84e16f5b419acf7c1b93a314b562c3d7ec732561 /lib/profile/InstrProfilingFile.c
parent83db677110a0953642661a2e526521e30c358c53 (diff)
[PGO] Add support for relocate profile dumping directory
Differential Revsion: http://reviews.llvm.org/D36648 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@310857 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/profile/InstrProfilingFile.c')
-rw-r--r--lib/profile/InstrProfilingFile.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/lib/profile/InstrProfilingFile.c b/lib/profile/InstrProfilingFile.c
index d038bb9cb..ddfa39225 100644
--- a/lib/profile/InstrProfilingFile.c
+++ b/lib/profile/InstrProfilingFile.c
@@ -513,23 +513,29 @@ const char *__llvm_profile_get_path_prefix(void) {
COMPILER_RT_VISIBILITY
void __llvm_profile_initialize_file(void) {
const char *EnvFilenamePat;
- const char *SelectedPat = NULL;
- ProfileNameSpecifier PNS = PNS_unknown;
int hasCommandLineOverrider = (INSTR_PROF_PROFILE_NAME_VAR[0] != 0);
EnvFilenamePat = getFilenamePatFromEnv();
- if (EnvFilenamePat) {
- SelectedPat = EnvFilenamePat;
- PNS = PNS_environment;
- } else if (hasCommandLineOverrider) {
- SelectedPat = INSTR_PROF_PROFILE_NAME_VAR;
- PNS = PNS_command_line;
+ if (EnvFilenamePat)
+ parseAndSetFilename(EnvFilenamePat, PNS_environment, 0);
+ else if (hasCommandLineOverrider) {
+ const char *SelectedPat = INSTR_PROF_PROFILE_NAME_VAR;
+
+ size_t PrefixLen;
+ int StripLen;
+ const char *Prefix = lprofGetPathPrefix(&StripLen, &PrefixLen);
+ if (Prefix != NULL) {
+ char *StripPat =
+ COMPILER_RT_ALLOCA(PrefixLen + 1 + strlen(SelectedPat) + 1);
+ lprofApplyPathPrefix(StripPat, SelectedPat, Prefix, PrefixLen, StripLen);
+ SelectedPat = StripPat;
+ }
+
+ parseAndSetFilename(SelectedPat, PNS_command_line, Prefix ? 1 : 0);
} else {
- SelectedPat = NULL;
- PNS = PNS_default;
+ parseAndSetFilename(NULL, PNS_default, 0);
}
- parseAndSetFilename(SelectedPat, PNS, 0);
}
/* This API is directly called by the user application code. It has the