summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXinliang David Li <davidxl@google.com>2015-11-28 05:47:34 +0000
committerXinliang David Li <davidxl@google.com>2015-11-28 05:47:34 +0000
commit017fffbd2a968de6aed705964ef4190e58782515 (patch)
tree6bea219a983f11441eddb985153b5dfedb973815
parent4cccee52ce21fc8408e24d5318ecf647c1afa47b (diff)
downloadbcm5719-llvm-017fffbd2a968de6aed705964ef4190e58782515.tar.gz
bcm5719-llvm-017fffbd2a968de6aed705964ef4190e58782515.zip
[PGO] Add return code for vp rt record init routine to indicate error condition
llvm-svn: 254220
-rw-r--r--llvm/include/llvm/ProfileData/InstrProf.h11
-rw-r--r--llvm/lib/ProfileData/InstrProf.cpp9
2 files changed, 13 insertions, 7 deletions
diff --git a/llvm/include/llvm/ProfileData/InstrProf.h b/llvm/include/llvm/ProfileData/InstrProf.h
index 8fd3d7f8ffd..b4e2206b00a 100644
--- a/llvm/include/llvm/ProfileData/InstrProf.h
+++ b/llvm/include/llvm/ProfileData/InstrProf.h
@@ -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);
diff --git a/llvm/lib/ProfileData/InstrProf.cpp b/llvm/lib/ProfileData/InstrProf.cpp
index 3bbc8249c3d..28626844812 100644
--- a/llvm/lib/ProfileData/InstrProf.cpp
+++ b/llvm/lib/ProfileData/InstrProf.cpp
@@ -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) {
OpenPOWER on IntegriCloud