[llvm] r267055 - [ProfileData] Report errors from InstrProfSymtab::create
Vedant Kumar via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 21 14:07:25 PDT 2016
Author: vedantk
Date: Thu Apr 21 16:07:25 2016
New Revision: 267055
URL: http://llvm.org/viewvc/llvm-project?rev=267055&view=rev
Log:
[ProfileData] Report errors from InstrProfSymtab::create
InstrProfSymtab::create can fail with instrprof_error::malformed, but
this error is silently dropped. Propagate the error up to the caller so
we fail early.
Eventually, I'd like to transition ProfileData over to the new Error
class so we can't ignore hard failures like this.
Modified:
llvm/trunk/include/llvm/ProfileData/InstrProfReader.h
llvm/trunk/lib/ProfileData/InstrProfReader.cpp
Modified: llvm/trunk/include/llvm/ProfileData/InstrProfReader.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ProfileData/InstrProfReader.h?rev=267055&r1=267054&r2=267055&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ProfileData/InstrProfReader.h (original)
+++ llvm/trunk/include/llvm/ProfileData/InstrProfReader.h Thu Apr 21 16:07:25 2016
@@ -196,7 +196,7 @@ public:
}
private:
- void createSymtab(InstrProfSymtab &Symtab);
+ std::error_code createSymtab(InstrProfSymtab &Symtab);
std::error_code readNextHeader(const char *CurrentPos);
std::error_code readHeader(const RawInstrProf::Header &Header);
template <class IntT> IntT swap(IntT Int) const {
Modified: llvm/trunk/lib/ProfileData/InstrProfReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ProfileData/InstrProfReader.cpp?rev=267055&r1=267054&r2=267055&view=diff
==============================================================================
--- llvm/trunk/lib/ProfileData/InstrProfReader.cpp (original)
+++ llvm/trunk/lib/ProfileData/InstrProfReader.cpp Thu Apr 21 16:07:25 2016
@@ -297,8 +297,11 @@ RawInstrProfReader<IntPtrT>::readNextHea
}
template <class IntPtrT>
-void RawInstrProfReader<IntPtrT>::createSymtab(InstrProfSymtab &Symtab) {
- Symtab.create(StringRef(NamesStart, NamesSize));
+std::error_code
+RawInstrProfReader<IntPtrT>::createSymtab(InstrProfSymtab &Symtab) {
+ std::error_code EC = Symtab.create(StringRef(NamesStart, NamesSize));
+ if (EC)
+ return EC;
for (const RawInstrProf::ProfileData<IntPtrT> *I = Data; I != DataEnd; ++I) {
const IntPtrT FPtr = swap(I->FunctionPointer);
if (!FPtr)
@@ -306,6 +309,7 @@ void RawInstrProfReader<IntPtrT>::create
Symtab.mapAddress(FPtr, I->NameRef);
}
Symtab.finalizeSymtab();
+ return success();
}
template <class IntPtrT>
@@ -345,7 +349,9 @@ RawInstrProfReader<IntPtrT>::readHeader(
ProfileEnd = Start + ProfileSize;
std::unique_ptr<InstrProfSymtab> NewSymtab = make_unique<InstrProfSymtab>();
- createSymtab(*NewSymtab.get());
+ if (auto EC = createSymtab(*NewSymtab.get()))
+ return EC;
+
Symtab = std::move(NewSymtab);
return success();
}
More information about the llvm-commits
mailing list