[lld] r231301 - PECOFF: Do not add layout-after edges.
Rui Ueyama
ruiu at google.com
Wed Mar 4 14:13:25 PST 2015
Author: ruiu
Date: Wed Mar 4 16:13:25 2015
New Revision: 231301
URL: http://llvm.org/viewvc/llvm-project?rev=231301&view=rev
Log:
PECOFF: Do not add layout-after edges.
The last use of layout-after edge for PE/COFF was removed in r231290.
Now layout-after edges do nothing. We can stop adding them to the graph.
No functionality change intended.
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=231301&r1=231300&r2=231301&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/Atoms.h (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/Atoms.h Wed Mar 4 16:13:25 2015
@@ -354,23 +354,6 @@ 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 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));
-}
-
} // namespace pecoff
} // namespace lld
Modified: lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp?rev=231301&r1=231300&r2=231301&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp Wed Mar 4 16:13:25 2015
@@ -754,8 +754,14 @@ std::error_code FileCOFF::AtomizeDefined
if (atoms.size() > 0)
atoms[0]->setAlignment(getAlignment(section));
- // Connect atoms with layout-before/layout-after edges.
- connectAtomsWithLayoutEdge(atoms);
+ // Connect atoms with layout-before edges. It prevents atoms
+ // from being GC'ed 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.
+ if (atoms.size() >= 2)
+ for (auto it = atoms.begin(), e = atoms.end(); it + 1 != e; ++it)
+ addLayoutEdge(*(it + 1), *it, lld::Reference::kindLayoutBefore);
for (COFFDefinedFileAtom *atom : atoms) {
_sectionAtoms[section].push_back(atom);
More information about the llvm-commits
mailing list