[PATCH] D66693: [SampleFDO] Extract the code calling each section reader to addOneSection
Wei Mi via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 26 08:55:47 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rG077a9c7053dc: [SampleFDO] Extract the code calling each section reader to readOneSection. (authored by wmi).
Herald added a subscriber: hiraditya.
Changed prior to commit:
https://reviews.llvm.org/D66693?vs=216982&id=217174#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D66693/new/
https://reviews.llvm.org/D66693
Files:
llvm/include/llvm/ProfileData/SampleProfReader.h
llvm/lib/ProfileData/SampleProfReader.cpp
Index: llvm/lib/ProfileData/SampleProfReader.cpp
===================================================================
--- llvm/lib/ProfileData/SampleProfReader.cpp
+++ llvm/lib/ProfileData/SampleProfReader.cpp
@@ -467,6 +467,31 @@
return sampleprof_error::success;
}
+std::error_code
+SampleProfileReaderExtBinary::readOneSection(const uint8_t *Start,
+ uint64_t Size, SecType Type) {
+ Data = Start;
+ switch (Type) {
+ case SecProfSummary:
+ if (std::error_code EC = readSummary())
+ return EC;
+ break;
+ case SecNameTable:
+ if (std::error_code EC = readNameTable())
+ return EC;
+ break;
+ case SecLBRProfile:
+ while (Data < Start + Size) {
+ if (std::error_code EC = readFuncProfile())
+ return EC;
+ }
+ break;
+ default:
+ break;
+ }
+ return sampleprof_error::success;
+}
+
std::error_code SampleProfileReaderExtBinaryBase::read() {
const uint8_t *BufStart =
reinterpret_cast<const uint8_t *>(Buffer->getBufferStart());
@@ -475,26 +500,10 @@
// Skip empty section.
if (!Entry.Size)
continue;
- Data = BufStart + Entry.Offset;
- switch (Entry.Type) {
- case SecProfSummary:
- if (std::error_code EC = readSummary())
- return EC;
- break;
- case SecNameTable:
- if (std::error_code EC = readNameTable())
- return EC;
- break;
- case SecLBRProfile:
- while (Data < BufStart + Entry.Offset + Entry.Size) {
- if (std::error_code EC = readFuncProfile())
- return EC;
- }
- break;
- default:
- continue;
- }
- if (Data != BufStart + Entry.Offset + Entry.Size)
+ const uint8_t *SecStart = BufStart + Entry.Offset;
+ if (std::error_code EC = readOneSection(SecStart, Entry.Size, Entry.Type))
+ return EC;
+ if (Data != SecStart + Entry.Size)
return sampleprof_error::malformed;
}
Index: llvm/include/llvm/ProfileData/SampleProfReader.h
===================================================================
--- llvm/include/llvm/ProfileData/SampleProfReader.h
+++ llvm/include/llvm/ProfileData/SampleProfReader.h
@@ -481,6 +481,8 @@
std::error_code readSecHdrTable();
virtual std::error_code readHeader() override;
virtual std::error_code verifySPMagic(uint64_t Magic) override = 0;
+ virtual std::error_code readOneSection(const uint8_t *Start, uint64_t Size,
+ SecType Type) = 0;
public:
SampleProfileReaderExtBinaryBase(std::unique_ptr<MemoryBuffer> B,
@@ -494,6 +496,8 @@
class SampleProfileReaderExtBinary : public SampleProfileReaderExtBinaryBase {
private:
virtual std::error_code verifySPMagic(uint64_t Magic) override;
+ virtual std::error_code readOneSection(const uint8_t *Start, uint64_t Size,
+ SecType Type) override;
public:
SampleProfileReaderExtBinary(std::unique_ptr<MemoryBuffer> B, LLVMContext &C,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66693.217174.patch
Type: text/x-patch
Size: 2975 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190826/5a8dd4ef/attachment.bin>
More information about the llvm-commits
mailing list