[PGO] Make header portable for C /NFC

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@258889 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Xinliang David Li 2016-01-27 00:13:39 +00:00
parent da5ebe55d9
commit 5b78a6e259

View File

@ -392,8 +392,10 @@ uint32_t getNumValueKindsRT(const void *R);
#define INSTR_PROF_DATA_DEFINED
#ifdef __cplusplus
#define INSTR_PROF_INLINE inline
#define INSTR_PROF_NULLPTR nullptr
#else
#define INSTR_PROF_INLINE
#define INSTR_PROF_NULLPTR NULL
#endif
#ifndef offsetof
@ -554,18 +556,19 @@ int initializeValueProfRuntimeRecord(ValueProfRuntimeRecord *RuntimeRecord,
for (I = 0; I <= IPVK_Last; I++) {
uint16_t N = NumValueSites[I];
if (!N) {
RuntimeRecord->SiteCountArray[I] = nullptr;
RuntimeRecord->SiteCountArray[I] = INSTR_PROF_NULLPTR;
continue;
}
NumValueKinds++;
RuntimeRecord->SiteCountArray[I] = (uint8_t *)calloc(N, 1);
if (!RuntimeRecord->SiteCountArray[I])
return 1;
RuntimeRecord->NodesKind[I] = Nodes ? &Nodes[S] : nullptr;
RuntimeRecord->NodesKind[I] = Nodes ? &Nodes[S] : INSTR_PROF_NULLPTR;
for (J = 0; J < N; J++) {
/* Compute value count for each site. */
uint32_t C = 0;
ValueProfNode *Site = Nodes ? RuntimeRecord->NodesKind[I][J] : nullptr;
ValueProfNode *Site =
Nodes ? RuntimeRecord->NodesKind[I][J] : INSTR_PROF_NULLPTR;
while (Site) {
C++;
Site = Site->Next;
@ -606,7 +609,7 @@ uint32_t getNumValueDataForSiteRT(const void *R, uint32_t VK, uint32_t S) {
uint32_t getNumValueDataRT(const void *R, uint32_t VK) {
unsigned I, S = 0;
const ValueProfRuntimeRecord *Record = (const ValueProfRuntimeRecord *)R;
if (Record->SiteCountArray[VK] == nullptr)
if (Record->SiteCountArray[VK] == INSTR_PROF_NULLPTR)
return 0;
for (I = 0; I < Record->NumValueSites[VK]; I++)
S += Record->SiteCountArray[VK][I];
@ -631,14 +634,10 @@ ValueProfData *allocValueProfDataRT(size_t TotalSizeInBytes) {
return (ValueProfData *)calloc(TotalSizeInBytes, 1);
}
static ValueProfRecordClosure RTRecordClosure = {nullptr,
getNumValueKindsRT,
getNumValueSitesRT,
getNumValueDataRT,
getNumValueDataForSiteRT,
nullptr,
getValueForSiteRT,
allocValueProfDataRT};
static ValueProfRecordClosure RTRecordClosure = {
INSTR_PROF_NULLPTR, getNumValueKindsRT, getNumValueSitesRT,
getNumValueDataRT, getNumValueDataForSiteRT, INSTR_PROF_NULLPTR,
getValueForSiteRT, allocValueProfDataRT};
/*
* Return the size of ValueProfData structure to store data