[lld] r227259 - Remove kindInGroup reference.

Rui Ueyama ruiu at google.com
Tue Jan 27 14:55:30 PST 2015


Author: ruiu
Date: Tue Jan 27 16:55:29 2015
New Revision: 227259

URL: http://llvm.org/viewvc/llvm-project?rev=227259&view=rev
Log:
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

Removed:
    lld/trunk/test/core/ingroup-test-big.objtxt
    lld/trunk/test/core/ingroup-test-loop.objtxt
    lld/trunk/test/core/ingroup-test-with-layout-after.objtxt
    lld/trunk/test/core/ingroup-test.objtxt
Modified:
    lld/trunk/include/lld/Core/Reference.h
    lld/trunk/include/lld/Passes/LayoutPass.h
    lld/trunk/lib/Core/Reader.cpp
    lld/trunk/lib/Passes/LayoutPass.cpp
    lld/trunk/lib/ReaderWriter/ELF/ELFFile.h
    lld/trunk/test/elf/Mips/ctors-order.test
    lld/trunk/test/elf/Mips/dynlib-dynsym-micro.test
    lld/trunk/test/elf/Mips/dynlib-dynsym.test
    lld/trunk/test/elf/Mips/got16-micro.test

Modified: lld/trunk/include/lld/Core/Reference.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/Reference.h?rev=227259&r1=227258&r2=227259&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/Reference.h (original)
+++ lld/trunk/include/lld/Core/Reference.h Tue Jan 27 16:55:29 2015
@@ -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

Modified: lld/trunk/include/lld/Passes/LayoutPass.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Passes/LayoutPass.h?rev=227259&r1=227258&r2=227259&view=diff
==============================================================================
--- lld/trunk/include/lld/Passes/LayoutPass.h (original)
+++ lld/trunk/include/lld/Passes/LayoutPass.h Tue Jan 27 16:55:29 2015
@@ -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);
 

Modified: lld/trunk/lib/Core/Reader.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/Reader.cpp?rev=227259&r1=227258&r2=227259&view=diff
==============================================================================
--- lld/trunk/lib/Core/Reader.cpp (original)
+++ lld/trunk/lib/Core/Reader.cpp Tue Jan 27 16:55:29 2015
@@ -52,7 +52,6 @@ Registry::loadFile(std::unique_ptr<Memor
 }
 
 static const Registry::KindStrings kindStrings[] = {
-    {Reference::kindInGroup, "in-group"},
     {Reference::kindLayoutAfter, "layout-after"},
     {Reference::kindLayoutBefore, "layout-before"},
     {Reference::kindGroupChild, "group-child"},

Modified: lld/trunk/lib/Passes/LayoutPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Passes/LayoutPass.cpp?rev=227259&r1=227258&r2=227259&view=diff
==============================================================================
--- lld/trunk/lib/Passes/LayoutPass.cpp (original)
+++ lld/trunk/lib/Passes/LayoutPass.cpp Tue Jan 27 16:55:29 2015
@@ -400,74 +400,6 @@ void LayoutPass::buildFollowOnTable(Muta
   }
 }
 
-/// 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
   // 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));
 

Modified: lld/trunk/lib/ReaderWriter/ELF/ELFFile.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ELFFile.h?rev=227259&r1=227258&r2=227259&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ELFFile.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ELFFile.h Tue Jan 27 16:55:29 2015
@@ -632,7 +632,6 @@ template <class ELFT> std::error_code EL
     }
 
     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 EL
         // 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) {

Removed: lld/trunk/test/core/ingroup-test-big.objtxt
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/core/ingroup-test-big.objtxt?rev=227258&view=auto
==============================================================================
--- lld/trunk/test/core/ingroup-test-big.objtxt (original)
+++ lld/trunk/test/core/ingroup-test-big.objtxt (removed)
@@ -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

Removed: lld/trunk/test/core/ingroup-test-loop.objtxt
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/core/ingroup-test-loop.objtxt?rev=227258&view=auto
==============================================================================
--- lld/trunk/test/core/ingroup-test-loop.objtxt (original)
+++ lld/trunk/test/core/ingroup-test-loop.objtxt (removed)
@@ -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

Removed: lld/trunk/test/core/ingroup-test-with-layout-after.objtxt
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/core/ingroup-test-with-layout-after.objtxt?rev=227258&view=auto
==============================================================================
--- lld/trunk/test/core/ingroup-test-with-layout-after.objtxt (original)
+++ lld/trunk/test/core/ingroup-test-with-layout-after.objtxt (removed)
@@ -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

Removed: lld/trunk/test/core/ingroup-test.objtxt
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/core/ingroup-test.objtxt?rev=227258&view=auto
==============================================================================
--- lld/trunk/test/core/ingroup-test.objtxt (original)
+++ lld/trunk/test/core/ingroup-test.objtxt (removed)
@@ -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

Modified: lld/trunk/test/elf/Mips/ctors-order.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/Mips/ctors-order.test?rev=227259&r1=227258&r2=227259&view=diff
==============================================================================
--- lld/trunk/test/elf/Mips/ctors-order.test (original)
+++ lld/trunk/test/elf/Mips/ctors-order.test Tue Jan 27 16:55:29 2015
@@ -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

Modified: lld/trunk/test/elf/Mips/dynlib-dynsym-micro.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/Mips/dynlib-dynsym-micro.test?rev=227259&r1=227258&r2=227259&view=diff
==============================================================================
--- lld/trunk/test/elf/Mips/dynlib-dynsym-micro.test (original)
+++ lld/trunk/test/elf/Mips/dynlib-dynsym-micro.test Tue Jan 27 16:55:29 2015
@@ -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

Modified: lld/trunk/test/elf/Mips/dynlib-dynsym.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/Mips/dynlib-dynsym.test?rev=227259&r1=227258&r2=227259&view=diff
==============================================================================
--- lld/trunk/test/elf/Mips/dynlib-dynsym.test (original)
+++ lld/trunk/test/elf/Mips/dynlib-dynsym.test Tue Jan 27 16:55:29 2015
@@ -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

Modified: lld/trunk/test/elf/Mips/got16-micro.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/Mips/got16-micro.test?rev=227259&r1=227258&r2=227259&view=diff
==============================================================================
--- lld/trunk/test/elf/Mips/got16-micro.test (original)
+++ lld/trunk/test/elf/Mips/got16-micro.test Tue Jan 27 16:55:29 2015
@@ -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:





More information about the llvm-commits mailing list