mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
llvm-dwp: Ensure uncompressed sections are not relocated during processing of later inputs
Richard Smith identified this in post commit review of r270466. The string sections in particular (in the future, possibly all sections - so I'm not going to bother pulling out just the string sections for the extra lifetime handling right now) need to remain valid during processing of all inputs so that elements of the DWPStringPool can be looked up repeatedly without having to make in-memory copies of string contents in the noncompressed case (more common in dwp+dwp merge steps where the memory is a bigger problem because the files are larger). Using the SmallVector (or any vector) a reallocation on push_back could cause any of the nested SmallStrings in small mode to move in memory and invalid pointers to their contents. Using a deque the SmallStrings will never move around since no elements are removed from the container. llvm-svn: 270797
This commit is contained in:
parent
e8af93083e
commit
a25f65e650
@ -39,6 +39,7 @@
|
||||
#include "llvm/Support/TargetSelect.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
#include <deque>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
|
||||
@ -360,7 +361,7 @@ std::string buildDWODescription(StringRef Name, StringRef DWPName, StringRef DWO
|
||||
}
|
||||
|
||||
static Error handleCompressedSection(
|
||||
SmallVector<SmallString<32>, 4> &UncompressedSections, StringRef &Name,
|
||||
std::deque<SmallString<32>> &UncompressedSections, StringRef &Name,
|
||||
StringRef &Contents) {
|
||||
if (!Name.startswith("zdebug_"))
|
||||
return Error();
|
||||
@ -384,7 +385,7 @@ static Error handleSection(
|
||||
const MCSection *StrSection, const MCSection *StrOffsetSection,
|
||||
const MCSection *TypesSection, const MCSection *CUIndexSection,
|
||||
const MCSection *TUIndexSection, const SectionRef &Section, MCStreamer &Out,
|
||||
SmallVector<SmallString<32>, 4> &UncompressedSections,
|
||||
std::deque<SmallString<32>> &UncompressedSections,
|
||||
uint32_t (&ContributionOffsets)[8], UnitIndexEntry &CurEntry,
|
||||
StringRef &CurStrSection, StringRef &CurStrOffsetSection,
|
||||
std::vector<StringRef> &CurTypesSection, StringRef &InfoSection,
|
||||
@ -489,7 +490,7 @@ static Error write(MCStreamer &Out, ArrayRef<std::string> Inputs) {
|
||||
SmallVector<OwningBinary<object::ObjectFile>, 128> Objects;
|
||||
Objects.reserve(Inputs.size());
|
||||
|
||||
SmallVector<SmallString<32>, 4> UncompressedSections;
|
||||
std::deque<SmallString<32>> UncompressedSections;
|
||||
|
||||
for (const auto &Input : Inputs) {
|
||||
auto ErrOrObj = object::ObjectFile::createObjectFile(Input);
|
||||
|
Loading…
Reference in New Issue
Block a user