[PGO] Add return code for vp rt record init routine to indicate error condition

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254220 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Xinliang David Li 2015-11-28 05:47:34 +00:00
parent 9bee4a8249
commit feed6dbc9f
2 changed files with 13 additions and 7 deletions

View File

@ -583,10 +583,13 @@ typedef struct ValueProfRuntimeRecord {
ValueProfNode **NodesKind[IPVK_Last + 1];
} ValueProfRuntimeRecord;
/* Initialize the record for runtime value profile data. */
void initializeValueProfRuntimeRecord(ValueProfRuntimeRecord *RuntimeRecord,
uint16_t *NumValueSites,
ValueProfNode **Nodes);
/* Initialize the record for runtime value profile data.
* Return 0 if the initialization is successful, otherwise
* return 1.
*/
int initializeValueProfRuntimeRecord(ValueProfRuntimeRecord *RuntimeRecord,
uint16_t *NumValueSites,
ValueProfNode **Nodes);
/* Release memory allocated for the runtime record. */
void finalizeValueProfRuntimeRecord(ValueProfRuntimeRecord *RuntimeRecord);

View File

@ -271,9 +271,9 @@ ValueProfData::serializeFrom(const InstrProfRecord &Record) {
* pre-compute the information needed to efficiently implement
* ValueProfRecordClosure's callback interfaces.
*/
void initializeValueProfRuntimeRecord(ValueProfRuntimeRecord *RuntimeRecord,
uint16_t *NumValueSites,
ValueProfNode **Nodes) {
int initializeValueProfRuntimeRecord(ValueProfRuntimeRecord *RuntimeRecord,
uint16_t *NumValueSites,
ValueProfNode **Nodes) {
unsigned I, J, S = 0, NumValueKinds = 0;
RuntimeRecord->NumValueSites = NumValueSites;
RuntimeRecord->Nodes = Nodes;
@ -286,6 +286,8 @@ void initializeValueProfRuntimeRecord(ValueProfRuntimeRecord *RuntimeRecord,
NumValueKinds++;
RuntimeRecord->SiteCountArray[I] = (uint8_t *)calloc(N, 1);
RuntimeRecord->NodesKind[I] = &RuntimeRecord->Nodes[S];
if (!RuntimeRecord->NodesKind[I])
return 1;
for (J = 0; J < N; J++) {
uint8_t C = 0;
ValueProfNode *Site = RuntimeRecord->Nodes[S + J];
@ -300,6 +302,7 @@ void initializeValueProfRuntimeRecord(ValueProfRuntimeRecord *RuntimeRecord,
S += N;
}
RuntimeRecord->NumValueKinds = NumValueKinds;
return 0;
}
void finalizeValueProfRuntimeRecord(ValueProfRuntimeRecord *RuntimeRecord) {