Esempio n. 1
0
Error InstrProfWriter::writeText(raw_fd_ostream &OS) {
  if (ProfileKind == PF_IRLevel)
    OS << "# IR level Instrumentation Flag\n:ir\n";
  else if (ProfileKind == PF_IRLevelWithCS)
    OS << "# CSIR level Instrumentation Flag\n:csir\n";
  InstrProfSymtab Symtab;

  using FuncPair = detail::DenseMapPair<uint64_t, InstrProfRecord>;
  using RecordType = std::pair<StringRef, FuncPair>;
  SmallVector<RecordType, 4> OrderedFuncData;

  for (const auto &I : FunctionData) {
    if (shouldEncodeData(I.getValue())) {
      if (Error E = Symtab.addFuncName(I.getKey()))
        return E;
      for (const auto &Func : I.getValue())
        OrderedFuncData.push_back(std::make_pair(I.getKey(), Func));
    }
  }

  llvm::sort(OrderedFuncData, [](const RecordType &A, const RecordType &B) {
    return std::tie(A.first, A.second.first) <
           std::tie(B.first, B.second.first);
  });

  for (const auto &record : OrderedFuncData) {
    const StringRef &Name = record.first;
    const FuncPair &Func = record.second;
    writeRecordInText(Name, Func.first, Func.second, Symtab, OS);
  }

  return Error::success();
}
Esempio n. 2
0
void InstrProfWriter::writeText(raw_fd_ostream &OS) {
  InstrProfSymtab Symtab;
  for (const auto &I : FunctionData)
    Symtab.addFuncName(I.getKey());
  Symtab.finalizeSymtab();

  for (const auto &I : FunctionData)
    for (const auto &Func : I.getValue())
      writeRecordInText(Func.second, Symtab, OS);
}
Esempio n. 3
0
void RawInstrProfReader<IntPtrT>::createSymtab(InstrProfSymtab &Symtab) {
  for (const RawInstrProf::ProfileData<IntPtrT> *I = Data; I != DataEnd; ++I) {
    StringRef FunctionName(getName(I->NamePtr), swap(I->NameSize));
    Symtab.addFuncName(FunctionName);
    const IntPtrT FPtr = swap(I->FunctionPointer);
    if (!FPtr)
      continue;
    Symtab.mapAddress(FPtr, IndexedInstrProf::ComputeHash(FunctionName));
  }
  Symtab.finalizeSymtab();
}
Esempio n. 4
0
void InstrProfWriter::writeText(raw_fd_ostream &OS) {
  if (ProfileKind == PF_IRLevel)
    OS << "# IR level Instrumentation Flag\n:ir\n";
  InstrProfSymtab Symtab;
  for (const auto &I : FunctionData)
    if (shouldEncodeData(I.getValue()))
      Symtab.addFuncName(I.getKey());
  Symtab.finalizeSymtab();

  for (const auto &I : FunctionData)
    if (shouldEncodeData(I.getValue()))
      for (const auto &Func : I.getValue())
        writeRecordInText(Func.second, Symtab, OS);
}
Esempio n. 5
0
Error InstrProfWriter::writeText(raw_fd_ostream &OS) {
  if (ProfileKind == PF_IRLevel)
    OS << "# IR level Instrumentation Flag\n:ir\n";
  InstrProfSymtab Symtab;
  for (const auto &I : FunctionData)
    if (shouldEncodeData(I.getValue()))
      if (Error E = Symtab.addFuncName(I.getKey()))
        return E;

  for (const auto &I : FunctionData)
    if (shouldEncodeData(I.getValue()))
      for (const auto &Func : I.getValue())
        writeRecordInText(I.getKey(), Func.first, Func.second, Symtab, OS);
  return Error::success();
}