[lld] r223529 - [mach-o] Switch MachOFile and MachODylibFile to use BumpPtr in lld::File
Nick Kledzik
kledzik at apple.com
Fri Dec 5 14:03:26 PST 2014
Author: kledzik
Date: Fri Dec 5 16:03:26 2014
New Revision: 223529
URL: http://llvm.org/viewvc/llvm-project?rev=223529&view=rev
Log:
[mach-o] Switch MachOFile and MachODylibFile to use BumpPtr in lld::File
Modified:
lld/trunk/lib/ReaderWriter/MachO/File.h
Modified: lld/trunk/lib/ReaderWriter/MachO/File.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/File.h?rev=223529&r1=223528&r2=223529&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/File.h (original)
+++ lld/trunk/lib/ReaderWriter/MachO/File.h Fri Dec 5 16:03:26 2014
@@ -36,15 +36,15 @@ public:
contentSize);
if (copyRefs) {
// Make a copy of the atom's name and content that is owned by this file.
- name = name.copy(_allocator);
- content = content.copy(_allocator);
+ name = name.copy(allocator());
+ content = content.copy(allocator());
}
DefinedAtom::Alignment align(
inSection->alignment,
sectionOffset % ((uint64_t)1 << inSection->alignment));
MachODefinedAtom *atom =
- new (_allocator) MachODefinedAtom(*this, name, scope, type, merge,
- thumb, noDeadStrip, content, align);
+ new (allocator()) MachODefinedAtom(*this, name, scope, type, merge,
+ thumb, noDeadStrip, content, align);
addAtomForSection(inSection, atom, sectionOffset);
}
@@ -58,15 +58,15 @@ public:
contentSize);
if (copyRefs) {
// Make a copy of the atom's name and content that is owned by this file.
- name = name.copy(_allocator);
- content = content.copy(_allocator);
- sectionName = sectionName.copy(_allocator);
+ name = name.copy(allocator());
+ content = content.copy(allocator());
+ sectionName = sectionName.copy(allocator());
}
DefinedAtom::Alignment align(
inSection->alignment,
sectionOffset % ((uint64_t)1 << inSection->alignment));
MachODefinedCustomSectionAtom *atom =
- new (_allocator) MachODefinedCustomSectionAtom(*this, name, scope, type,
+ new (allocator()) MachODefinedCustomSectionAtom(*this, name, scope, type,
merge, thumb,
noDeadStrip, content,
sectionName, align);
@@ -79,24 +79,24 @@ public:
const Section *inSection) {
if (copyRefs) {
// Make a copy of the atom's name and content that is owned by this file.
- name = name.copy(_allocator);
+ name = name.copy(allocator());
}
DefinedAtom::Alignment align(
inSection->alignment,
sectionOffset % ((uint64_t)1 << inSection->alignment));
MachODefinedAtom *atom =
- new (_allocator) MachODefinedAtom(*this, name, scope, size, noDeadStrip,
- align);
+ new (allocator()) MachODefinedAtom(*this, name, scope, size, noDeadStrip,
+ align);
addAtomForSection(inSection, atom, sectionOffset);
}
void addUndefinedAtom(StringRef name, bool copyRefs) {
if (copyRefs) {
// Make a copy of the atom's name that is owned by this file.
- name = name.copy(_allocator);
+ name = name.copy(allocator());
}
SimpleUndefinedAtom *atom =
- new (_allocator) SimpleUndefinedAtom(*this, name);
+ new (allocator()) SimpleUndefinedAtom(*this, name);
addAtom(*atom);
_undefAtoms[name] = atom;
}
@@ -105,10 +105,10 @@ public:
DefinedAtom::Alignment align, bool copyRefs) {
if (copyRefs) {
// Make a copy of the atom's name that is owned by this file.
- name = name.copy(_allocator);
+ name = name.copy(allocator());
}
MachOTentativeDefAtom *atom =
- new (_allocator) MachOTentativeDefAtom(*this, name, scope, size, align);
+ new (allocator()) MachOTentativeDefAtom(*this, name, scope, size, align);
addAtom(*atom);
_undefAtoms[name] = atom;
}
@@ -172,7 +172,6 @@ public:
visitor(offAndAtom.atom, offAndAtom.offset);
}
- llvm::BumpPtrAllocator &allocator() { return _allocator; }
private:
struct SectionOffsetAndAtom { uint64_t offset; MachODefinedAtom *atom; };
@@ -191,7 +190,6 @@ private:
std::vector<SectionOffsetAndAtom>> SectionToAtoms;
typedef llvm::StringMap<const lld::Atom *> NameToAtom;
- llvm::BumpPtrAllocator _allocator;
SectionToAtoms _sectionAtoms;
NameToAtom _undefAtoms;
};
@@ -204,13 +202,12 @@ public:
_currentVersion(currentVersion), _compatVersion(compatVersion) {
}
- const SharedLibraryAtom *exports(StringRef name,
- bool isData) const override {
- // Pass down _installName and _allocator so that if this requested symbol
+ const SharedLibraryAtom *exports(StringRef name, bool isData) const override {
+ // Pass down _installName so that if this requested symbol
// is re-exported through this dylib, the SharedLibraryAtom's loadName()
// is this dylib installName and not the implementation dylib's.
// NOTE: isData is not needed for dylibs (it matters for static libs).
- return exports(name, _installName, _allocator);
+ return exports(name, _installName);
}
const atom_collection<DefinedAtom> &defined() const override {
@@ -233,7 +230,7 @@ public:
/// SharedLibraryAtom is created lazily (since most symbols are not used).
void addExportedSymbol(StringRef name, bool weakDef, bool copyRefs) {
if (copyRefs) {
- name = name.copy(_allocator);
+ name = name.copy(allocator());
}
AtomAndFlags info(weakDef);
_nameToAtom[name] = info;
@@ -258,16 +255,16 @@ public:
}
private:
- const SharedLibraryAtom *exports(StringRef name, StringRef installName,
- llvm::BumpPtrAllocator &allocator) const {
+ const SharedLibraryAtom *exports(StringRef name,
+ StringRef installName) const {
// First, check if requested symbol is directly implemented by this dylib.
auto entry = _nameToAtom.find(name);
if (entry != _nameToAtom.end()) {
if (!entry->second.atom) {
// Lazily create SharedLibraryAtom.
entry->second.atom =
- new (allocator) MachOSharedLibraryAtom(*this, name, installName,
- entry->second.weakDef);
+ new (allocator()) MachOSharedLibraryAtom(*this, name, installName,
+ entry->second.weakDef);
}
return entry->second.atom;
}
@@ -275,7 +272,7 @@ private:
// Next, check if symbol is implemented in some re-exported dylib.
for (const ReExportedDylib &dylib : _reExportedDylibs) {
assert(dylib.file);
- auto atom = dylib.file->exports(name, installName, allocator);
+ auto atom = dylib.file->exports(name, installName);
if (atom)
return atom;
}
@@ -307,7 +304,6 @@ private:
atom_collection_vector<AbsoluteAtom> _absoluteAtoms;
std::vector<ReExportedDylib> _reExportedDylibs;
mutable std::unordered_map<StringRef, AtomAndFlags> _nameToAtom;
- mutable llvm::BumpPtrAllocator _allocator;
};
} // end namespace mach_o
More information about the llvm-commits
mailing list