forked from OSchip/llvm-project
[PGO] internal API name cleanups (for better consistency)
llvm-svn: 262788
This commit is contained in:
parent
32effa1974
commit
cf1a8d6912
|
@ -46,14 +46,14 @@ uint64_t __llvm_profile_get_size_for_buffer_internal(
|
|||
}
|
||||
|
||||
COMPILER_RT_VISIBILITY int __llvm_profile_write_buffer(char *Buffer) {
|
||||
return llvmWriteProfData(llvmBufferWriter, Buffer, 0, 0);
|
||||
return lprofWriteData(lprofBufferWriter, Buffer, 0, 0);
|
||||
}
|
||||
|
||||
COMPILER_RT_VISIBILITY int __llvm_profile_write_buffer_internal(
|
||||
char *Buffer, const __llvm_profile_data *DataBegin,
|
||||
const __llvm_profile_data *DataEnd, const uint64_t *CountersBegin,
|
||||
const uint64_t *CountersEnd, const char *NamesBegin, const char *NamesEnd) {
|
||||
return llvmWriteProfDataImpl(llvmBufferWriter, Buffer, DataBegin, DataEnd,
|
||||
CountersBegin, CountersEnd, 0, 0, NamesBegin,
|
||||
NamesEnd);
|
||||
return lprofWriteDataImpl(lprofBufferWriter, Buffer, DataBegin, DataEnd,
|
||||
CountersBegin, CountersEnd, 0, 0, NamesBegin,
|
||||
NamesEnd);
|
||||
}
|
||||
|
|
|
@ -21,12 +21,12 @@
|
|||
#define UNCONST(ptr) ((void *)(uintptr_t)(ptr))
|
||||
|
||||
#ifdef COMPILER_RT_HAS_UNAME
|
||||
int GetHostName(char *Name, int Len) {
|
||||
struct utsname N;
|
||||
int R;
|
||||
if (!(R = uname(&N)))
|
||||
strncpy(Name, N.nodename, Len);
|
||||
return R;
|
||||
int lprofGetHostName(char *Name, int Len) {
|
||||
struct utsname N;
|
||||
int R;
|
||||
if (!(R = uname(&N)))
|
||||
strncpy(Name, N.nodename, Len);
|
||||
return R;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -44,10 +44,10 @@ static uint32_t fileWriter(ProfDataIOVec *IOVecs, uint32_t NumIOVecs,
|
|||
}
|
||||
|
||||
COMPILER_RT_VISIBILITY ProfBufferIO *
|
||||
llvmCreateBufferIOInternal(void *File, uint32_t BufferSz) {
|
||||
lprofCreateBufferIOInternal(void *File, uint32_t BufferSz) {
|
||||
CallocHook = calloc;
|
||||
FreeHook = free;
|
||||
return llvmCreateBufferIO(fileWriter, File, BufferSz);
|
||||
return lprofCreateBufferIO(fileWriter, File, BufferSz);
|
||||
}
|
||||
|
||||
static int writeFile(FILE *File) {
|
||||
|
@ -60,7 +60,7 @@ static int writeFile(FILE *File) {
|
|||
BufferSzStr = getenv("LLVM_VP_BUFFER_SIZE");
|
||||
if (BufferSzStr && BufferSzStr[0])
|
||||
VPBufferSize = atoi(BufferSzStr);
|
||||
return llvmWriteProfData(fileWriter, File, ValueDataArray, ValueDataSize);
|
||||
return lprofWriteData(fileWriter, File, ValueDataArray, ValueDataSize);
|
||||
}
|
||||
|
||||
static int writeFileWithName(const char *OutputName) {
|
||||
|
|
|
@ -68,51 +68,51 @@ typedef struct ProfBufferIO {
|
|||
} ProfBufferIO;
|
||||
|
||||
/* The creator interface used by testing. */
|
||||
ProfBufferIO *llvmCreateBufferIOInternal(void *File, uint32_t DefaultBufferSz);
|
||||
ProfBufferIO *lprofCreateBufferIOInternal(void *File, uint32_t DefaultBufferSz);
|
||||
/*!
|
||||
* This is the interface to create a handle for buffered IO.
|
||||
*/
|
||||
ProfBufferIO *llvmCreateBufferIO(WriterCallback FileWriter, void *File,
|
||||
uint32_t DefaultBufferSz);
|
||||
ProfBufferIO *lprofCreateBufferIO(WriterCallback FileWriter, void *File,
|
||||
uint32_t DefaultBufferSz);
|
||||
/*!
|
||||
* The interface to destroy the bufferIO handle and reclaim
|
||||
* the memory.
|
||||
*/
|
||||
void llvmDeleteBufferIO(ProfBufferIO *BufferIO);
|
||||
void lprofDeleteBufferIO(ProfBufferIO *BufferIO);
|
||||
|
||||
/*!
|
||||
* This is the interface to write \c Data of \c Size bytes through
|
||||
* \c BufferIO. Returns 0 if successful, otherwise return -1.
|
||||
*/
|
||||
int llvmBufferIOWrite(ProfBufferIO *BufferIO, const uint8_t *Data,
|
||||
uint32_t Size);
|
||||
int lprofBufferIOWrite(ProfBufferIO *BufferIO, const uint8_t *Data,
|
||||
uint32_t Size);
|
||||
/*!
|
||||
* The interface to flush the remaining data in the buffer.
|
||||
* through the low level writer callback.
|
||||
*/
|
||||
int llvmBufferIOFlush(ProfBufferIO *BufferIO);
|
||||
int lprofBufferIOFlush(ProfBufferIO *BufferIO);
|
||||
|
||||
/* The low level interface to write data into a buffer. It is used as the
|
||||
* callback by other high level writer methods such as buffered IO writer
|
||||
* and profile data writer. */
|
||||
uint32_t llvmBufferWriter(ProfDataIOVec *IOVecs, uint32_t NumIOVecs,
|
||||
void **WriterCtx);
|
||||
uint32_t lprofBufferWriter(ProfDataIOVec *IOVecs, uint32_t NumIOVecs,
|
||||
void **WriterCtx);
|
||||
|
||||
int llvmWriteProfData(WriterCallback Writer, void *WriterCtx,
|
||||
struct ValueProfData **ValueDataArray,
|
||||
const uint64_t ValueDataSize);
|
||||
int llvmWriteProfDataImpl(WriterCallback Writer, void *WriterCtx,
|
||||
const __llvm_profile_data *DataBegin,
|
||||
const __llvm_profile_data *DataEnd,
|
||||
const uint64_t *CountersBegin,
|
||||
const uint64_t *CountersEnd,
|
||||
struct ValueProfData **ValueDataBeginArray,
|
||||
const uint64_t ValueDataSize, const char *NamesBegin,
|
||||
const char *NamesEnd);
|
||||
int lprofWriteData(WriterCallback Writer, void *WriterCtx,
|
||||
struct ValueProfData **ValueDataArray,
|
||||
const uint64_t ValueDataSize);
|
||||
int lprofWriteDataImpl(WriterCallback Writer, void *WriterCtx,
|
||||
const __llvm_profile_data *DataBegin,
|
||||
const __llvm_profile_data *DataEnd,
|
||||
const uint64_t *CountersBegin,
|
||||
const uint64_t *CountersEnd,
|
||||
struct ValueProfData **ValueDataBeginArray,
|
||||
const uint64_t ValueDataSize, const char *NamesBegin,
|
||||
const char *NamesEnd);
|
||||
/* Merge value profile data pointed to by SrcValueProfData into
|
||||
* in-memory profile counters pointed by to DstData. */
|
||||
void mergeValueProfData(struct ValueProfData *SrcValueProfData,
|
||||
__llvm_profile_data *DstData);
|
||||
void lprofMergeValueProfData(struct ValueProfData *SrcValueProfData,
|
||||
__llvm_profile_data *DstData);
|
||||
|
||||
extern char *(*GetEnvHook)(const char *);
|
||||
extern void (*FreeHook)(void *);
|
||||
|
|
|
@ -18,12 +18,12 @@
|
|||
#include "InstrProfData.inc"
|
||||
|
||||
void (*VPMergeHook)(ValueProfData *,
|
||||
__llvm_profile_data *) = &mergeValueProfData;
|
||||
__llvm_profile_data *) = &lprofMergeValueProfData;
|
||||
|
||||
/* Merge value profile data pointed to by SrcValueProfData into
|
||||
* in-memory profile counters pointed by to DstData. */
|
||||
void mergeValueProfData(ValueProfData *SrcValueProfData,
|
||||
__llvm_profile_data *DstData) {
|
||||
void lprofMergeValueProfData(ValueProfData *SrcValueProfData,
|
||||
__llvm_profile_data *DstData) {
|
||||
unsigned I, S, V, C;
|
||||
InstrProfValueData *VData;
|
||||
ValueProfRecord *VR = getFirstValueProfRecord(SrcValueProfData);
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#elif defined(__PS4__)
|
||||
#define COMPILER_RT_GETHOSTNAME(Name, Len) (-1)
|
||||
#else
|
||||
#define COMPILER_RT_GETHOSTNAME(Name, Len) GetHostName(Name, Len)
|
||||
#define COMPILER_RT_GETHOSTNAME(Name, Len) lprofGetHostName(Name, Len)
|
||||
#define COMPILER_RT_HAS_UNAME 1
|
||||
#endif
|
||||
|
||||
|
@ -53,7 +53,7 @@
|
|||
#endif
|
||||
#else /* COMPILER_RT_HAS_ATOMICS != 1 */
|
||||
#define COMPILER_RT_BOOL_CMPXCHG(Ptr, OldV, NewV) \
|
||||
BoolCmpXchg((void **)Ptr, OldV, NewV)
|
||||
lprofBoolCmpXchg((void **)Ptr, OldV, NewV)
|
||||
#endif
|
||||
|
||||
#define PROF_ERR(Format, ...) \
|
||||
|
|
|
@ -37,7 +37,7 @@ void __llvm_profile_recursive_mkdir(char *path) {
|
|||
|
||||
#if COMPILER_RT_HAS_ATOMICS != 1
|
||||
COMPILER_RT_VISIBILITY
|
||||
uint32_t BoolCmpXchg(void **Ptr, void *OldV, void *NewV) {
|
||||
uint32_t lprofBoolCmpXchg(void **Ptr, void *OldV, void *NewV) {
|
||||
void *R = *Ptr;
|
||||
if (R == OldV) {
|
||||
*Ptr = NewV;
|
||||
|
|
|
@ -20,9 +20,9 @@ uint32_t VPBufferSize = 0;
|
|||
/* The buffer writer is reponsponsible in keeping writer state
|
||||
* across the call.
|
||||
*/
|
||||
COMPILER_RT_VISIBILITY uint32_t llvmBufferWriter(ProfDataIOVec *IOVecs,
|
||||
uint32_t NumIOVecs,
|
||||
void **WriterCtx) {
|
||||
COMPILER_RT_VISIBILITY uint32_t lprofBufferWriter(ProfDataIOVec *IOVecs,
|
||||
uint32_t NumIOVecs,
|
||||
void **WriterCtx) {
|
||||
uint32_t I;
|
||||
char **Buffer = (char **)WriterCtx;
|
||||
for (I = 0; I < NumIOVecs; I++) {
|
||||
|
@ -43,7 +43,7 @@ static void llvmInitBufferIO(ProfBufferIO *BufferIO, WriterCallback FileWriter,
|
|||
}
|
||||
|
||||
COMPILER_RT_VISIBILITY ProfBufferIO *
|
||||
llvmCreateBufferIO(WriterCallback FileWriter, void *File, uint32_t BufferSz) {
|
||||
lprofCreateBufferIO(WriterCallback FileWriter, void *File, uint32_t BufferSz) {
|
||||
ProfBufferIO *BufferIO = (ProfBufferIO *)CallocHook(1, sizeof(ProfBufferIO));
|
||||
uint8_t *Buffer = (uint8_t *)CallocHook(1, BufferSz);
|
||||
if (!Buffer) {
|
||||
|
@ -54,17 +54,17 @@ llvmCreateBufferIO(WriterCallback FileWriter, void *File, uint32_t BufferSz) {
|
|||
return BufferIO;
|
||||
}
|
||||
|
||||
COMPILER_RT_VISIBILITY void llvmDeleteBufferIO(ProfBufferIO *BufferIO) {
|
||||
COMPILER_RT_VISIBILITY void lprofDeleteBufferIO(ProfBufferIO *BufferIO) {
|
||||
FreeHook(BufferIO->BufferStart);
|
||||
FreeHook(BufferIO);
|
||||
}
|
||||
|
||||
COMPILER_RT_VISIBILITY int
|
||||
llvmBufferIOWrite(ProfBufferIO *BufferIO, const uint8_t *Data, uint32_t Size) {
|
||||
lprofBufferIOWrite(ProfBufferIO *BufferIO, const uint8_t *Data, uint32_t Size) {
|
||||
/* Buffer is not large enough, it is time to flush. */
|
||||
if (Size + BufferIO->CurOffset > BufferIO->BufferSz) {
|
||||
if (llvmBufferIOFlush(BufferIO) != 0)
|
||||
return -1;
|
||||
if (lprofBufferIOFlush(BufferIO) != 0)
|
||||
return -1;
|
||||
}
|
||||
/* Special case, bypass the buffer completely. */
|
||||
ProfDataIOVec IO[] = {{Data, sizeof(uint8_t), Size}};
|
||||
|
@ -74,13 +74,13 @@ llvmBufferIOWrite(ProfBufferIO *BufferIO, const uint8_t *Data, uint32_t Size) {
|
|||
} else {
|
||||
/* Write the data to buffer */
|
||||
uint8_t *Buffer = BufferIO->BufferStart + BufferIO->CurOffset;
|
||||
llvmBufferWriter(IO, 1, (void **)&Buffer);
|
||||
lprofBufferWriter(IO, 1, (void **)&Buffer);
|
||||
BufferIO->CurOffset = Buffer - BufferIO->BufferStart;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
COMPILER_RT_VISIBILITY int llvmBufferIOFlush(ProfBufferIO *BufferIO) {
|
||||
COMPILER_RT_VISIBILITY int lprofBufferIOFlush(ProfBufferIO *BufferIO) {
|
||||
if (BufferIO->CurOffset) {
|
||||
ProfDataIOVec IO[] = {
|
||||
{BufferIO->BufferStart, sizeof(uint8_t), BufferIO->CurOffset}};
|
||||
|
@ -91,10 +91,10 @@ COMPILER_RT_VISIBILITY int llvmBufferIOFlush(ProfBufferIO *BufferIO) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
COMPILER_RT_VISIBILITY int llvmWriteProfData(WriterCallback Writer,
|
||||
void *WriterCtx,
|
||||
ValueProfData **ValueDataArray,
|
||||
const uint64_t ValueDataSize) {
|
||||
COMPILER_RT_VISIBILITY int lprofWriteData(WriterCallback Writer,
|
||||
void *WriterCtx,
|
||||
ValueProfData **ValueDataArray,
|
||||
const uint64_t ValueDataSize) {
|
||||
/* Match logic in __llvm_profile_write_buffer(). */
|
||||
const __llvm_profile_data *DataBegin = __llvm_profile_begin_data();
|
||||
const __llvm_profile_data *DataEnd = __llvm_profile_end_data();
|
||||
|
@ -102,9 +102,9 @@ COMPILER_RT_VISIBILITY int llvmWriteProfData(WriterCallback Writer,
|
|||
const uint64_t *CountersEnd = __llvm_profile_end_counters();
|
||||
const char *NamesBegin = __llvm_profile_begin_names();
|
||||
const char *NamesEnd = __llvm_profile_end_names();
|
||||
return llvmWriteProfDataImpl(Writer, WriterCtx, DataBegin, DataEnd,
|
||||
CountersBegin, CountersEnd, ValueDataArray,
|
||||
ValueDataSize, NamesBegin, NamesEnd);
|
||||
return lprofWriteDataImpl(Writer, WriterCtx, DataBegin, DataEnd,
|
||||
CountersBegin, CountersEnd, ValueDataArray,
|
||||
ValueDataSize, NamesBegin, NamesEnd);
|
||||
}
|
||||
|
||||
#define VP_BUFFER_SIZE 8 * 1024
|
||||
|
@ -118,30 +118,31 @@ static int writeValueProfData(WriterCallback Writer, void *WriterCtx,
|
|||
return 0;
|
||||
|
||||
BufferSz = VPBufferSize ? VPBufferSize : VP_BUFFER_SIZE;
|
||||
BufferIO = llvmCreateBufferIO(Writer, WriterCtx, BufferSz);
|
||||
BufferIO = lprofCreateBufferIO(Writer, WriterCtx, BufferSz);
|
||||
|
||||
for (I = 0; I < NumVData; I++) {
|
||||
ValueProfData *CurVData = ValueDataBegin[I];
|
||||
if (!CurVData)
|
||||
continue;
|
||||
if (llvmBufferIOWrite(BufferIO, (const uint8_t *)CurVData,
|
||||
CurVData->TotalSize) != 0)
|
||||
if (lprofBufferIOWrite(BufferIO, (const uint8_t *)CurVData,
|
||||
CurVData->TotalSize) != 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (llvmBufferIOFlush(BufferIO) != 0)
|
||||
if (lprofBufferIOFlush(BufferIO) != 0)
|
||||
return -1;
|
||||
llvmDeleteBufferIO(BufferIO);
|
||||
lprofDeleteBufferIO(BufferIO);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
COMPILER_RT_VISIBILITY int llvmWriteProfDataImpl(
|
||||
WriterCallback Writer, void *WriterCtx,
|
||||
const __llvm_profile_data *DataBegin, const __llvm_profile_data *DataEnd,
|
||||
const uint64_t *CountersBegin, const uint64_t *CountersEnd,
|
||||
ValueProfData **ValueDataBegin, const uint64_t ValueDataSize,
|
||||
const char *NamesBegin, const char *NamesEnd) {
|
||||
COMPILER_RT_VISIBILITY int
|
||||
lprofWriteDataImpl(WriterCallback Writer, void *WriterCtx,
|
||||
const __llvm_profile_data *DataBegin,
|
||||
const __llvm_profile_data *DataEnd,
|
||||
const uint64_t *CountersBegin, const uint64_t *CountersEnd,
|
||||
ValueProfData **ValueDataBegin, const uint64_t ValueDataSize,
|
||||
const char *NamesBegin, const char *NamesEnd) {
|
||||
|
||||
/* Calculate size of sections. */
|
||||
const uint64_t DataSize = __llvm_profile_get_data_size(DataBegin, DataEnd);
|
||||
|
|
|
@ -16,9 +16,9 @@ void __llvm_profile_merge_from_buffer(const char *, uint64_t);
|
|||
void __llvm_profile_set_filename(const char *);
|
||||
struct __llvm_profile_data;
|
||||
struct ValueProfData;
|
||||
void mergeValueProfData(struct ValueProfData *, struct __llvm_profile_data *);
|
||||
void lprofMergeValueProfData(struct ValueProfData *, struct __llvm_profile_data *);
|
||||
/* Force the vp merger module to be linked in. */
|
||||
void *Dummy = &mergeValueProfData;
|
||||
void *Dummy = &lprofMergeValueProfData;
|
||||
|
||||
void callee1() {}
|
||||
void callee2() {}
|
||||
|
|
|
@ -12,10 +12,10 @@
|
|||
|
||||
typedef struct ProfBufferIO ProfBufferIO;
|
||||
ProfBufferIO *llvmCreateBufferIOInternal(FILE *File, uint32_t DefaultBufferSz);
|
||||
void llvmDeleteBufferIO(ProfBufferIO *BufferIO);
|
||||
void lprofDeleteBufferIO(ProfBufferIO *BufferIO);
|
||||
|
||||
int llvmBufferIOWrite(ProfBufferIO *BufferIO, const char *Data, uint32_t Size);
|
||||
int llvmBufferIOFlush(ProfBufferIO *BufferIO);
|
||||
int lprofBufferIOWrite(ProfBufferIO *BufferIO, const char *Data, uint32_t Size);
|
||||
int lprofBufferIOFlush(ProfBufferIO *BufferIO);
|
||||
|
||||
int __llvm_profile_runtime = 0;
|
||||
|
||||
|
@ -42,34 +42,34 @@ int main(int argc, const char *argv[]) {
|
|||
if (!File[J])
|
||||
return 1;
|
||||
|
||||
BufferIO = llvmCreateBufferIOInternal(File[J], IOBufferSize[J]);
|
||||
BufferIO = lprofCreateBufferIOInternal(File[J], IOBufferSize[J]);
|
||||
|
||||
llvmBufferIOWrite(BufferIO, "Short Strings:\n", strlen("Short Strings:\n"));
|
||||
lprofBufferIOWrite(BufferIO, "Short Strings:\n", strlen("Short Strings:\n"));
|
||||
for (I = 0; I < 1024; I++) {
|
||||
llvmBufferIOWrite(BufferIO, SmallData, strlen(SmallData));
|
||||
lprofBufferIOWrite(BufferIO, SmallData, strlen(SmallData));
|
||||
}
|
||||
llvmBufferIOWrite(BufferIO, "Long Strings:\n", strlen("Long Strings:\n"));
|
||||
lprofBufferIOWrite(BufferIO, "Long Strings:\n", strlen("Long Strings:\n"));
|
||||
for (I = 0; I < 1024; I++) {
|
||||
llvmBufferIOWrite(BufferIO, MediumData, strlen(MediumData));
|
||||
lprofBufferIOWrite(BufferIO, MediumData, strlen(MediumData));
|
||||
}
|
||||
llvmBufferIOWrite(BufferIO, "Extra Long Strings:\n",
|
||||
lprofBufferIOWrite(BufferIO, "Extra Long Strings:\n",
|
||||
strlen("Extra Long Strings:\n"));
|
||||
for (I = 0; I < 10; I++) {
|
||||
llvmBufferIOWrite(BufferIO, LargeData, strlen(LargeData));
|
||||
lprofBufferIOWrite(BufferIO, LargeData, strlen(LargeData));
|
||||
}
|
||||
llvmBufferIOWrite(BufferIO, "Mixed Strings:\n", strlen("Mixed Strings:\n"));
|
||||
lprofBufferIOWrite(BufferIO, "Mixed Strings:\n", strlen("Mixed Strings:\n"));
|
||||
for (I = 0; I < 1024; I++) {
|
||||
llvmBufferIOWrite(BufferIO, MediumData, strlen(MediumData));
|
||||
llvmBufferIOWrite(BufferIO, SmallData, strlen(SmallData));
|
||||
lprofBufferIOWrite(BufferIO, MediumData, strlen(MediumData));
|
||||
lprofBufferIOWrite(BufferIO, SmallData, strlen(SmallData));
|
||||
}
|
||||
llvmBufferIOWrite(BufferIO, "Endings:\n", strlen("Endings:\n"));
|
||||
llvmBufferIOWrite(BufferIO, "END\n", strlen("END\n"));
|
||||
llvmBufferIOWrite(BufferIO, "ENDEND\n", strlen("ENDEND\n"));
|
||||
llvmBufferIOWrite(BufferIO, "ENDENDEND\n", strlen("ENDENDEND\n"));
|
||||
llvmBufferIOWrite(BufferIO, "ENDENDENDEND\n", strlen("ENDENDENDEND\n"));
|
||||
llvmBufferIOFlush(BufferIO);
|
||||
lprofBufferIOWrite(BufferIO, "Endings:\n", strlen("Endings:\n"));
|
||||
lprofBufferIOWrite(BufferIO, "END\n", strlen("END\n"));
|
||||
lprofBufferIOWrite(BufferIO, "ENDEND\n", strlen("ENDEND\n"));
|
||||
lprofBufferIOWrite(BufferIO, "ENDENDEND\n", strlen("ENDENDEND\n"));
|
||||
lprofBufferIOWrite(BufferIO, "ENDENDENDEND\n", strlen("ENDENDENDEND\n"));
|
||||
lprofBufferIOFlush(BufferIO);
|
||||
|
||||
llvmDeleteBufferIO(BufferIO);
|
||||
lprofDeleteBufferIO(BufferIO);
|
||||
|
||||
fclose(File[J]);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue