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

Xinliang David Li via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 27 21:47:34 PST 2015


Author: davidxl
Date: Fri Nov 27 23:47:34 2015
New Revision: 254220

URL: http://llvm.org/viewvc/llvm-project?rev=254220&view=rev
Log:
[PGO] Add return code for vp rt record init routine to indicate error condition

Modified:
    llvm/trunk/include/llvm/ProfileData/InstrProf.h
    llvm/trunk/lib/ProfileData/InstrProf.cpp

Modified: llvm/trunk/include/llvm/ProfileData/InstrProf.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ProfileData/InstrProf.h?rev=254220&r1=254219&r2=254220&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ProfileData/InstrProf.h (original)
+++ llvm/trunk/include/llvm/ProfileData/InstrProf.h Fri Nov 27 23:47:34 2015
@@ -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);

Modified: llvm/trunk/lib/ProfileData/InstrProf.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ProfileData/InstrProf.cpp?rev=254220&r1=254219&r2=254220&view=diff
==============================================================================
--- llvm/trunk/lib/ProfileData/InstrProf.cpp (original)
+++ llvm/trunk/lib/ProfileData/InstrProf.cpp Fri Nov 27 23:47:34 2015
@@ -271,9 +271,9 @@ ValueProfData::serializeFrom(const Instr
  * 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(Va
     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(Va
     S += N;
   }
   RuntimeRecord->NumValueKinds = NumValueKinds;
+  return 0;
 }
 
 void finalizeValueProfRuntimeRecord(ValueProfRuntimeRecord *RuntimeRecord) {




More information about the llvm-commits mailing list