Remove kindInGroup reference.

That kind of reference was used only in ELFFile, and the use of
that reference there didn't seem to make sense. All test still
pass (after adjusting symbol names) without that code. LLD is
still be able to link LLD and Clang. Looks like we just don't
need this.

http://reviews.llvm.org/D7189

llvm-svn: 227259
This commit is contained in:
Rui Ueyama 2015-01-27 22:55:29 +00:00
parent e745728fad
commit dd88e86b57
13 changed files with 18 additions and 274 deletions

View File

@ -82,16 +82,15 @@ public:
/// KindValues used with KindNamespace::all and KindArch::all.
enum {
kindInGroup = 1,
// kindLayoutAfter is treated as a bidirected edge by the dead-stripping
// pass.
kindLayoutAfter = 2,
kindLayoutAfter = 1,
// kindLayoutBefore is currently used only by PECOFF port, and will
// be removed soon. To enforce layout, use kindLayoutAfter instead.
kindLayoutBefore = 3,
kindLayoutBefore,
// kindGroupChild is treated as a bidirected edge too.
kindGroupChild = 4,
kindAssociate = 5,
kindGroupChild,
kindAssociate,
};
// A value to be added to the value of a target

View File

@ -52,10 +52,6 @@ private:
// reference type
void buildFollowOnTable(MutableFile::DefinedAtomRange &range);
// Build the followOn atoms chain as specified by the kindInGroup
// reference type
void buildInGroupTable(MutableFile::DefinedAtomRange &range);
// Build a map of Atoms to ordinals for sorting the atoms
void buildOrdinalOverrideMap(MutableFile::DefinedAtomRange &range);

View File

@ -52,7 +52,6 @@ Registry::loadFile(std::unique_ptr<MemoryBuffer> mb,
}
static const Registry::KindStrings kindStrings[] = {
{Reference::kindInGroup, "in-group"},
{Reference::kindLayoutAfter, "layout-after"},
{Reference::kindLayoutBefore, "layout-before"},
{Reference::kindGroupChild, "group-child"},

View File

@ -400,74 +400,6 @@ void LayoutPass::buildFollowOnTable(MutableFile::DefinedAtomRange &range) {
}
}
/// This pass builds the followon tables using InGroup relationships
/// The algorithm follows a very simple approach
/// a) If the rootAtom is not part of any root, create a new root with the
/// as the head
/// b) If the current Atom root is not found, then make the current atoms root
/// point to the rootAtom
/// c) If the root of the current Atom is itself a root of some other tree
/// make all the atoms in the chain point to the ingroup reference
/// d) Check to see if the current atom is part of the chain from the rootAtom
/// if not add the atom to the chain, so that the current atom is part of the
/// the chain where the rootAtom is in
void LayoutPass::buildInGroupTable(MutableFile::DefinedAtomRange &range) {
ScopedTask task(getDefaultDomain(), "LayoutPass::buildInGroupTable");
// This table would convert precededby references to follow on
// references so that we have only one table
for (const DefinedAtom *ai : range) {
for (const Reference *r : *ai) {
if (r->kindNamespace() != lld::Reference::KindNamespace::all ||
r->kindValue() != lld::Reference::kindInGroup)
continue;
const DefinedAtom *rootAtom = dyn_cast<DefinedAtom>(r->target());
// If the root atom is not part of any root
// create a new root
if (_followOnRoots.count(rootAtom) == 0) {
_followOnRoots[rootAtom] = rootAtom;
}
// If the current Atom has not been seen yet and there is no root
// that has been set, set the root of the atom to the targetAtom
// as the targetAtom points to the ingroup root
auto iter = _followOnRoots.find(ai);
if (iter == _followOnRoots.end()) {
_followOnRoots[ai] = rootAtom;
} else if (iter->second == ai) {
if (iter->second != rootAtom)
setChainRoot(iter->second, rootAtom);
} else {
// TODO : Flag an error that the root of the tree
// is different, Here is an example
// Say there are atoms
// chain 1 : a->b->c
// chain 2 : d->e->f
// and e,f have their ingroup reference as a
// this could happen only if the root of e,f that is d
// has root as 'a'
continue;
}
// Check if the current atom is part of the chain
bool isAtomInChain = false;
const DefinedAtom *lastAtom = rootAtom;
for (;;) {
AtomToAtomT::iterator followOnAtomsIter =
_followOnNexts.find(lastAtom);
if (followOnAtomsIter != _followOnNexts.end()) {
lastAtom = followOnAtomsIter->second;
if (lastAtom != ai)
continue;
isAtomInChain = true;
}
break;
}
if (!isAtomInChain)
_followOnNexts[lastAtom] = ai;
}
}
}
/// Build an ordinal override map by traversing the followon chain, and
/// assigning ordinals to each atom, if the atoms have their ordinals
/// already assigned skip the atom and move to the next. This is the
@ -520,9 +452,6 @@ void LayoutPass::perform(std::unique_ptr<MutableFile> &mergedFile) {
// Build follow on tables
buildFollowOnTable(atomRange);
// Build Ingroup reference table
buildInGroupTable(atomRange);
// Check the structure of followon graph if running in debug mode.
DEBUG(checkFollowonChain(atomRange));

View File

@ -632,7 +632,6 @@ template <class ELFT> std::error_code ELFFile<ELFT>::createAtoms() {
}
ELFDefinedAtom<ELFT> *previousAtom = nullptr;
ELFDefinedAtom<ELFT> *inGroupAtom = nullptr;
ELFReference<ELFT> *anonFollowedBy = nullptr;
for (auto si = symbols.begin(), se = symbols.end(); si != se; ++si) {
@ -717,20 +716,12 @@ template <class ELFT> std::error_code ELFFile<ELFT>::createAtoms() {
// Set the followon atom to the weak atom that we have created, so
// that they would alias when the file gets written.
followOn->setTarget(anonAtom ? anonAtom : newAtom);
// Add a preceded-by reference only if the current atom is not a weak
// atom.
if (symbol->getBinding() != llvm::ELF::STB_WEAK)
createEdge(newAtom, inGroupAtom, lld::Reference::kindInGroup);
}
// The previous atom is always the atom created before unless the atom
// is a weak atom.
previousAtom = anonAtom ? anonAtom : newAtom;
if (!inGroupAtom)
inGroupAtom = previousAtom;
_definedAtoms._atoms.push_back(newAtom);
_symbolToAtomMapping.insert(std::make_pair(&*symbol, newAtom));
if (anonAtom) {

View File

@ -1,57 +0,0 @@
# RUN: lld -core --add-pass layout %s | FileCheck %s -check-prefix=CHKORDER
---
defined-atoms:
- name: A
scope: global
references:
- kind: layout-after
offset: 0
target: B
- name: B
scope: global
references:
- kind: in-group
offset: 0
target: A
- kind: layout-after
offset: 0
target: C
- name: C
scope: global
references:
- kind: in-group
offset: 0
target: A
- name: E
scope: global
references:
- kind: in-group
offset: 0
target: E
- kind: layout-after
offset: 0
target: F
- name: F
scope: global
references:
- kind: in-group
offset: 0
target: E
- name: D
scope: global
references:
- kind: in-group
offset: 0
target: A
- kind: layout-after
offset: 0
target: E
...
# CHKORDER: - name: A
# CHKORDER: - name: B
# CHKORDER: - name: C
# CHKORDER: - name: D
# CHKORDER: - name: E
# CHKORDER: - name: F

View File

@ -1,20 +0,0 @@
# RUN: lld -core --add-pass layout %s | FileCheck %s -check-prefix=CHKORDER
---
defined-atoms:
- name: A
scope: global
references:
- kind: layout-after
offset: 0
target: E
- name: E
scope: global
references:
- kind: in-group
offset: 0
target: A
...
# CHKORDER: - name: A
# CHKORDER: - name: E

View File

@ -1,50 +0,0 @@
# RUN: lld -core --add-pass layout %s | FileCheck %s -check-prefix=CHKORDER
---
defined-atoms:
- name: A
scope: global
references:
- kind: layout-after
offset: 0
target: B
- name: B
scope: global
references:
- kind: in-group
offset: 0
target: A
- kind: layout-after
offset: 0
target: E
- name: F
scope: global
references:
- kind: in-group
offset: 0
target: E
- kind: layout-after
offset: 0
target: G
- name: G
scope: global
references:
- kind: in-group
offset: 0
target: E
- name: E
scope: global
references:
- kind: in-group
offset: 0
target: A
- kind: layout-after
offset: 0
target: F
...
# CHKORDER: - name: A
# CHKORDER: - name: B
# CHKORDER: - name: E
# CHKORDER: - name: F
# CHKORDER: - name: G

View File

@ -1,38 +0,0 @@
# RUN: lld -core --add-pass layout %s | FileCheck %s -check-prefix=CHKORDER
---
defined-atoms:
- name: A
scope: global
- name: B
scope: global
references:
- kind: in-group
offset: 0
target: A
- name: F
scope: global
references:
- kind: in-group
offset: 0
target: E
- name: G
scope: global
references:
- kind: in-group
offset: 0
target: E
- name: E
scope: global
references:
- kind: in-group
offset: 0
target: A
...
# CHKORDER: - name: A
# CHKORDER: - name: B
# CHKORDER: - name: E
# CHKORDER: - name: F
# CHKORDER: - name: G

View File

@ -10,8 +10,7 @@
# RUN: llvm-objdump -s %t.so | FileCheck -check-prefix=RAW %s
# CHECK: defined-atoms:
# CHECK-NEXT: - ref-name: L000
# CHECK-NEXT: type: data
# CHECK-NEXT: - type: data
# CHECK-NEXT: alignment: 2^2
# CHECK-NEXT: section-choice: custom-required
# CHECK-NEXT: section-name: .ctors
@ -25,10 +24,6 @@
# CHECK-NEXT: alignment: 2^2
# CHECK-NEXT: section-choice: custom-required
# CHECK-NEXT: section-name: .ctors
# CHECK-NEXT: references:
# CHECK-NEXT: - kind: in-group
# CHECK-NEXT: offset: 0
# CHECK-NEXT: target: L000
# CHECK-NEXT: - type: data
# CHECK-NEXT: content: [ 11, 11, 11, 11 ]
# CHECK-NEXT: alignment: 2^2
@ -39,7 +34,7 @@
# CHECK-NEXT: alignment: 2^2
# CHECK-NEXT: section-choice: custom-required
# CHECK-NEXT: section-name: .ctors.2
# CHECK-NEXT: - ref-name: L005
# CHECK-NEXT: - ref-name: L003
# CHECK-NEXT: type: data
# CHECK-NEXT: alignment: 2^2
# CHECK-NEXT: section-choice: custom-required

View File

@ -122,7 +122,7 @@
# CHECK-GOT: - kind: LLD_R_MIPS_GLOBAL_GOT
# CHECK-GOT: offset: 0
# CHECK-GOT: target: ext1
# CHECK-GOT: - ref-name: L009
# CHECK-GOT: - ref-name: L008
# CHECK-GOT: type: got
# CHECK-GOT: content: [ 00, 00, 00, 00 ]
# CHECK-GOT: alignment: 2^2

View File

@ -118,7 +118,7 @@
# CHECK-GOT: - kind: LLD_R_MIPS_GLOBAL_GOT
# CHECK-GOT: offset: 0
# CHECK-GOT: target: ext1
# CHECK-GOT: - ref-name: L009
# CHECK-GOT: - ref-name: L008
# CHECK-GOT: type: got
# CHECK-GOT: content: [ 00, 00, 00, 00 ]
# CHECK-GOT: alignment: 2^2

View File

@ -11,7 +11,7 @@
# RUN: | FileCheck -check-prefix RAW %s
# Local GOT entries:
# YAML: - ref-name: L002
# YAML: - ref-name: L001
# YAML-NEXT: type: got
# YAML-NEXT: content: [ 00, 00, 00, 00 ]
# YAML-NEXT: alignment: 2^2
@ -22,7 +22,7 @@
# YAML-NEXT: - kind: LLD_R_MIPS_32_HI16
# YAML-NEXT: offset: 0
# YAML-NEXT: target: data_1
# YAML-NEXT: - ref-name: L003
# YAML-NEXT: - ref-name: L002
# YAML-NEXT: type: got
# YAML-NEXT: content: [ 00, 00, 00, 00 ]
# YAML-NEXT: alignment: 2^2
@ -33,7 +33,7 @@
# YAML-NEXT: - kind: LLD_R_MIPS_32_HI16
# YAML-NEXT: offset: 0
# YAML-NEXT: target: data_2
# YAML-NEXT: - ref-name: L004
# YAML-NEXT: - ref-name: L003
# YAML-NEXT: type: got
# YAML-NEXT: content: [ 00, 00, 00, 00 ]
# YAML-NEXT: alignment: 2^2
@ -46,7 +46,7 @@
# YAML-NEXT: target: data_h
# Global GOT entries:
# YAML-NEXT: - ref-name: L005
# YAML-NEXT: - ref-name: L004
# YAML-NEXT: type: got
# YAML-NEXT: content: [ 00, 00, 00, 00 ]
# YAML-NEXT: alignment: 2^2
@ -60,7 +60,7 @@
# YAML-NEXT: - kind: R_MIPS_32
# YAML-NEXT: offset: 0
# YAML-NEXT: target: bar
# YAML-NEXT: - ref-name: L006
# YAML-NEXT: - ref-name: L005
# YAML-NEXT: type: got
# YAML-NEXT: content: [ 00, 00, 00, 00 ]
# YAML-NEXT: alignment: 2^2
@ -83,25 +83,25 @@
# YAML: references:
# YAML-NEXT: - kind: R_MICROMIPS_GOT16
# YAML-NEXT: offset: 0
# YAML-NEXT: target: L002
# YAML-NEXT: target: L001
# YAML-NEXT: - kind: R_MICROMIPS_LO16
# YAML-NEXT: offset: 4
# YAML-NEXT: target: data_1
# YAML-NEXT: - kind: R_MICROMIPS_GOT16
# YAML-NEXT: offset: 8
# YAML-NEXT: target: L003
# YAML-NEXT: target: L002
# YAML-NEXT: - kind: R_MICROMIPS_LO16
# YAML-NEXT: offset: 12
# YAML-NEXT: target: data_2
# YAML-NEXT: - kind: R_MICROMIPS_GOT16
# YAML-NEXT: offset: 16
# YAML-NEXT: target: L004
# YAML-NEXT: target: L003
# YAML-NEXT: - kind: R_MICROMIPS_CALL16
# YAML-NEXT: offset: 20
# YAML-NEXT: target: L005
# YAML-NEXT: target: L004
# YAML-NEXT: - kind: R_MICROMIPS_CALL16
# YAML-NEXT: offset: 24
# YAML-NEXT: target: L006
# YAML-NEXT: target: L005
# RAW: Disassembly of section .text:
# RAW: main: