forked from OSchip/llvm-project
PECOFF: Do not add layout-after edges.
Previously we needed to create atoms as a doubly-linked link, but it's no longer needed. Also we don't use layout-after edges in PE/COFF. Creating such edges is just waste. llvm-svn: 230732
This commit is contained in:
parent
60aa7985cc
commit
584abaee67
|
@ -351,27 +351,16 @@ void addLayoutEdge(T *a, U *b, uint32_t which) {
|
|||
a->addReference(std::unique_ptr<COFFReference>(ref));
|
||||
}
|
||||
|
||||
template <typename T, typename U> void connectWithLayoutEdge(T *a, U *b) {
|
||||
addLayoutEdge(a, b, lld::Reference::kindLayoutAfter);
|
||||
addLayoutEdge(b, a, lld::Reference::kindLayoutBefore);
|
||||
}
|
||||
|
||||
/// Connect atoms with layout-{before,after} edges. It usually serves two
|
||||
/// purposes.
|
||||
///
|
||||
/// - To prevent atoms from being GC'ed (aka dead-stripped) if there is a
|
||||
/// reference to one of the atoms. In that case we want to emit all the
|
||||
/// atoms appeared in the same section, because the referenced "live" atom
|
||||
/// may reference other atoms in the same section. If we don't add layout
|
||||
/// edges between atoms, unreferenced atoms in the same section would be
|
||||
/// GC'ed.
|
||||
/// - To preserve the order of atmos. We want to emit the atoms in the
|
||||
/// same order as they appeared in the input object file.
|
||||
/// Connect atoms with layout-before edges. It prevents atoms from
|
||||
/// being GC'ed (aka dead-stripped) if there is a reference to one of
|
||||
/// the atoms in the same layout-before chain. In such case we want to
|
||||
/// emit all the atoms appeared in the same chain, because the "live"
|
||||
/// atom may reference other atoms in the same chain.
|
||||
template <typename T> void connectAtomsWithLayoutEdge(std::vector<T *> &atoms) {
|
||||
if (atoms.size() < 2)
|
||||
return;
|
||||
for (auto it = atoms.begin(), e = atoms.end(); it + 1 != e; ++it)
|
||||
connectWithLayoutEdge(*it, *(it + 1));
|
||||
addLayoutEdge(*(it + 1), *it, lld::Reference::kindLayoutBefore);
|
||||
}
|
||||
|
||||
} // namespace pecoff
|
||||
|
|
|
@ -756,7 +756,7 @@ std::error_code FileCOFF::AtomizeDefinedSymbols(
|
|||
if (atoms.size() > 0)
|
||||
atoms[0]->setAlignment(getAlignment(section));
|
||||
|
||||
// Connect atoms with layout-before/layout-after edges.
|
||||
// Connect atoms with layout-before edges.
|
||||
connectAtomsWithLayoutEdge(atoms);
|
||||
|
||||
for (COFFDefinedFileAtom *atom : atoms) {
|
||||
|
|
Loading…
Reference in New Issue