From: Xinliang David Li Date: Sun, 29 Nov 2015 04:52:34 +0000 (+0000) Subject: Minor code cleanups X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=commitdiff_plain;h=672212ce1a10672e6decadd82f7ea9713cff29a3 Minor code cleanups - Add const keyword - fix code comments - move forward decl to the common file git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254244 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/ProfileData/InstrProf.h b/include/llvm/ProfileData/InstrProf.h index 9b0a99a7ef1..13f6c70b3e8 100644 --- a/include/llvm/ProfileData/InstrProf.h +++ b/include/llvm/ProfileData/InstrProf.h @@ -458,7 +458,7 @@ inline support::endianness getHostEndianness() { * return 1. */ int initializeValueProfRuntimeRecord(ValueProfRuntimeRecord *RuntimeRecord, - uint16_t *NumValueSites, + const uint16_t *NumValueSites, ValueProfNode **Nodes); /* Release memory allocated for the runtime record. */ diff --git a/include/llvm/ProfileData/InstrProfData.inc b/include/llvm/ProfileData/InstrProfData.inc index 656ceae34a2..8ff7003a0b2 100644 --- a/include/llvm/ProfileData/InstrProfData.inc +++ b/include/llvm/ProfileData/InstrProfData.inc @@ -296,14 +296,14 @@ typedef struct ValueProfData { /* * The closure is designed to abstact away two types of value profile data: - * - InstrProfRecord which is the primary data structure used to - * represent profile data in host tools (reader, writer, and profile-use) + * - InstrProfRecord which is the primary data structure used to + * represent profile data in host tools (reader, writer, and profile-use) * - value profile runtime data structure suitable to be used by C - * runtime library. + * runtime library. * * Both sources of data need to serialize to disk/memory-buffer in common * format: ValueProfData. The abstraction allows compiler-rt's raw profiler - * writer to share * the same code with indexed profile writer. + * writer to share the same format and code with indexed profile writer. * * For documentation of the member methods below, refer to corresponding methods * in class InstrProfRecord. @@ -337,7 +337,7 @@ typedef struct ValueProfRecordClosure { */ typedef struct ValueProfRuntimeRecord { /* Number of sites for each value profile kind. */ - uint16_t *NumValueSites; + const uint16_t *NumValueSites; /* An array of linked-list headers. The size of of the array is the * total number of value profile sites : sum(NumValueSites[*])). Each * linked-list stores the values profiled for a value profile site. */ @@ -352,6 +352,16 @@ typedef struct ValueProfRuntimeRecord { ValueProfNode **NodesKind[IPVK_Last + 1]; } ValueProfRuntimeRecord; +/* Forward declarations of C interfaces. */ +int initializeValueProfRuntimeRecord(ValueProfRuntimeRecord *RuntimeRecord, + const uint16_t *NumValueSites, + ValueProfNode **Nodes); +void finalizeValueProfRuntimeRecord(ValueProfRuntimeRecord *RuntimeRecord); +uint32_t getValueProfDataSizeRT(const ValueProfRuntimeRecord *Record); +ValueProfData * +serializeValueProfDataFromRT(const ValueProfRuntimeRecord *Record, + ValueProfData *Dst); + #undef INSTR_PROF_VALUE_PROF_DATA #endif /* INSTR_PROF_VALUE_PROF_DATA */ @@ -506,13 +516,15 @@ ValueProfData *serializeValueProfDataFrom(ValueProfRecordClosure *Closure, /* * The value profiler runtime library stores the value profile data - * for a given function in NumValueSites and Nodes. This is the - * method to initialize the RuntimeRecord with the runtime data to - * pre-compute the information needed to efficiently implement - * ValueProfRecordClosure's callback interfaces. + * for a given function in \c NumValueSites and \c Nodes structures. + * \c ValueProfRuntimeRecord class is used to encapsulate the runtime + * profile data and provides fast interfaces to retrieve the profile + * information. This interface is used to initialize the runtime record + * and pre-compute the information needed for efficient implementation + * of callbacks required by ValueProfRecordClosure class. */ int initializeValueProfRuntimeRecord(ValueProfRuntimeRecord *RuntimeRecord, - uint16_t *NumValueSites, + const uint16_t *NumValueSites, ValueProfNode **Nodes) { unsigned I, J, S = 0, NumValueKinds = 0; RuntimeRecord->NumValueSites = NumValueSites;