-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[nfc]Make InstrProfSymtab non-copyable and non-movable #86882
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -894,31 +894,34 @@ static Error readCoverageMappingData( | |
Expected<std::unique_ptr<BinaryCoverageReader>> | ||
BinaryCoverageReader::createCoverageReaderFromBuffer( | ||
StringRef Coverage, FuncRecordsStorage &&FuncRecords, | ||
InstrProfSymtab &&ProfileNames, uint8_t BytesInAddress, | ||
std::unique_ptr<InstrProfSymtab> ProfileNames, uint8_t BytesInAddress, | ||
llvm::endianness Endian, StringRef CompilationDir) { | ||
std::unique_ptr<BinaryCoverageReader> Reader( | ||
new BinaryCoverageReader(std::move(FuncRecords))); | ||
Reader->ProfileNames = std::move(ProfileNames); | ||
if (ProfileNames == nullptr) | ||
return make_error<CoverageMapError>(coveragemap_error::malformed, | ||
"Caller must provide ProfileNames"); | ||
std::unique_ptr<BinaryCoverageReader> Reader(new BinaryCoverageReader( | ||
std::move(ProfileNames), std::move(FuncRecords))); | ||
InstrProfSymtab &ProfileNamesRef = *Reader->ProfileNames; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this be const too? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
It seems
Sure! I renamed input parameter to |
||
StringRef FuncRecordsRef = Reader->FuncRecords->getBuffer(); | ||
if (BytesInAddress == 4 && Endian == llvm::endianness::little) { | ||
if (Error E = readCoverageMappingData<uint32_t, llvm::endianness::little>( | ||
Reader->ProfileNames, Coverage, FuncRecordsRef, | ||
Reader->MappingRecords, CompilationDir, Reader->Filenames)) | ||
ProfileNamesRef, Coverage, FuncRecordsRef, Reader->MappingRecords, | ||
CompilationDir, Reader->Filenames)) | ||
return std::move(E); | ||
} else if (BytesInAddress == 4 && Endian == llvm::endianness::big) { | ||
if (Error E = readCoverageMappingData<uint32_t, llvm::endianness::big>( | ||
Reader->ProfileNames, Coverage, FuncRecordsRef, | ||
Reader->MappingRecords, CompilationDir, Reader->Filenames)) | ||
ProfileNamesRef, Coverage, FuncRecordsRef, Reader->MappingRecords, | ||
CompilationDir, Reader->Filenames)) | ||
return std::move(E); | ||
} else if (BytesInAddress == 8 && Endian == llvm::endianness::little) { | ||
if (Error E = readCoverageMappingData<uint64_t, llvm::endianness::little>( | ||
Reader->ProfileNames, Coverage, FuncRecordsRef, | ||
Reader->MappingRecords, CompilationDir, Reader->Filenames)) | ||
ProfileNamesRef, Coverage, FuncRecordsRef, Reader->MappingRecords, | ||
CompilationDir, Reader->Filenames)) | ||
return std::move(E); | ||
} else if (BytesInAddress == 8 && Endian == llvm::endianness::big) { | ||
if (Error E = readCoverageMappingData<uint64_t, llvm::endianness::big>( | ||
Reader->ProfileNames, Coverage, FuncRecordsRef, | ||
Reader->MappingRecords, CompilationDir, Reader->Filenames)) | ||
ProfileNamesRef, Coverage, FuncRecordsRef, Reader->MappingRecords, | ||
CompilationDir, Reader->Filenames)) | ||
return std::move(E); | ||
} else | ||
return make_error<CoverageMapError>( | ||
|
@@ -963,8 +966,8 @@ loadTestingFormat(StringRef Data, StringRef CompilationDir) { | |
if (Data.size() < ProfileNamesSize) | ||
return make_error<CoverageMapError>(coveragemap_error::malformed, | ||
"the size of ProfileNames is too big"); | ||
InstrProfSymtab ProfileNames; | ||
if (Error E = ProfileNames.create(Data.substr(0, ProfileNamesSize), Address)) | ||
auto ProfileNames = std::make_unique<InstrProfSymtab>(); | ||
if (Error E = ProfileNames->create(Data.substr(0, ProfileNamesSize), Address)) | ||
return std::move(E); | ||
Data = Data.substr(ProfileNamesSize); | ||
|
||
|
@@ -1099,7 +1102,7 @@ loadBinaryFormat(std::unique_ptr<Binary> Bin, StringRef Arch, | |
OF->isLittleEndian() ? llvm::endianness::little : llvm::endianness::big; | ||
|
||
// Look for the sections that we are interested in. | ||
InstrProfSymtab ProfileNames; | ||
auto ProfileNames = std::make_unique<InstrProfSymtab>(); | ||
std::vector<SectionRef> NamesSectionRefs; | ||
// If IPSK_name is not found, fallback to search for IPK_covname, which is | ||
// used when binary correlation is enabled. | ||
|
@@ -1116,7 +1119,7 @@ loadBinaryFormat(std::unique_ptr<Binary> Bin, StringRef Arch, | |
return make_error<CoverageMapError>( | ||
coveragemap_error::malformed, | ||
"the size of coverage mapping section is not one"); | ||
if (Error E = ProfileNames.create(NamesSectionRefs.back())) | ||
if (Error E = ProfileNames->create(NamesSectionRefs.back())) | ||
return std::move(E); | ||
|
||
auto CoverageSection = lookupSections(*OF, IPSK_covmap); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::shared_ptr has (some) overhead and since we aren't using it in this change, lets drop this comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds good! I also hesitated about whether to mention
shared_ptr
and added it mainly for completeness.