diff options
| author | Xinliang David Li <davidxl@google.com> | 2015-11-23 17:09:40 +0000 | 
|---|---|---|
| committer | Xinliang David Li <davidxl@google.com> | 2015-11-23 17:09:40 +0000 | 
| commit | 0ca5bd4a46701e46191a9c33a9f9227db2352ecf (patch) | |
| tree | 7b52133b107c54722eebfb247bf148162e4ee837 /compiler-rt/lib | |
| parent | 6290fc9154fd6af0069f77bcc6828c461e096f1f (diff) | |
| download | bcm5719-llvm-0ca5bd4a46701e46191a9c33a9f9227db2352ecf.tar.gz bcm5719-llvm-0ca5bd4a46701e46191a9c33a9f9227db2352ecf.zip | |
[PGO] Start use InstrProf template file in compiler-rt/lib/profile
- Replace use of __llvm_profile_value_data with common data structure.
- Remve duplicate InstrProfValueNode
llvm-svn: 253883
Diffstat (limited to 'compiler-rt/lib')
| -rw-r--r-- | compiler-rt/lib/profile/InstrProfiling.c | 29 | ||||
| -rw-r--r-- | compiler-rt/lib/profile/InstrProfiling.h | 7 | 
2 files changed, 14 insertions, 22 deletions
| diff --git a/compiler-rt/lib/profile/InstrProfiling.c b/compiler-rt/lib/profile/InstrProfiling.c index 54103a0d6a0..dede45bc872 100644 --- a/compiler-rt/lib/profile/InstrProfiling.c +++ b/compiler-rt/lib/profile/InstrProfiling.c @@ -12,11 +12,6 @@  #include <stdlib.h>  #include <string.h> -typedef struct ValueProfNode { -  __llvm_profile_value_data VData; -  struct ValueProfNode *Next; -} ValueProfNode; -  LLVM_LIBRARY_VISIBILITY uint64_t __llvm_profile_get_magic(void) {    /* Magic number to detect file format and endianness.     * @@ -70,7 +65,7 @@ LLVM_LIBRARY_VISIBILITY void __llvm_profile_reset_counters(void) {        ValueProfNode *CurrentVNode = ValueCounters[i];        while (CurrentVNode) { -        CurrentVNode->VData.NumTaken = 0; +        CurrentVNode->VData.Count = 0;          CurrentVNode = CurrentVNode->Next;        }      } @@ -121,23 +116,23 @@ LLVM_LIBRARY_VISIBILITY void  __llvm_profile_instrument_target(uint64_t TargetValue, void *Data,                                   uint32_t CounterIndex) { -  __llvm_profile_data *VData = (__llvm_profile_data *)Data; -  if (!VData) +  __llvm_profile_data *PData = (__llvm_profile_data *)Data; +  if (!PData)      return; -  if (!VData->Values) { -    if (!allocateValueProfileCounters(VData)) +  if (!PData->Values) { +    if (!allocateValueProfileCounters(PData))        return;    } -  ValueProfNode **ValueCounters = (ValueProfNode **)VData->Values; +  ValueProfNode **ValueCounters = (ValueProfNode **)PData->Values;    ValueProfNode *PrevVNode = NULL;    ValueProfNode *CurrentVNode = ValueCounters[CounterIndex];    uint8_t VDataCount = 0;    while (CurrentVNode) { -    if (TargetValue == CurrentVNode->VData.TargetValue) { -      CurrentVNode->VData.NumTaken++; +    if (TargetValue == CurrentVNode->VData.Value) { +      CurrentVNode->VData.Count++;        return;      }      PrevVNode = CurrentVNode; @@ -152,8 +147,8 @@ __llvm_profile_instrument_target(uint64_t TargetValue, void *Data,    if (!CurrentVNode)      return; -  CurrentVNode->VData.TargetValue = TargetValue; -  CurrentVNode->VData.NumTaken++; +  CurrentVNode->VData.Value = TargetValue; +  CurrentVNode->VData.Count++;    uint32_t Success = 0;    if (!ValueCounters[CounterIndex]) @@ -201,8 +196,8 @@ __llvm_profile_gather_value_data(uint8_t **VDataArray) {      uint8_t Padding = __llvm_profile_get_num_padding_bytes(NumVSites);      uint8_t *PerSiteCountPtr = PerSiteCountsHead; -    __llvm_profile_value_data *VDataPtr = -        (__llvm_profile_value_data *)(PerSiteCountPtr + NumVSites + Padding); +    InstrProfValueData *VDataPtr = +        (InstrProfValueData *)(PerSiteCountPtr + NumVSites + Padding);      for (i = 0; i < NumVSites; ++i) { diff --git a/compiler-rt/lib/profile/InstrProfiling.h b/compiler-rt/lib/profile/InstrProfiling.h index c8178fce924..579d4fe7254 100644 --- a/compiler-rt/lib/profile/InstrProfiling.h +++ b/compiler-rt/lib/profile/InstrProfiling.h @@ -45,17 +45,14 @@ typedef unsigned long int uintptr_t;  #endif /* defined(__FreeBSD__) && defined(__i386__) */ +#include "InstrProfData.inc" +  enum ValueKind {    IPVK_IndirectCallTarget = 0,    IPVK_First = IPVK_IndirectCallTarget,    IPVK_Last = IPVK_IndirectCallTarget  }; -typedef struct __llvm_profile_value_data { -  uint64_t TargetValue; -  uint64_t NumTaken; -} __llvm_profile_value_data; -  typedef void *IntPtrT;  typedef struct LLVM_ALIGNAS(8) __llvm_profile_data {    const uint32_t NameSize; | 

