From 57c62e6ab9ea5332f5708b97dce71224fe607871 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Wed, 4 Mar 2015 22:13:25 +0000 Subject: [PATCH] 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. llvm-svn: 231301 --- lld/lib/ReaderWriter/PECOFF/Atoms.h | 17 ----------------- lld/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp | 10 ++++++++-- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/lld/lib/ReaderWriter/PECOFF/Atoms.h b/lld/lib/ReaderWriter/PECOFF/Atoms.h index 733b9846e1fd..1890c69e19a2 100644 --- a/lld/lib/ReaderWriter/PECOFF/Atoms.h +++ b/lld/lib/ReaderWriter/PECOFF/Atoms.h @@ -354,23 +354,6 @@ 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 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)); -} - } // namespace pecoff } // namespace lld diff --git a/lld/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp b/lld/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp index f5ddbe5b832c..a9a1563ab080 100644 --- a/lld/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp +++ b/lld/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp @@ -754,8 +754,14 @@ std::error_code FileCOFF::AtomizeDefinedSymbols( 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);