summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/ProfileData/InstrProf.cpp3
-rw-r--r--llvm/lib/ProfileData/InstrProfReader.cpp29
-rw-r--r--llvm/lib/ProfileData/InstrProfWriter.cpp4
3 files changed, 19 insertions, 17 deletions
diff --git a/llvm/lib/ProfileData/InstrProf.cpp b/llvm/lib/ProfileData/InstrProf.cpp
index fd25728a8a8..106b3770cb0 100644
--- a/llvm/lib/ProfileData/InstrProf.cpp
+++ b/llvm/lib/ProfileData/InstrProf.cpp
@@ -355,7 +355,7 @@ Error InstrProfSymtab::create(Module &M, bool InLTO) {
}
}
}
- Sorted = false;
+
finalizeSymtab();
return Error::success();
}
@@ -476,6 +476,7 @@ Error readPGOFuncNameStrings(StringRef NameStrings, InstrProfSymtab &Symtab) {
while (P < EndP && *P == 0)
P++;
}
+ Symtab.finalizeSymtab();
return Error::success();
}
diff --git a/llvm/lib/ProfileData/InstrProfReader.cpp b/llvm/lib/ProfileData/InstrProfReader.cpp
index 64f98ad0051..b920beeb1c0 100644
--- a/llvm/lib/ProfileData/InstrProfReader.cpp
+++ b/llvm/lib/ProfileData/InstrProfReader.cpp
@@ -200,13 +200,9 @@ TextInstrProfReader::readValueProfileData(InstrProfRecord &Record) {
std::pair<StringRef, StringRef> VD = Line->rsplit(':');
uint64_t TakenCount, Value;
if (ValueKind == IPVK_IndirectCallTarget) {
- if (InstrProfSymtab::isExternalSymbol(VD.first)) {
- Value = 0;
- } else {
- if (Error E = Symtab->addFuncName(VD.first))
- return E;
- Value = IndexedInstrProf::ComputeHash(VD.first);
- }
+ if (Error E = Symtab->addFuncName(VD.first))
+ return E;
+ Value = IndexedInstrProf::ComputeHash(VD.first);
} else {
READ_NUM(VD.first, Value);
}
@@ -231,13 +227,14 @@ Error TextInstrProfReader::readNextRecord(NamedInstrProfRecord &Record) {
++Line;
// If we hit EOF while looking for a name, we're done.
if (Line.is_at_end()) {
+ Symtab->finalizeSymtab();
return error(instrprof_error::eof);
}
// Read the function name.
Record.Name = *Line++;
if (Error E = Symtab->addFuncName(Record.Name))
- return error(std::move(E));
+ return E;
// Read the function hash.
if (Line.is_at_end())
@@ -268,8 +265,11 @@ Error TextInstrProfReader::readNextRecord(NamedInstrProfRecord &Record) {
// Check if value profile data exists and read it if so.
if (Error E = readValueProfileData(Record))
- return error(std::move(E));
+ return E;
+ // This is needed to avoid two pass parsing because llvm-profdata
+ // does dumping while reading.
+ Symtab->finalizeSymtab();
return success();
}
@@ -331,6 +331,7 @@ Error RawInstrProfReader<IntPtrT>::createSymtab(InstrProfSymtab &Symtab) {
continue;
Symtab.mapAddress(FPtr, I->NameRef);
}
+ Symtab.finalizeSymtab();
return success();
}
@@ -448,23 +449,23 @@ Error RawInstrProfReader<IntPtrT>::readNextRecord(NamedInstrProfRecord &Record)
if (atEnd())
// At this point, ValueDataStart field points to the next header.
if (Error E = readNextHeader(getNextHeaderPos()))
- return error(std::move(E));
+ return E;
// Read name ad set it in Record.
if (Error E = readName(Record))
- return error(std::move(E));
+ return E;
// Read FuncHash and set it in Record.
if (Error E = readFuncHash(Record))
- return error(std::move(E));
+ return E;
// Read raw counts and set Record.
if (Error E = readRawCounts(Record))
- return error(std::move(E));
+ return E;
// Read value data and set Record.
if (Error E = readValueProfilingData(Record))
- return error(std::move(E));
+ return E;
// Iterate.
advanceData();
diff --git a/llvm/lib/ProfileData/InstrProfWriter.cpp b/llvm/lib/ProfileData/InstrProfWriter.cpp
index 33ceb66fd26..ce3f8806e12 100644
--- a/llvm/lib/ProfileData/InstrProfWriter.cpp
+++ b/llvm/lib/ProfileData/InstrProfWriter.cpp
@@ -361,8 +361,7 @@ void InstrProfWriter::writeRecordInText(StringRef Name, uint64_t Hash,
std::unique_ptr<InstrProfValueData[]> VD = Func.getValueForSite(VK, S);
for (uint32_t I = 0; I < ND; I++) {
if (VK == IPVK_IndirectCallTarget)
- OS << Symtab.getFuncNameOrExternalSymbol(VD[I].Value) << ":"
- << VD[I].Count << "\n";
+ OS << Symtab.getFuncName(VD[I].Value) << ":" << VD[I].Count << "\n";
else
OS << VD[I].Value << ":" << VD[I].Count << "\n";
}
@@ -380,6 +379,7 @@ Error InstrProfWriter::writeText(raw_fd_ostream &OS) {
if (shouldEncodeData(I.getValue()))
if (Error E = Symtab.addFuncName(I.getKey()))
return E;
+ Symtab.finalizeSymtab();
for (const auto &I : FunctionData)
if (shouldEncodeData(I.getValue()))
OpenPOWER on IntegriCloud