Index: lib/profile/InstrProfilingFile.c =================================================================== --- lib/profile/InstrProfilingFile.c +++ lib/profile/InstrProfilingFile.c @@ -529,7 +529,9 @@ PNS = PNS_default; } - parseAndSetFilename(SelectedPat, PNS, 0); + /* Pass CopyFilenamePat = 1, to ensure that the filename would be valid at the + * moment when __llvm_profile_write_file() gets executed. */ + parseAndSetFilename(SelectedPat, PNS, 1); } /* This API is directly called by the user application code. It has the