[lld] r230734 - Partially revert "PECOFF: Do not add layout-after edges."

Rui Ueyama ruiu at google.com
Thu Feb 26 21:22:19 PST 2015


Author: ruiu
Date: Thu Feb 26 23:22:19 2015
New Revision: 230734

URL: http://llvm.org/viewvc/llvm-project?rev=230734&view=rev
Log:
Partially revert "PECOFF: Do not add layout-after edges."

This reverts commit r230732.

sectionSize() in lib/Core/SymbolTable.cpp still depends on the layout-
after edges, so we couldn't remove them yet.

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=230734&r1=230733&r2=230734&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/Atoms.h (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/Atoms.h Thu Feb 26 23:22:19 2015
@@ -351,16 +351,21 @@ void addLayoutEdge(T *a, U *b, uint32_t
   a->addReference(std::unique_ptr<COFFReference>(ref));
 }
 
-/// 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, 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 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)
-    addLayoutEdge(*(it + 1), *it, lld::Reference::kindLayoutBefore);
+    connectWithLayoutEdge(*it, *(it + 1));
 }
 
 } // 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=230734&r1=230733&r2=230734&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp Thu Feb 26 23:22:19 2015
@@ -756,7 +756,7 @@ std::error_code FileCOFF::AtomizeDefined
     if (atoms.size() > 0)
       atoms[0]->setAlignment(getAlignment(section));
 
-    // Connect atoms with layout-before edges.
+    // Connect atoms with layout-before/layout-after edges.
     connectAtomsWithLayoutEdge(atoms);
 
     for (COFFDefinedFileAtom *atom : atoms) {





More information about the llvm-commits mailing list