diff options
author | Renato Golin <renato.golin@linaro.org> | 2016-05-07 20:07:09 +0000 |
---|---|---|
committer | Renato Golin <renato.golin@linaro.org> | 2016-05-07 20:07:09 +0000 |
commit | f97746032152365913ac99ae6d8dbe98990830cf (patch) | |
tree | 8a146b02b42142dd7bd5884fe5c3ce42c5d03314 /lib/profile/InstrProfilingValue.c | |
parent | 2c920abc2fc34be7f400179ebc284ec2832f77b0 (diff) |
Revert "[profile] Simplify value profile writing"
This reverts commit r268840, as it breaks Thumb2 self-hosting. There is something
unstable in the profiling for Thumb2 that needs to be sorted out before we continue
implementing these changes to the profiler. See PR27667.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@268864 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/profile/InstrProfilingValue.c')
-rw-r--r-- | lib/profile/InstrProfilingValue.c | 56 |
1 files changed, 43 insertions, 13 deletions
diff --git a/lib/profile/InstrProfilingValue.c b/lib/profile/InstrProfilingValue.c index 3fe913e9d..4b4c82e80 100644 --- a/lib/profile/InstrProfilingValue.c +++ b/lib/profile/InstrProfilingValue.c @@ -21,6 +21,7 @@ #define PROF_OOM_RETURN(Msg) \ { \ PROF_OOM(Msg) \ + free(ValueDataArray); \ return NULL; \ } @@ -117,22 +118,51 @@ __llvm_profile_instrument_target(uint64_t TargetValue, void *Data, } } -COMPILER_RT_VISIBILITY struct ValueProfData * -lprofGatherValueProfData(const __llvm_profile_data *Data) { - ValueProfData *VD = NULL; - ValueProfRuntimeRecord R; - if (initializeValueProfRuntimeRecord(&R, Data->NumValueSites, Data->Values)) +COMPILER_RT_VISIBILITY ValueProfData ** +__llvm_profile_gather_value_data(uint64_t *ValueDataSize) { + size_t S = 0; + __llvm_profile_data *I; + ValueProfData **ValueDataArray; + + const __llvm_profile_data *DataEnd = __llvm_profile_end_data(); + const __llvm_profile_data *DataBegin = __llvm_profile_begin_data(); + + if (!ValueDataSize) + return NULL; + + ValueDataArray = (ValueProfData **)calloc( + __llvm_profile_get_data_size(DataBegin, DataEnd), sizeof(void *)); + if (!ValueDataArray) PROF_OOM_RETURN("Failed to write value profile data "); - /* Compute the size of ValueProfData from this runtime record. */ - if (getNumValueKindsRT(&R) != 0) { - uint32_t VS = getValueProfDataSizeRT(&R); - VD = (ValueProfData *)calloc(VS, sizeof(uint8_t)); - if (!VD) + /* + * Compute the total Size of the buffer to hold ValueProfData + * structures for functions with value profile data. + */ + for (I = (__llvm_profile_data *)DataBegin; I < DataEnd; ++I) { + ValueProfRuntimeRecord R; + if (initializeValueProfRuntimeRecord(&R, I->NumValueSites, I->Values)) PROF_OOM_RETURN("Failed to write value profile data "); - serializeValueProfDataFromRT(&R, VD); + + /* Compute the size of ValueProfData from this runtime record. */ + if (getNumValueKindsRT(&R) != 0) { + ValueProfData *VD = NULL; + uint32_t VS = getValueProfDataSizeRT(&R); + VD = (ValueProfData *)calloc(VS, sizeof(uint8_t)); + if (!VD) + PROF_OOM_RETURN("Failed to write value profile data "); + serializeValueProfDataFromRT(&R, VD); + ValueDataArray[I - DataBegin] = VD; + S += VS; + } + finalizeValueProfRuntimeRecord(&R); + } + + if (!S) { + free(ValueDataArray); + ValueDataArray = NULL; } - finalizeValueProfRuntimeRecord(&R); - return VD; + *ValueDataSize = S; + return ValueDataArray; } |