[PGO]: Refactor VP data writer
Extract the buffered filer writer code used by value profile
writer and turn it into common/sharable buffered fileIO
interfaces. Added a test case for the buffered file writer and
rewrite the VP dumping using the new APIs.
llvm-svn: 256604
diff --git a/compiler-rt/lib/profile/InstrProfilingFile.c b/compiler-rt/lib/profile/InstrProfilingFile.c
index a803ba5..4ea7fbf 100644
--- a/compiler-rt/lib/profile/InstrProfilingFile.c
+++ b/compiler-rt/lib/profile/InstrProfilingFile.c
@@ -30,6 +30,13 @@
return 0;
}
+COMPILER_RT_VISIBILITY ProfBufferIO *
+llvmCreateBufferIOInternal(void *File, uint32_t BufferSz) {
+ CallocHook = calloc;
+ FreeHook = free;
+ return llvmCreateBufferIO(fileWriter, File, BufferSz);
+}
+
static int writeFile(FILE *File) {
const char *BufferSzStr = 0;
uint64_t ValueDataSize = 0;