コード例 #1
0
ファイル: InstrProfReader.cpp プロジェクト: bhanug/llvm
std::error_code
RawInstrProfReader<IntPtrT>::readValueProfilingData(InstrProfRecord &Record) {

  Record.clearValueData();
  CurValueDataSize = 0;
  // Need to match the logic in value profile dumper code in compiler-rt:
  uint32_t NumValueKinds = 0;
  for (uint32_t I = 0; I < IPVK_Last + 1; I++)
    NumValueKinds += (Data->NumValueSites[I] != 0);

  if (!NumValueKinds)
    return success();

  ErrorOr<std::unique_ptr<ValueProfData>> VDataPtrOrErr =
      ValueProfData::getValueProfData(ValueDataStart,
                                      (const unsigned char *)ProfileEnd,
                                      getDataEndianness());

  if (VDataPtrOrErr.getError())
    return VDataPtrOrErr.getError();

  VDataPtrOrErr.get()->deserializeTo(Record, &Symtab->getAddrHashMap());
  CurValueDataSize = VDataPtrOrErr.get()->getSize();
  return success();
}
コード例 #2
0
ファイル: InstrProfReader.cpp プロジェクト: AnachroNia/llvm
std::error_code
RawInstrProfReader<IntPtrT>::readValueProfilingData(InstrProfRecord &Record) {

  Record.clearValueData();
  CurValueDataSize = 0;
  // Need to match the logic in value profile dumper code in compiler-rt:
  uint32_t NumValueKinds = 0;
  for (uint32_t I = 0; I < IPVK_Last + 1; I++)
    NumValueKinds += (Data->NumValueSites[I] != 0);

  if (!NumValueKinds)
    return success();

  ErrorOr<std::unique_ptr<ValueProfData>> VDataPtrOrErr =
      ValueProfData::getValueProfData(ValueDataStart,
                                      (const unsigned char *)ProfileEnd,
                                      getDataEndianness());

  if (VDataPtrOrErr.getError())
    return VDataPtrOrErr.getError();

  // Note that besides deserialization, this also performs the conversion for
  // indirect call targets.  The function pointers from the raw profile are
  // remapped into function name hashes.
  VDataPtrOrErr.get()->deserializeTo(Record, &Symtab->getAddrHashMap());
  CurValueDataSize = VDataPtrOrErr.get()->getSize();
  return success();
}
コード例 #3
0
ファイル: InstrProfReader.cpp プロジェクト: 8l/llvm
std::error_code RawInstrProfReader<IntPtrT>::readValueProfilingData(
    InstrProfRecord &Record) {

  Record.clearValueData();
  if (!Data->Values || (ValueDataDelta == 0))
    return success();

  // Read value data.
  uint64_t NumVSites = 0;
  for (uint32_t Kind = IPVK_First; Kind <= ValueKindLast; ++Kind)
    NumVSites += swap(Data->NumValueSites[Kind]);
  NumVSites += getNumPaddingBytes(NumVSites);

  auto VDataCounts = makeArrayRef(getValueDataCounts(Data->Values), NumVSites);
  // Check bounds.
  if (VDataCounts.data() < ValueDataStart ||
      VDataCounts.data() + VDataCounts.size() >
          reinterpret_cast<const uint8_t *>(ProfileEnd))
    return error(instrprof_error::malformed);

  const InstrProfValueData *VDataPtr =
      getValueData(swap(Data->Values) + NumVSites);
  for (uint32_t Kind = IPVK_First; Kind <= ValueKindLast; ++Kind) {
    NumVSites = swap(Data->NumValueSites[Kind]);
    Record.reserveSites(Kind, NumVSites);
    for (uint32_t VSite = 0; VSite < NumVSites; ++VSite) {

      uint32_t VDataCount = VDataCounts[VSite];
      if ((const char *)(VDataPtr + VDataCount) > ProfileEnd)
        return error(instrprof_error::malformed);

      std::vector<InstrProfValueData> CurrentValues;
      CurrentValues.reserve(VDataCount);
      for (uint32_t VIndex = 0; VIndex < VDataCount; ++VIndex) {
        uint64_t TargetValue = swap(VDataPtr->Value);
        uint64_t Count = swap(VDataPtr->Count);
        CurrentValues.push_back({TargetValue, Count});
        ++VDataPtr;
      }
      Record.addValueData(Kind, VSite, CurrentValues.data(),
                          VDataCount, &FunctionPtrToNameMap);
    }
  }
  return success();
}