summaryrefslogtreecommitdiff
path: root/lib/ProfileData/InstrProfReader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ProfileData/InstrProfReader.cpp')
-rw-r--r--lib/ProfileData/InstrProfReader.cpp33
1 files changed, 16 insertions, 17 deletions
diff --git a/lib/ProfileData/InstrProfReader.cpp b/lib/ProfileData/InstrProfReader.cpp
index 23c9a2676b9e..3b704158a5c5 100644
--- a/lib/ProfileData/InstrProfReader.cpp
+++ b/lib/ProfileData/InstrProfReader.cpp
@@ -129,7 +129,7 @@ bool TextInstrProfReader::hasFormat(const MemoryBuffer &Buffer) {
StringRef buffer = Buffer.getBufferStart();
return count == 0 ||
std::all_of(buffer.begin(), buffer.begin() + count,
- [](char c) { return ::isprint(c) || ::isspace(c); });
+ [](char c) { return isPrint(c) || ::isspace(c); });
}
// Read the profile variant flag from the header: ":FE" means this is a FE
@@ -200,9 +200,13 @@ TextInstrProfReader::readValueProfileData(InstrProfRecord &Record) {
std::pair<StringRef, StringRef> VD = Line->rsplit(':');
uint64_t TakenCount, Value;
if (ValueKind == IPVK_IndirectCallTarget) {
- if (Error E = Symtab->addFuncName(VD.first))
- return E;
- Value = IndexedInstrProf::ComputeHash(VD.first);
+ if (InstrProfSymtab::isExternalSymbol(VD.first)) {
+ Value = 0;
+ } else {
+ if (Error E = Symtab->addFuncName(VD.first))
+ return E;
+ Value = IndexedInstrProf::ComputeHash(VD.first);
+ }
} else {
READ_NUM(VD.first, Value);
}
@@ -227,14 +231,13 @@ 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 E;
+ return error(std::move(E));
// Read the function hash.
if (Line.is_at_end())
@@ -265,11 +268,8 @@ Error TextInstrProfReader::readNextRecord(NamedInstrProfRecord &Record) {
// Check if value profile data exists and read it if so.
if (Error E = readValueProfileData(Record))
- return E;
+ return error(std::move(E));
- // This is needed to avoid two pass parsing because llvm-profdata
- // does dumping while reading.
- Symtab->finalizeSymtab();
return success();
}
@@ -331,7 +331,6 @@ Error RawInstrProfReader<IntPtrT>::createSymtab(InstrProfSymtab &Symtab) {
continue;
Symtab.mapAddress(FPtr, I->NameRef);
}
- Symtab.finalizeSymtab();
return success();
}
@@ -439,7 +438,7 @@ Error RawInstrProfReader<IntPtrT>::readValueProfilingData(
// 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());
+ VDataPtrOrErr.get()->deserializeTo(Record, Symtab.get());
CurValueDataSize = VDataPtrOrErr.get()->getSize();
return success();
}
@@ -449,23 +448,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 E;
+ return error(std::move(E));
// Read name ad set it in Record.
if (Error E = readName(Record))
- return E;
+ return error(std::move(E));
// Read FuncHash and set it in Record.
if (Error E = readFuncHash(Record))
- return E;
+ return error(std::move(E));
// Read raw counts and set Record.
if (Error E = readRawCounts(Record))
- return E;
+ return error(std::move(E));
// Read value data and set Record.
if (Error E = readValueProfilingData(Record))
- return E;
+ return error(std::move(E));
// Iterate.
advanceData();