/* Write profile data to file \c OutputName. */ static int writeFile(const char *OutputName) { int RetVal; FILE *OutputFile; if (!doMerging()) OutputFile = fopen(OutputName, "ab"); else OutputFile = openFileForMerging(OutputName); if (!OutputFile) return -1; FreeHook = &free; setupIOBuffer(); RetVal = lprofWriteData(fileWriter, OutputFile, lprofGetVPDataReader()); fclose(OutputFile); return RetVal; }
static int dump(void) { if (lprofProfileDumped()) { lprofWrite("Profile data not published: already written.\n"); return 0; } /* Check if there is llvm/runtime version mismatch. */ if (GET_VERSION(__llvm_profile_get_version()) != INSTR_PROF_RAW_VERSION) { lprofWrite("Runtime and instrumentation version mismatch : " "expected %d, but got %d\n", INSTR_PROF_RAW_VERSION, (int)GET_VERSION(__llvm_profile_get_version())); return -1; } /* Write the profile data into the mapped region. */ ProfDataWriter VMOWriter; initVMOWriter(&VMOWriter); if (lprofWriteData(&VMOWriter, lprofGetVPDataReader(), 0) != 0) return -1; return 0; }
static int writeFile(FILE *File) { FreeHook = &free; setupIOBuffer(); return lprofWriteData(fileWriter, File, lprofGetVPDataReader()); }