Skip to content

Commit ae89869

Browse files
committed
[PGO] Make header portable for C /NFC
llvm-svn: 258889
1 parent 07b9cd3 commit ae89869

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

llvm/include/llvm/ProfileData/InstrProfData.inc

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -392,8 +392,10 @@ uint32_t getNumValueKindsRT(const void *R);
392392
#define INSTR_PROF_DATA_DEFINED
393393
#ifdef __cplusplus
394394
#define INSTR_PROF_INLINE inline
395+
#define INSTR_PROF_NULLPTR nullptr
395396
#else
396397
#define INSTR_PROF_INLINE
398+
#define INSTR_PROF_NULLPTR NULL
397399
#endif
398400

399401
#ifndef offsetof
@@ -554,18 +556,19 @@ int initializeValueProfRuntimeRecord(ValueProfRuntimeRecord *RuntimeRecord,
554556
for (I = 0; I <= IPVK_Last; I++) {
555557
uint16_t N = NumValueSites[I];
556558
if (!N) {
557-
RuntimeRecord->SiteCountArray[I] = nullptr;
559+
RuntimeRecord->SiteCountArray[I] = INSTR_PROF_NULLPTR;
558560
continue;
559561
}
560562
NumValueKinds++;
561563
RuntimeRecord->SiteCountArray[I] = (uint8_t *)calloc(N, 1);
562564
if (!RuntimeRecord->SiteCountArray[I])
563565
return 1;
564-
RuntimeRecord->NodesKind[I] = Nodes ? &Nodes[S] : nullptr;
566+
RuntimeRecord->NodesKind[I] = Nodes ? &Nodes[S] : INSTR_PROF_NULLPTR;
565567
for (J = 0; J < N; J++) {
566568
/* Compute value count for each site. */
567569
uint32_t C = 0;
568-
ValueProfNode *Site = Nodes ? RuntimeRecord->NodesKind[I][J] : nullptr;
570+
ValueProfNode *Site =
571+
Nodes ? RuntimeRecord->NodesKind[I][J] : INSTR_PROF_NULLPTR;
569572
while (Site) {
570573
C++;
571574
Site = Site->Next;
@@ -606,7 +609,7 @@ uint32_t getNumValueDataForSiteRT(const void *R, uint32_t VK, uint32_t S) {
606609
uint32_t getNumValueDataRT(const void *R, uint32_t VK) {
607610
unsigned I, S = 0;
608611
const ValueProfRuntimeRecord *Record = (const ValueProfRuntimeRecord *)R;
609-
if (Record->SiteCountArray[VK] == nullptr)
612+
if (Record->SiteCountArray[VK] == INSTR_PROF_NULLPTR)
610613
return 0;
611614
for (I = 0; I < Record->NumValueSites[VK]; I++)
612615
S += Record->SiteCountArray[VK][I];
@@ -631,14 +634,10 @@ ValueProfData *allocValueProfDataRT(size_t TotalSizeInBytes) {
631634
return (ValueProfData *)calloc(TotalSizeInBytes, 1);
632635
}
633636

634-
static ValueProfRecordClosure RTRecordClosure = {nullptr,
635-
getNumValueKindsRT,
636-
getNumValueSitesRT,
637-
getNumValueDataRT,
638-
getNumValueDataForSiteRT,
639-
nullptr,
640-
getValueForSiteRT,
641-
allocValueProfDataRT};
637+
static ValueProfRecordClosure RTRecordClosure = {
638+
INSTR_PROF_NULLPTR, getNumValueKindsRT, getNumValueSitesRT,
639+
getNumValueDataRT, getNumValueDataForSiteRT, INSTR_PROF_NULLPTR,
640+
getValueForSiteRT, allocValueProfDataRT};
642641

643642
/*
644643
* Return the size of ValueProfData structure to store data

0 commit comments

Comments
 (0)