Revert "Revert "[InstrProf] Support for external functions in text format.""
Summary:
This reverts commit 364eb09576a7667bc6d3ff80c52a83014ccac976 and separates out
the portion that was fixing binary reader error propagation - turns out, there
are production cases where that causes a regression.
Will re-introduce the error propagation fix separately.
The fix to the text reader error propagation is still "in".
Reviewers: bkramer
Reviewed By: bkramer
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D44807
llvm-svn: 328244
diff --git a/llvm/lib/ProfileData/InstrProfReader.cpp b/llvm/lib/ProfileData/InstrProfReader.cpp
index b920beeb..f5c97d1 100644
--- a/llvm/lib/ProfileData/InstrProfReader.cpp
+++ b/llvm/lib/ProfileData/InstrProfReader.cpp
@@ -200,9 +200,13 @@
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 @@
++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 @@
// 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 @@
continue;
Symtab.mapAddress(FPtr, I->NameRef);
}
- Symtab.finalizeSymtab();
return success();
}