From 584abaee676dfe43848c5b93133e6737ace3d408 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Fri, 27 Feb 2015 05:05:38 +0000 Subject: [PATCH] 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 --- lld/lib/ReaderWriter/PECOFF/Atoms.h | 23 ++++++---------------- lld/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp | 2 +- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/lld/lib/ReaderWriter/PECOFF/Atoms.h b/lld/lib/ReaderWriter/PECOFF/Atoms.h index f66920713964..5d101962411a 100644 --- a/lld/lib/ReaderWriter/PECOFF/Atoms.h +++ b/lld/lib/ReaderWriter/PECOFF/Atoms.h @@ -351,27 +351,16 @@ void addLayoutEdge(T *a, U *b, uint32_t which) { a->addReference(std::unique_ptr(ref)); } -template 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 void connectAtomsWithLayoutEdge(std::vector &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 diff --git a/lld/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp b/lld/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp index 171137713c5e..c42d3c2db9d3 100644 --- a/lld/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp +++ b/lld/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp @@ -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) {