[lld] r262195 - Remove dead code for ELF.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 28 13:59:03 PST 2016


Author: ruiu
Date: Sun Feb 28 15:59:02 2016
New Revision: 262195

URL: http://llvm.org/viewvc/llvm-project?rev=262195&view=rev
Log:
Remove dead code for ELF.

Modified:
    lld/trunk/include/lld/Core/LinkingContext.h
    lld/trunk/include/lld/Core/Node.h
    lld/trunk/include/lld/Core/Resolver.h
    lld/trunk/include/lld/Core/SymbolTable.h
    lld/trunk/lib/Core/LinkingContext.cpp
    lld/trunk/lib/Core/SymbolTable.cpp

Modified: lld/trunk/include/lld/Core/LinkingContext.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/LinkingContext.h?rev=262195&r1=262194&r2=262195&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/LinkingContext.h (original)
+++ lld/trunk/include/lld/Core/LinkingContext.h Sun Feb 28 15:59:02 2016
@@ -111,35 +111,6 @@ public:
   /// whether core linking considers remaining undefines to be an error.
   bool allowRemainingUndefines() const { return _allowRemainingUndefines; }
 
-  /// In the lld model, a SharedLibraryAtom is a proxy atom for something
-  /// that will be found in a dynamic shared library when the program runs.
-  /// A SharedLibraryAtom optionally contains the name of the shared library
-  /// in which to find the symbol name at runtime.  Core linking may merge
-  /// two SharedLibraryAtom with the same name.  If this method returns true,
-  /// when merging core linking will also verify that they both have the same
-  /// loadName() and if not print a warning.
-  ///
-  /// \todo This should be a method core linking calls so that drivers can
-  /// format the warning as needed.
-  bool warnIfCoalesableAtomsHaveDifferentLoadName() const {
-    return _warnIfCoalesableAtomsHaveDifferentLoadName;
-  }
-
-  /// In C/C++ you can mark a function's prototype with
-  /// __attribute__((weak_import)) or __attribute__((weak)) to say the function
-  /// may not be available at runtime and/or build time and in which case its
-  /// address will evaluate to NULL. In lld this is modeled using the
-  /// UndefinedAtom::canBeNull() method.  During core linking, UndefinedAtom
-  /// with the same name are automatically merged.  If this method returns
-  /// true, core link also verfies that the canBeNull() value for merged
-  /// UndefinedAtoms are the same and warns if not.
-  ///
-  /// \todo This should be a method core linking calls so that drivers can
-  /// format the warning as needed.
-  bool warnIfCoalesableAtomsHaveDifferentCanBeNull() const {
-    return _warnIfCoalesableAtomsHaveDifferentCanBeNull;
-  }
-
   /// Normally, every UndefinedAtom must be replaced by a DefinedAtom or a
   /// SharedLibraryAtom for the link to be successful.  This method controls
   /// whether core linking considers remaining undefines from the shared library
@@ -173,7 +144,6 @@ public:
   }
 
   void setDeadStripping(bool enable) { _deadStrip = enable; }
-  void setAllowDuplicates(bool enable) { _allowDuplicates = enable; }
   void setGlobalsAreDeadStripRoots(bool v) { _globalsAreDeadStripRoots = v; }
   void setSearchArchivesToOverrideTentativeDefinitions(bool search) {
     _searchArchivesToOverrideTentativeDefinitions = search;
@@ -181,12 +151,6 @@ public:
   void setSearchSharedLibrariesToOverrideTentativeDefinitions(bool search) {
     _searchSharedLibrariesToOverrideTentativeDefinitions = search;
   }
-  void setWarnIfCoalesableAtomsHaveDifferentCanBeNull(bool warn) {
-    _warnIfCoalesableAtomsHaveDifferentCanBeNull = warn;
-  }
-  void setWarnIfCoalesableAtomsHaveDifferentLoadName(bool warn) {
-    _warnIfCoalesableAtomsHaveDifferentLoadName = warn;
-  }
   void setPrintRemainingUndefines(bool print) {
     _printRemainingUndefines = print;
   }
@@ -196,22 +160,11 @@ public:
   void setAllowShlibUndefines(bool allow) { _allowShlibUndefines = allow; }
   void setLogInputFiles(bool log) { _logInputFiles = log; }
 
-  // Returns true if multiple definitions should not be treated as a
-  // fatal error.
-  bool getAllowDuplicates() const { return _allowDuplicates; }
-
   void appendLLVMOption(const char *opt) { _llvmOptions.push_back(opt); }
 
   std::vector<std::unique_ptr<Node>> &getNodes() { return _nodes; }
   const std::vector<std::unique_ptr<Node>> &getNodes() const { return _nodes; }
 
-  /// Notify the LinkingContext when the symbol table found a name collision.
-  /// The useNew parameter specifies which the symbol table plans to keep,
-  /// but that can be changed by the LinkingContext.  This is also an
-  /// opportunity for flavor specific processing.
-  virtual void notifySymbolTableCoalesce(const Atom *existingAtom,
-                                         const Atom *newAtom, bool &useNew) {}
-
   /// This method adds undefined symbols specified by the -u option to the to
   /// the list of undefined symbols known to the linker. This option essentially
   /// forces an undefined symbol to be created. You may also need to call
@@ -323,18 +276,12 @@ protected:
   virtual std::unique_ptr<File> createUndefinedSymbolFile() const;
   std::unique_ptr<File> createUndefinedSymbolFile(StringRef filename) const;
 
-  /// Method to create an internal file for alias symbols
-  std::unique_ptr<File> createAliasSymbolFile() const;
-
   StringRef _outputPath;
   StringRef _entrySymbolName;
   bool _deadStrip;
-  bool _allowDuplicates;
   bool _globalsAreDeadStripRoots;
   bool _searchArchivesToOverrideTentativeDefinitions;
   bool _searchSharedLibrariesToOverrideTentativeDefinitions;
-  bool _warnIfCoalesableAtomsHaveDifferentCanBeNull;
-  bool _warnIfCoalesableAtomsHaveDifferentLoadName;
   bool _printRemainingUndefines;
   bool _allowRemainingUndefines;
   bool _logInputFiles;

Modified: lld/trunk/include/lld/Core/Node.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/Node.h?rev=262195&r1=262194&r2=262195&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/Node.h (original)
+++ lld/trunk/include/lld/Core/Node.h Sun Feb 28 15:59:02 2016
@@ -57,7 +57,7 @@ private:
 class FileNode : public Node {
 public:
   explicit FileNode(std::unique_ptr<File> f)
-      : Node(Node::Kind::File), _file(std::move(f)), _asNeeded(false) {}
+      : Node(Node::Kind::File), _file(std::move(f)) {}
 
   static bool classof(const Node *a) {
     return a->kind() == Node::Kind::File;
@@ -65,12 +65,8 @@ public:
 
   File *getFile() { return _file.get(); }
 
-  void setAsNeeded(bool val) { _asNeeded = val; }
-  bool asNeeded() const { return _asNeeded; }
-
 protected:
   std::unique_ptr<File> _file;
-  bool _asNeeded;
 };
 
 } // namespace lld

Modified: lld/trunk/include/lld/Core/Resolver.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/Resolver.h?rev=262195&r1=262194&r2=262195&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/Resolver.h (original)
+++ lld/trunk/include/lld/Core/Resolver.h Sun Feb 28 15:59:02 2016
@@ -33,7 +33,7 @@ class LinkingContext;
 class Resolver {
 public:
   Resolver(LinkingContext &ctx)
-      : _ctx(ctx), _symbolTable(ctx), _result(new MergedFile()),
+      : _ctx(ctx), _symbolTable(), _result(new MergedFile()),
         _fileIndex(0) {}
 
   // InputFiles::Handler methods

Modified: lld/trunk/include/lld/Core/SymbolTable.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/SymbolTable.h?rev=262195&r1=262194&r2=262195&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/SymbolTable.h (original)
+++ lld/trunk/include/lld/Core/SymbolTable.h Sun Feb 28 15:59:02 2016
@@ -34,8 +34,6 @@ class UndefinedAtom;
 /// if an atom has been coalesced away.
 class SymbolTable {
 public:
-  explicit SymbolTable(LinkingContext &);
-
   /// @brief add atom to symbol table
   bool add(const DefinedAtom &);
 
@@ -98,7 +96,6 @@ private:
   bool addByName(const Atom &);
   bool addByContent(const DefinedAtom &);
 
-  LinkingContext &_ctx;
   AtomToAtom _replacedAtoms;
   NameToAtom _nameTable;
   AtomContentSet _contentTable;

Modified: lld/trunk/lib/Core/LinkingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/LinkingContext.cpp?rev=262195&r1=262194&r2=262195&view=diff
==============================================================================
--- lld/trunk/lib/Core/LinkingContext.cpp (original)
+++ lld/trunk/lib/Core/LinkingContext.cpp Sun Feb 28 15:59:02 2016
@@ -16,12 +16,9 @@
 namespace lld {
 
 LinkingContext::LinkingContext()
-    : _deadStrip(false), _allowDuplicates(false),
-      _globalsAreDeadStripRoots(false),
+    : _deadStrip(false), _globalsAreDeadStripRoots(false),
       _searchArchivesToOverrideTentativeDefinitions(false),
       _searchSharedLibrariesToOverrideTentativeDefinitions(false),
-      _warnIfCoalesableAtomsHaveDifferentCanBeNull(false),
-      _warnIfCoalesableAtomsHaveDifferentLoadName(false),
       _printRemainingUndefines(true), _allowRemainingUndefines(false),
       _logInputFiles(false), _allowShlibUndefines(true),
       _outputFileType(OutputFileType::Default), _nextOrdinal(0) {}

Modified: lld/trunk/lib/Core/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/SymbolTable.cpp?rev=262195&r1=262194&r2=262195&view=diff
==============================================================================
--- lld/trunk/lib/Core/SymbolTable.cpp (original)
+++ lld/trunk/lib/Core/SymbolTable.cpp Sun Feb 28 15:59:02 2016
@@ -28,8 +28,6 @@
 #include <vector>
 
 namespace lld {
-SymbolTable::SymbolTable(LinkingContext &context) : _ctx(context) {}
-
 bool SymbolTable::add(const UndefinedAtom &atom) { return addByName(atom); }
 
 bool SymbolTable::add(const SharedLibraryAtom &atom) { return addByName(atom); }
@@ -166,19 +164,16 @@ bool SymbolTable::addByName(const Atom &
       // fallthrough
     }
     case MCR_Error:
-      if (!_ctx.getAllowDuplicates()) {
-        llvm::errs() << "Duplicate symbols: "
-                     << existing->name()
-                     << ":"
-                     << existing->file().path()
-                     << " and "
-                     << newAtom.name()
-                     << ":"
-                     << newAtom.file().path()
-                     << "\n";
-        llvm::report_fatal_error("duplicate symbol error");
-      }
-      useNew = false;
+      llvm::errs() << "Duplicate symbols: "
+                   << existing->name()
+                   << ":"
+                   << existing->file().path()
+                   << " and "
+                   << newAtom.name()
+                   << ":"
+                   << newAtom.file().path()
+                   << "\n";
+      llvm::report_fatal_error("duplicate symbol error");
       break;
     }
     break;
@@ -188,14 +183,6 @@ bool SymbolTable::addByName(const Atom &
     const UndefinedAtom* newUndef = cast<UndefinedAtom>(&newAtom);
 
     bool sameCanBeNull = (existingUndef->canBeNull() == newUndef->canBeNull());
-    if (!sameCanBeNull && _ctx.warnIfCoalesableAtomsHaveDifferentCanBeNull()) {
-      llvm::errs() << "lld warning: undefined symbol "
-                   << existingUndef->name()
-                   << " has different weakness in "
-                   << existingUndef->file().path()
-                   << " and in " << newUndef->file().path() << "\n";
-    }
-
     if (sameCanBeNull)
       useNew = false;
     else
@@ -203,26 +190,6 @@ bool SymbolTable::addByName(const Atom &
     break;
   }
   case NCR_DupShLib: {
-    const SharedLibraryAtom *curShLib = cast<SharedLibraryAtom>(existing);
-    const SharedLibraryAtom *newShLib = cast<SharedLibraryAtom>(&newAtom);
-    bool sameNullness =
-        (curShLib->canBeNullAtRuntime() == newShLib->canBeNullAtRuntime());
-    bool sameName = curShLib->loadName().equals(newShLib->loadName());
-    if (sameName && !sameNullness &&
-        _ctx.warnIfCoalesableAtomsHaveDifferentCanBeNull()) {
-      // FIXME: need diagonstics interface for writing warning messages
-      llvm::errs() << "lld warning: shared library symbol "
-                   << curShLib->name() << " has different weakness in "
-                   << curShLib->file().path() << " and in "
-                   << newShLib->file().path();
-    }
-    if (!sameName && _ctx.warnIfCoalesableAtomsHaveDifferentLoadName()) {
-      // FIXME: need diagonstics interface for writing warning messages
-      llvm::errs() << "lld warning: shared library symbol "
-                   << curShLib->name() << " has different load path in "
-                   << curShLib->file().path() << " and in "
-                   << newShLib->file().path();
-    }
     useNew = false;
     break;
   }
@@ -232,9 +199,6 @@ bool SymbolTable::addByName(const Atom &
     break;
   }
 
-  // Give context a chance to change which is kept.
-  _ctx.notifySymbolTableCoalesce(existing, &newAtom, useNew);
-
   if (useNew) {
     // Update name table to use new atom.
     _nameTable[name] = &newAtom;




More information about the llvm-commits mailing list