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
This commit is contained in:
Rui Ueyama 2015-03-04 22:13:25 +00:00
parent b8b43d5494
commit 57c62e6ab9
2 changed files with 8 additions and 19 deletions

View File

@ -354,23 +354,6 @@ void addLayoutEdge(T *a, U *b, uint32_t which) {
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

View File

@ -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);