Index: include/lld/Core/Reference.h =================================================================== --- include/lld/Core/Reference.h +++ include/lld/Core/Reference.h @@ -82,16 +82,15 @@ /// 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 Index: include/lld/Passes/LayoutPass.h =================================================================== --- include/lld/Passes/LayoutPass.h +++ include/lld/Passes/LayoutPass.h @@ -52,10 +52,6 @@ // 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); Index: lib/Core/Reader.cpp =================================================================== --- lib/Core/Reader.cpp +++ lib/Core/Reader.cpp @@ -52,7 +52,6 @@ } static const Registry::KindStrings kindStrings[] = { - {Reference::kindInGroup, "in-group"}, {Reference::kindLayoutAfter, "layout-after"}, {Reference::kindLayoutBefore, "layout-before"}, {Reference::kindGroupChild, "group-child"}, Index: lib/Passes/LayoutPass.cpp =================================================================== --- lib/Passes/LayoutPass.cpp +++ lib/Passes/LayoutPass.cpp @@ -400,74 +400,6 @@ } } -/// 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(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 @@ // 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)); Index: lib/ReaderWriter/ELF/ELFFile.h =================================================================== --- lib/ReaderWriter/ELF/ELFFile.h +++ lib/ReaderWriter/ELF/ELFFile.h @@ -626,7 +626,6 @@ } ELFDefinedAtom *previousAtom = nullptr; - ELFDefinedAtom *inGroupAtom = nullptr; ELFReference *anonFollowedBy = nullptr; for (auto si = symbols.begin(), se = symbols.end(); si != se; ++si) { @@ -712,20 +711,12 @@ // 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) Index: test/core/ingroup-test-big.objtxt =================================================================== --- test/core/ingroup-test-big.objtxt +++ /dev/null @@ -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 Index: test/core/ingroup-test-loop.objtxt =================================================================== --- test/core/ingroup-test-loop.objtxt +++ /dev/null @@ -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 Index: test/core/ingroup-test-with-layout-after.objtxt =================================================================== --- test/core/ingroup-test-with-layout-after.objtxt +++ /dev/null @@ -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 Index: test/core/ingroup-test.objtxt =================================================================== --- test/core/ingroup-test.objtxt +++ /dev/null @@ -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 Index: test/elf/Mips/ctors-order.test =================================================================== --- test/elf/Mips/ctors-order.test +++ test/elf/Mips/ctors-order.test @@ -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 Index: test/elf/Mips/dynlib-dynsym-micro.test =================================================================== --- test/elf/Mips/dynlib-dynsym-micro.test +++ test/elf/Mips/dynlib-dynsym-micro.test @@ -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 Index: test/elf/Mips/dynlib-dynsym.test =================================================================== --- test/elf/Mips/dynlib-dynsym.test +++ test/elf/Mips/dynlib-dynsym.test @@ -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 Index: test/elf/Mips/got16-micro.test =================================================================== --- test/elf/Mips/got16-micro.test +++ test/elf/Mips/got16-micro.test @@ -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: