[lld] r230732 - PECOFF: Do not add layout-after edges.

Rui Ueyama ruiu at google.com
Thu Feb 26 21:05:38 PST 2015


Author: ruiu
Date: Thu Feb 26 23:05:38 2015
New Revision: 230732

URL: http://llvm.org/viewvc/llvm-project?rev=230732&view=rev
Log:
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.

Modified:
    lld/trunk/lib/ReaderWriter/PECOFF/Atoms.h
    lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp

Modified: lld/trunk/lib/ReaderWriter/PECOFF/Atoms.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/Atoms.h?rev=230732&r1=230731&r2=230732&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/Atoms.h (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/Atoms.h Thu Feb 26 23:05:38 2015
@@ -351,27 +351,16 @@ void addLayoutEdge(T *a, U *b, uint32_t
   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

Modified: lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp?rev=230732&r1=230731&r2=230732&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp Thu Feb 26 23:05:38 2015
@@ -756,7 +756,7 @@ std::error_code FileCOFF::AtomizeDefined
     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) {





More information about the llvm-commits mailing list