diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2018-07-31 17:18:35 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2018-07-31 17:18:35 +0000 |
commit | c85947bf324728dd1b26c2a7454535ba2134185c (patch) | |
tree | 95d51ca568463410856c7f3a3e577b960d7c1388 /contrib/llvm/tools/lld/include | |
parent | 735bee93f1285c5c55c64d80fdc2ede4c0f23341 (diff) | |
parent | 20d35e67e67f106f617c939725101223211659f0 (diff) |
Merge lld trunk r338150, and resolve conflicts.
Notes
Notes:
svn path=/projects/clang700-import/; revision=336982
Diffstat (limited to 'contrib/llvm/tools/lld/include')
18 files changed, 228 insertions, 100 deletions
diff --git a/contrib/llvm/tools/lld/include/lld/Common/Driver.h b/contrib/llvm/tools/lld/include/lld/Common/Driver.h index 15ec3cd44cb5..f6d92933af62 100644 --- a/contrib/llvm/tools/lld/include/lld/Common/Driver.h +++ b/contrib/llvm/tools/lld/include/lld/Common/Driver.h @@ -30,7 +30,7 @@ bool link(llvm::ArrayRef<const char *> Args, bool CanExitEarly, } namespace mach_o { -bool link(llvm::ArrayRef<const char *> Args, +bool link(llvm::ArrayRef<const char *> Args, bool CanExitEarly, llvm::raw_ostream &Diag = llvm::errs()); } diff --git a/contrib/llvm/tools/lld/include/lld/Common/ErrorHandler.h b/contrib/llvm/tools/lld/include/lld/Common/ErrorHandler.h index 8ae6f46ac59e..f17f7cc99035 100644 --- a/contrib/llvm/tools/lld/include/lld/Common/ErrorHandler.h +++ b/contrib/llvm/tools/lld/include/lld/Common/ErrorHandler.h @@ -7,21 +7,62 @@ // //===----------------------------------------------------------------------===// // -// In LLD, we have three levels of errors: fatal, error or warn. +// We designed lld's error handlers with the following goals in mind: // -// Fatal makes the program exit immediately with an error message. -// You shouldn't use it except for reporting a corrupted input file. +// - Errors can occur at any place where we handle user input, but we don't +// want them to affect the normal execution path too much. Ideally, +// handling errors should be as simple as reporting them and exit (but +// without actually doing exit). // -// Error prints out an error message and increment a global variable -// ErrorCount to record the fact that we met an error condition. It does -// not exit, so it is safe for a lld-as-a-library use case. It is generally -// useful because it can report more than one error in a single run. +// In particular, the design to wrap all functions that could fail with +// ErrorOr<T> is rejected because otherwise we would have to wrap a large +// number of functions in lld with ErrorOr. With that approach, if some +// function F can fail, not only F but all functions that transitively call +// F have to be wrapped with ErrorOr. That seemed too much. // -// Warn doesn't do anything but printing out a given message. +// - Finding only one error at a time is not sufficient. We want to find as +// many errors as possible with one execution of the linker. That means the +// linker needs to keep running after a first error and give up at some +// checkpoint (beyond which it would find cascading, false errors caused by +// the previous errors). // -// It is not recommended to use llvm::outs() or llvm::errs() directly -// in LLD because they are not thread-safe. The functions declared in -// this file are mutually excluded, so you want to use them instead. +// - We want a simple interface to report errors. Unlike Clang, the data we +// handle is compiled binary, so we don't need an error reporting mechanism +// that's as sophisticated as the one that Clang has. +// +// The current lld's error handling mechanism is simple: +// +// - When you find an error, report it using error() and continue as far as +// you can. An internal error counter is incremented by one every time you +// call error(). +// +// A common idiom to handle an error is calling error() and then returning +// a reasonable default value. For example, if your function handles a +// user-supplied alignment value, and if you find an invalid alignment +// (e.g. 17 which is not 2^n), you may report it using error() and continue +// as if it were alignment 1 (which is the simplest reasonable value). +// +// Note that you should not continue with an invalid value; that breaks the +// internal consistency. You need to maintain all variables have some sane +// value even after an error occurred. So, when you have to continue with +// some value, always use a dummy value. +// +// - Find a reasonable checkpoint at where you want to stop the linker, and +// add code to return from the function if errorCount() > 0. In most cases, +// a checkpoint already exists, so you don't need to do anything for this. +// +// This interface satisfies all the goals that we mentioned above. +// +// You should never call fatal() except for reporting a corrupted input file. +// fatal() immediately terminates the linker, so the function is not desirable +// if you are using lld as a subroutine in other program, and with that you +// can find only one error at a time. +// +// warn() doesn't do anything but printing out a given message. +// +// It is not recommended to use llvm::outs() or llvm::errs() directly in lld +// because they are not thread-safe. The functions declared in this file are +// thread-safe. // //===----------------------------------------------------------------------===// @@ -34,6 +75,10 @@ #include "llvm/Support/Error.h" #include "llvm/Support/FileOutputBuffer.h" +namespace llvm { +class DiagnosticInfo; +} + namespace lld { class ErrorHandler { @@ -74,6 +119,9 @@ inline uint64_t errorCount() { return errorHandler().ErrorCount; } LLVM_ATTRIBUTE_NORETURN void exitLld(int Val); +void diagnosticHandler(const llvm::DiagnosticInfo &DI); +void checkError(Error E); + // check functions are convenient functions to strip errors // from error-or-value objects. template <class T> T check(ErrorOr<T> E) { diff --git a/contrib/llvm/tools/lld/include/lld/Common/Strings.h b/contrib/llvm/tools/lld/include/lld/Common/Strings.h index 1a63f75f9ecf..e17b25763781 100644 --- a/contrib/llvm/tools/lld/include/lld/Common/Strings.h +++ b/contrib/llvm/tools/lld/include/lld/Common/Strings.h @@ -10,14 +10,40 @@ #ifndef LLD_STRINGS_H #define LLD_STRINGS_H +#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/Optional.h" #include "llvm/ADT/StringRef.h" +#include "llvm/Support/GlobPattern.h" #include <string> +#include <vector> namespace lld { // Returns a demangled C++ symbol name. If Name is not a mangled // name, it returns Optional::None. llvm::Optional<std::string> demangleItanium(llvm::StringRef Name); +llvm::Optional<std::string> demangleMSVC(llvm::StringRef S); + +std::vector<uint8_t> parseHex(llvm::StringRef S); +bool isValidCIdentifier(llvm::StringRef S); + +// Write the contents of the a buffer to a file +void saveBuffer(llvm::StringRef Buffer, const llvm::Twine &Path); + +// This class represents multiple glob patterns. +class StringMatcher { +public: + StringMatcher() = default; + explicit StringMatcher(llvm::ArrayRef<llvm::StringRef> Pat); + + bool match(llvm::StringRef S) const; + +private: + std::vector<llvm::GlobPattern> Patterns; +}; + +inline llvm::ArrayRef<uint8_t> toArrayRef(llvm::StringRef S) { + return {reinterpret_cast<const uint8_t *>(S.data()), S.size()}; } +} // namespace lld #endif diff --git a/contrib/llvm/tools/lld/include/lld/Common/TargetOptionsCommandFlags.h b/contrib/llvm/tools/lld/include/lld/Common/TargetOptionsCommandFlags.h index 9c4ff7cea3fb..8443b184aa70 100644 --- a/contrib/llvm/tools/lld/include/lld/Common/TargetOptionsCommandFlags.h +++ b/contrib/llvm/tools/lld/include/lld/Common/TargetOptionsCommandFlags.h @@ -18,4 +18,5 @@ namespace lld { llvm::TargetOptions InitTargetOptionsFromCodeGenFlags(); llvm::Optional<llvm::CodeModel::Model> GetCodeModelFromCMModel(); +std::string GetCPUStr(); } diff --git a/contrib/llvm/tools/lld/include/lld/Common/Timer.h b/contrib/llvm/tools/lld/include/lld/Common/Timer.h new file mode 100644 index 000000000000..6654af626919 --- /dev/null +++ b/contrib/llvm/tools/lld/include/lld/Common/Timer.h @@ -0,0 +1,59 @@ +//===- Timer.h ----------------------------------------------*- C++ -*-===// +// +// The LLVM Linker +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLD_COMMON_TIMER_H +#define LLD_COMMON_TIMER_H + +#include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/StringRef.h" +#include <assert.h> +#include <chrono> +#include <map> +#include <memory> + +namespace lld { + +class Timer; + +struct ScopedTimer { + explicit ScopedTimer(Timer &T); + + ~ScopedTimer(); + + void stop(); + + Timer *T = nullptr; +}; + +class Timer { +public: + Timer(llvm::StringRef Name, Timer &Parent); + + static Timer &root(); + + void start(); + void stop(); + void print(); + + double millis() const; + +private: + explicit Timer(llvm::StringRef Name); + void print(int Depth, double TotalDuration, bool Recurse = true) const; + + std::chrono::time_point<std::chrono::high_resolution_clock> StartTime; + std::chrono::nanoseconds Total; + std::vector<Timer *> Children; + std::string Name; + Timer *Parent; +}; + +} // namespace lld + +#endif diff --git a/contrib/llvm/tools/lld/include/lld/Common/Version.h b/contrib/llvm/tools/lld/include/lld/Common/Version.h index 93de77df5804..23a10ed6dbf3 100644 --- a/contrib/llvm/tools/lld/include/lld/Common/Version.h +++ b/contrib/llvm/tools/lld/include/lld/Common/Version.h @@ -18,7 +18,7 @@ #include "llvm/ADT/StringRef.h" namespace lld { -/// \brief Retrieves a string representing the complete lld version. +/// Retrieves a string representing the complete lld version. std::string getLLDVersion(); } diff --git a/contrib/llvm/tools/lld/include/lld/Core/DefinedAtom.h b/contrib/llvm/tools/lld/include/lld/Core/DefinedAtom.h index 6229d67e25a5..ba10b45411f1 100644 --- a/contrib/llvm/tools/lld/include/lld/Core/DefinedAtom.h +++ b/contrib/llvm/tools/lld/include/lld/Core/DefinedAtom.h @@ -18,7 +18,7 @@ namespace lld { class File; -/// \brief The fundamental unit of linking. +/// The fundamental unit of linking. /// /// A C function or global variable is an atom. An atom has content and /// attributes. The content of a function atom is the instructions that @@ -179,10 +179,10 @@ public: }; enum DynamicExport { - /// \brief The linker may or may not export this atom dynamically depending + /// The linker may or may not export this atom dynamically depending /// on the output type and other context of the link. dynamicExportNormal, - /// \brief The linker will always export this atom dynamically. + /// The linker will always export this atom dynamically. dynamicExportAlways, }; @@ -212,26 +212,26 @@ public: } }; - /// \brief returns a value for the order of this Atom within its file. + /// returns a value for the order of this Atom within its file. /// /// This is used by the linker to order the layout of Atoms so that the /// resulting image is stable and reproducible. virtual uint64_t ordinal() const = 0; - /// \brief the number of bytes of space this atom's content will occupy in the + /// the number of bytes of space this atom's content will occupy in the /// final linked image. /// /// For a function atom, it is the number of bytes of code in the function. virtual uint64_t size() const = 0; - /// \brief The size of the section from which the atom is instantiated. + /// The size of the section from which the atom is instantiated. /// /// Merge::mergeByLargestSection is defined in terms of section size /// and not in terms of atom size, so we need this function separate /// from size(). virtual uint64_t sectionSize() const { return 0; } - /// \brief The visibility of this atom to other atoms. + /// The visibility of this atom to other atoms. /// /// C static functions have scope scopeTranslationUnit. Regular C functions /// have scope scopeGlobal. Functions compiled with visibility=hidden have @@ -239,48 +239,48 @@ public: /// not by the OS loader. virtual Scope scope() const = 0; - /// \brief Whether the linker should use direct or indirect access to this + /// Whether the linker should use direct or indirect access to this /// atom. virtual Interposable interposable() const = 0; - /// \brief how the linker should handle if multiple atoms have the same name. + /// how the linker should handle if multiple atoms have the same name. virtual Merge merge() const = 0; - /// \brief The type of this atom, such as code or data. + /// The type of this atom, such as code or data. virtual ContentType contentType() const = 0; - /// \brief The alignment constraints on how this atom must be laid out in the + /// The alignment constraints on how this atom must be laid out in the /// final linked image (e.g. 16-byte aligned). virtual Alignment alignment() const = 0; - /// \brief Whether this atom must be in a specially named section in the final + /// Whether this atom must be in a specially named section in the final /// linked image, or if the linker can infer the section based on the /// contentType(). virtual SectionChoice sectionChoice() const = 0; - /// \brief If sectionChoice() != sectionBasedOnContent, then this return the + /// If sectionChoice() != sectionBasedOnContent, then this return the /// name of the section the atom should be placed into. virtual StringRef customSectionName() const = 0; - /// \brief constraints on whether the linker may dead strip away this atom. + /// constraints on whether the linker may dead strip away this atom. virtual DeadStripKind deadStrip() const = 0; - /// \brief Under which conditions should this atom be dynamically exported. + /// Under which conditions should this atom be dynamically exported. virtual DynamicExport dynamicExport() const { return dynamicExportNormal; } - /// \brief Code model used by the atom. + /// Code model used by the atom. virtual CodeModel codeModel() const { return codeNA; } - /// \brief Returns the OS memory protections required for this atom's content + /// Returns the OS memory protections required for this atom's content /// at runtime. /// /// A function atom is R_X, a global variable is RW_, and a read-only constant /// is R__. virtual ContentPermissions permissions() const; - /// \brief returns a reference to the raw (unrelocated) bytes of this Atom's + /// returns a reference to the raw (unrelocated) bytes of this Atom's /// content. virtual ArrayRef<uint8_t> rawContent() const = 0; @@ -317,10 +317,10 @@ public: const void *_it; }; - /// \brief Returns an iterator to the beginning of this Atom's References. + /// Returns an iterator to the beginning of this Atom's References. virtual reference_iterator begin() const = 0; - /// \brief Returns an iterator to the end of this Atom's References. + /// Returns an iterator to the end of this Atom's References. virtual reference_iterator end() const = 0; /// Adds a reference to this atom. @@ -361,11 +361,11 @@ protected: ~DefinedAtom() override = default; - /// \brief Returns a pointer to the Reference object that the abstract + /// Returns a pointer to the Reference object that the abstract /// iterator "points" to. virtual const Reference *derefIterator(const void *iter) const = 0; - /// \brief Adjusts the abstract iterator to "point" to the next Reference + /// Adjusts the abstract iterator to "point" to the next Reference /// object for this Atom. virtual void incrementIterator(const void *&iter) const = 0; }; diff --git a/contrib/llvm/tools/lld/include/lld/Core/File.h b/contrib/llvm/tools/lld/include/lld/Core/File.h index 20418688dfa0..54f533576a4b 100644 --- a/contrib/llvm/tools/lld/include/lld/Core/File.h +++ b/contrib/llvm/tools/lld/include/lld/Core/File.h @@ -43,7 +43,7 @@ class File { public: virtual ~File(); - /// \brief Kinds of files that are supported. + /// Kinds of files that are supported. enum Kind { kindErrorObject, ///< a error object file (.o) kindNormalizedObject, ///< a normalized file (.o) @@ -59,7 +59,7 @@ public: kindArchiveLibrary ///< archive (.a) }; - /// \brief Returns file kind. Need for dyn_cast<> on File objects. + /// Returns file kind. Need for dyn_cast<> on File objects. Kind kind() const { return _kind; } @@ -114,10 +114,8 @@ public: AtomRange(AtomVector<T> &v) : _v(v) {} AtomRange(const AtomVector<T> &v) : _v(const_cast<AtomVector<T> &>(v)) {} - typedef std::pointer_to_unary_function<const OwningAtomPtr<T>&, - const T*> ConstDerefFn; - - typedef std::pointer_to_unary_function<OwningAtomPtr<T>&, T*> DerefFn; + using ConstDerefFn = const T* (*)(const OwningAtomPtr<T>&); + using DerefFn = T* (*)(OwningAtomPtr<T>&); typedef llvm::mapped_iterator<typename AtomVector<T>::const_iterator, ConstDerefFn> ConstItTy; @@ -174,19 +172,19 @@ public: AtomVector<T> &_v; }; - /// \brief Must be implemented to return the AtomVector object for + /// Must be implemented to return the AtomVector object for /// all DefinedAtoms in this File. virtual const AtomRange<DefinedAtom> defined() const = 0; - /// \brief Must be implemented to return the AtomVector object for + /// Must be implemented to return the AtomVector object for /// all UndefinedAtomw in this File. virtual const AtomRange<UndefinedAtom> undefined() const = 0; - /// \brief Must be implemented to return the AtomVector object for + /// Must be implemented to return the AtomVector object for /// all SharedLibraryAtoms in this File. virtual const AtomRange<SharedLibraryAtom> sharedLibrary() const = 0; - /// \brief Must be implemented to return the AtomVector object for + /// Must be implemented to return the AtomVector object for /// all AbsoluteAtoms in this File. virtual const AtomRange<AbsoluteAtom> absolute() const = 0; @@ -196,7 +194,7 @@ public: /// of a different file. We need to destruct all atoms before any files. virtual void clearAtoms() = 0; - /// \brief If a file is parsed using a different method than doParse(), + /// If a file is parsed using a different method than doParse(), /// one must use this method to set the last error status, so that /// doParse will not be called twice. Only YAML reader uses this /// (because YAML reader does not read blobs but structured data). @@ -214,12 +212,12 @@ public: } protected: - /// \brief only subclasses of File can be instantiated + /// only subclasses of File can be instantiated File(StringRef p, Kind kind) : _path(p), _kind(kind), _ordinal(UINT64_MAX), _nextAtomOrdinal(0) {} - /// \brief Subclasses should override this method to parse the + /// Subclasses should override this method to parse the /// memory buffer passed to this file's constructor. virtual std::error_code doParse() { return std::error_code(); } diff --git a/contrib/llvm/tools/lld/include/lld/Core/Instrumentation.h b/contrib/llvm/tools/lld/include/lld/Core/Instrumentation.h index 162375905e17..939d64557587 100644 --- a/contrib/llvm/tools/lld/include/lld/Core/Instrumentation.h +++ b/contrib/llvm/tools/lld/include/lld/Core/Instrumentation.h @@ -8,7 +8,7 @@ //===----------------------------------------------------------------------===// /// /// \file -/// \brief Provide an Instrumentation API that optionally uses VTune interfaces. +/// Provide an Instrumentation API that optionally uses VTune interfaces. /// //===----------------------------------------------------------------------===// @@ -24,7 +24,7 @@ namespace lld { #ifdef LLD_HAS_VTUNE -/// \brief A unique global scope for instrumentation data. +/// A unique global scope for instrumentation data. /// /// Domains last for the lifetime of the application and cannot be destroyed. /// Multiple Domains created with the same name represent the same domain. @@ -38,7 +38,7 @@ public: __itt_domain *operator->() const { return _domain; } }; -/// \brief A global reference to a string constant. +/// A global reference to a string constant. /// /// These are uniqued by the ITT runtime and cannot be deleted. They are not /// specific to a domain. @@ -54,7 +54,7 @@ public: operator __itt_string_handle *() const { return _handle; } }; -/// \brief A task on a single thread. Nests within other tasks. +/// A task on a single thread. Nests within other tasks. /// /// Each thread has its own task stack and tasks nest recursively on that stack. /// A task cannot transfer threads. @@ -68,7 +68,7 @@ class ScopedTask { ScopedTask &operator=(const ScopedTask &) = delete; public: - /// \brief Create a task in Domain \p d named \p s. + /// Create a task in Domain \p d named \p s. ScopedTask(const Domain &d, const StringHandle &s) : _domain(d) { __itt_task_begin(d, __itt_null, __itt_null, s); } @@ -83,7 +83,7 @@ public: return *this; } - /// \brief Prematurely end this task. + /// Prematurely end this task. void end() { if (_domain) __itt_task_end(_domain); @@ -93,7 +93,7 @@ public: ~ScopedTask() { end(); } }; -/// \brief A specific point in time. Allows metadata to be associated. +/// A specific point in time. Allows metadata to be associated. class Marker { public: Marker(const Domain &d, const StringHandle &s) { diff --git a/contrib/llvm/tools/lld/include/lld/Core/LinkingContext.h b/contrib/llvm/tools/lld/include/lld/Core/LinkingContext.h index eb9510cbd215..52ab1a2480e8 100644 --- a/contrib/llvm/tools/lld/include/lld/Core/LinkingContext.h +++ b/contrib/llvm/tools/lld/include/lld/Core/LinkingContext.h @@ -16,7 +16,6 @@ #include "llvm/ADT/StringRef.h" #include "llvm/Support/Allocator.h" #include "llvm/Support/Error.h" -#include "llvm/Support/raw_ostream.h" #include <cassert> #include <cstdint> #include <memory> @@ -31,7 +30,7 @@ class Writer; class Node; class SharedLibraryFile; -/// \brief The LinkingContext class encapsulates "what and how" to link. +/// The LinkingContext class encapsulates "what and how" to link. /// /// The base class LinkingContext contains the options needed by core linking. /// Subclasses of LinkingContext have additional options needed by specific @@ -167,10 +166,10 @@ public: /// After all set* methods are called, the Driver calls this method /// to validate that there are no missing options or invalid combinations /// of options. If there is a problem, a description of the problem - /// is written to the supplied stream. + /// is written to the global error handler. /// /// \returns true if there is an error with the current settings. - bool validate(raw_ostream &diagnostics); + bool validate(); /// Formats symbol name for use in error messages. virtual std::string demangle(StringRef symbolName) const = 0; @@ -250,7 +249,7 @@ protected: private: /// Validate the subclass bits. Only called by validate. - virtual bool validateImpl(raw_ostream &diagnostics) = 0; + virtual bool validateImpl() = 0; }; } // end namespace lld diff --git a/contrib/llvm/tools/lld/include/lld/Core/PassManager.h b/contrib/llvm/tools/lld/include/lld/Core/PassManager.h index 2ea65ae13ace..f2ef10f406f2 100644 --- a/contrib/llvm/tools/lld/include/lld/Core/PassManager.h +++ b/contrib/llvm/tools/lld/include/lld/Core/PassManager.h @@ -20,7 +20,7 @@ namespace lld { class SimpleFile; class Pass; -/// \brief Owns and runs a collection of passes. +/// Owns and runs a collection of passes. /// /// This class is currently just a container for passes and a way to run them. /// @@ -40,7 +40,7 @@ public: } private: - /// \brief Passes in the order they should run. + /// Passes in the order they should run. std::vector<std::unique_ptr<Pass>> _passes; }; } // end namespace lld diff --git a/contrib/llvm/tools/lld/include/lld/Core/Reader.h b/contrib/llvm/tools/lld/include/lld/Core/Reader.h index c7baf86af61f..6cf6282ff39c 100644 --- a/contrib/llvm/tools/lld/include/lld/Core/Reader.h +++ b/contrib/llvm/tools/lld/include/lld/Core/Reader.h @@ -32,7 +32,7 @@ class File; class LinkingContext; class MachOLinkingContext; -/// \brief An abstract class for reading object files, library files, and +/// An abstract class for reading object files, library files, and /// executable files. /// /// Each file format (e.g. mach-o, etc) has a concrete subclass of Reader. @@ -46,14 +46,14 @@ public: /// 2) the whole file content buffer if the above is not enough. virtual bool canParse(llvm::file_magic magic, MemoryBufferRef mb) const = 0; - /// \brief Parse a supplied buffer (already filled with the contents of a + /// Parse a supplied buffer (already filled with the contents of a /// file) and create a File object. /// The resulting File object takes ownership of the MemoryBuffer. virtual ErrorOr<std::unique_ptr<File>> loadFile(std::unique_ptr<MemoryBuffer> mb, const class Registry &) const = 0; }; -/// \brief An abstract class for handling alternate yaml representations +/// An abstract class for handling alternate yaml representations /// of object files. /// /// The YAML syntax allows "tags" which are used to specify the type of diff --git a/contrib/llvm/tools/lld/include/lld/Core/Resolver.h b/contrib/llvm/tools/lld/include/lld/Core/Resolver.h index fb62a779c0a5..5157c9fddc1a 100644 --- a/contrib/llvm/tools/lld/include/lld/Core/Resolver.h +++ b/contrib/llvm/tools/lld/include/lld/Core/Resolver.h @@ -28,7 +28,7 @@ namespace lld { class Atom; class LinkingContext; -/// \brief The Resolver is responsible for merging all input object files +/// The Resolver is responsible for merging all input object files /// and producing a merged graph. class Resolver { public: @@ -50,7 +50,7 @@ public: // Handle a shared library file. llvm::Error handleSharedLibrary(File &); - /// @brief do work of merging and resolving and return list + /// do work of merging and resolving and return list bool resolve(); std::unique_ptr<SimpleFile> resultFile() { return std::move(_result); } @@ -61,7 +61,7 @@ private: bool undefinesAdded(int begin, int end); File *getFile(int &index); - /// \brief The main function that iterates over the files to resolve + /// The main function that iterates over the files to resolve bool resolveUndefines(); void updateReferences(); void deadStripOptimize(); diff --git a/contrib/llvm/tools/lld/include/lld/Core/Simple.h b/contrib/llvm/tools/lld/include/lld/Core/Simple.h index 3aa7abf5d12b..feeed6ae473b 100644 --- a/contrib/llvm/tools/lld/include/lld/Core/Simple.h +++ b/contrib/llvm/tools/lld/include/lld/Core/Simple.h @@ -8,7 +8,7 @@ //===----------------------------------------------------------------------===// /// /// \file -/// \brief Provide simple implementations for Atoms and File. +/// Provide simple implementations for Atoms and File. /// //===----------------------------------------------------------------------===// diff --git a/contrib/llvm/tools/lld/include/lld/Core/SymbolTable.h b/contrib/llvm/tools/lld/include/lld/Core/SymbolTable.h index 9c39a6ed507c..156c56eafbf7 100644 --- a/contrib/llvm/tools/lld/include/lld/Core/SymbolTable.h +++ b/contrib/llvm/tools/lld/include/lld/Core/SymbolTable.h @@ -12,7 +12,7 @@ #include "lld/Common/LLVM.h" #include "llvm/ADT/DenseSet.h" -#include "llvm/ADT/StringExtras.h" +#include "llvm/Support/DJB.h" #include <cstring> #include <map> #include <vector> @@ -27,35 +27,35 @@ class ResolverOptions; class SharedLibraryAtom; class UndefinedAtom; -/// \brief The SymbolTable class is responsible for coalescing atoms. +/// The SymbolTable class is responsible for coalescing atoms. /// /// All atoms coalescable by-name or by-content should be added. /// The method replacement() can be used to find the replacement atom /// if an atom has been coalesced away. class SymbolTable { public: - /// @brief add atom to symbol table + /// add atom to symbol table bool add(const DefinedAtom &); - /// @brief add atom to symbol table + /// add atom to symbol table bool add(const UndefinedAtom &); - /// @brief add atom to symbol table + /// add atom to symbol table bool add(const SharedLibraryAtom &); - /// @brief add atom to symbol table + /// add atom to symbol table bool add(const AbsoluteAtom &); - /// @brief returns atom in symbol table for specified name (or nullptr) + /// returns atom in symbol table for specified name (or nullptr) const Atom *findByName(StringRef sym); - /// @brief returns vector of remaining UndefinedAtoms + /// returns vector of remaining UndefinedAtoms std::vector<const UndefinedAtom *> undefines(); - /// @brief if atom has been coalesced away, return replacement, else return atom + /// if atom has been coalesced away, return replacement, else return atom const Atom *replacement(const Atom *); - /// @brief if atom has been coalesced away, return true + /// if atom has been coalesced away, return true bool isCoalescedAway(const Atom *); private: @@ -65,7 +65,7 @@ private: static StringRef getEmptyKey() { return StringRef(); } static StringRef getTombstoneKey() { return StringRef(" ", 1); } static unsigned getHashValue(StringRef const val) { - return llvm::HashString(val); + return llvm::djbHash(val, 0); } static bool isEqual(StringRef const lhs, StringRef const rhs) { return lhs.equals(rhs); diff --git a/contrib/llvm/tools/lld/include/lld/Core/TODO.txt b/contrib/llvm/tools/lld/include/lld/Core/TODO.txt index 8b523045de75..2aa61ff8612d 100644 --- a/contrib/llvm/tools/lld/include/lld/Core/TODO.txt +++ b/contrib/llvm/tools/lld/include/lld/Core/TODO.txt @@ -6,9 +6,6 @@ include/lld/Core abstraction only works for returning low level OS errors. It does not work for describing formatting issues. -* We need to design a diagnostics interface. It would be nice to share code - with Clang_ where possible. - * We need to add more attributes to File. In particular, we need cpu and OS information (like target triples). We should also provide explicit support for `LLVM IR module flags metadata`__. diff --git a/contrib/llvm/tools/lld/include/lld/Core/Writer.h b/contrib/llvm/tools/lld/include/lld/Core/Writer.h index 1f0ca4cda41f..1cdfabefebd7 100644 --- a/contrib/llvm/tools/lld/include/lld/Core/Writer.h +++ b/contrib/llvm/tools/lld/include/lld/Core/Writer.h @@ -20,17 +20,17 @@ class File; class LinkingContext; class MachOLinkingContext; -/// \brief The Writer is an abstract class for writing object files, shared +/// The Writer is an abstract class for writing object files, shared /// library files, and executable files. Each file format (e.g. mach-o, etc) /// has a concrete subclass of Writer. class Writer { public: virtual ~Writer(); - /// \brief Write a file from the supplied File object + /// Write a file from the supplied File object virtual llvm::Error writeFile(const File &linkedFile, StringRef path) = 0; - /// \brief This method is called by Core Linking to give the Writer a chance + /// This method is called by Core Linking to give the Writer a chance /// to add file format specific "files" to set of files to be linked. This is /// how file format specific atoms can be added to the link. virtual void createImplicitFiles(std::vector<std::unique_ptr<File>> &) {} diff --git a/contrib/llvm/tools/lld/include/lld/ReaderWriter/MachOLinkingContext.h b/contrib/llvm/tools/lld/include/lld/ReaderWriter/MachOLinkingContext.h index 9eefa8c4d944..fde65880c3e3 100644 --- a/contrib/llvm/tools/lld/include/lld/ReaderWriter/MachOLinkingContext.h +++ b/contrib/llvm/tools/lld/include/lld/ReaderWriter/MachOLinkingContext.h @@ -89,7 +89,7 @@ public: bool exportDynamicSymbols); void addPasses(PassManager &pm) override; - bool validateImpl(raw_ostream &diagnostics) override; + bool validateImpl() override; std::string demangle(StringRef symbolName) const override; void createImplicitFiles(std::vector<std::unique_ptr<File>> &) override; @@ -201,7 +201,7 @@ public: uint32_t swiftVersion() const { return _swiftVersion; } - /// \brief Checks whether a given path on the filesystem exists. + /// Checks whether a given path on the filesystem exists. /// /// When running in -test_file_usage mode, this method consults an /// internally maintained list of files that exist (provided by -path_exists) @@ -211,7 +211,7 @@ public: /// Like pathExists() but only used on files - not directories. bool fileExists(StringRef path) const; - /// \brief Adds any library search paths derived from the given base, possibly + /// Adds any library search paths derived from the given base, possibly /// modified by -syslibroots. /// /// The set of paths added consists of approximately all syslibroot-prepended @@ -219,7 +219,7 @@ public: /// for whatever reason. With various edge-cases for compatibility. void addModifiedSearchDir(StringRef libPath, bool isSystemPath = false); - /// \brief Determine whether -lFoo can be resolve within the given path, and + /// Determine whether -lFoo can be resolve within the given path, and /// return the filename if so. /// /// The -lFoo option is documented to search for libFoo.dylib and libFoo.a in @@ -228,7 +228,7 @@ public: llvm::Optional<StringRef> searchDirForLibrary(StringRef path, StringRef libName) const; - /// \brief Iterates through all search path entries looking for libName (as + /// Iterates through all search path entries looking for libName (as /// specified by -lFoo). llvm::Optional<StringRef> searchLibrary(StringRef libName) const; @@ -236,11 +236,11 @@ public: /// the path with syslibroot. void addFrameworkSearchDir(StringRef fwPath, bool isSystemPath = false); - /// \brief Iterates through all framework directories looking for + /// Iterates through all framework directories looking for /// Foo.framework/Foo (when fwName = "Foo"). llvm::Optional<StringRef> findPathForFramework(StringRef fwName) const; - /// \brief The dylib's binary compatibility version, in the raw uint32 format. + /// The dylib's binary compatibility version, in the raw uint32 format. /// /// When building a dynamic library, this is the compatibility version that /// gets embedded into the result. Other Mach-O binaries that link against @@ -249,28 +249,28 @@ public: /// installed dynamic library. uint32_t compatibilityVersion() const { return _compatibilityVersion; } - /// \brief The dylib's current version, in the the raw uint32 format. + /// The dylib's current version, in the the raw uint32 format. /// /// When building a dynamic library, this is the current version that gets /// embedded into the result. Other Mach-O binaries that link against /// this library will store the compatibility version in its load command. uint32_t currentVersion() const { return _currentVersion; } - /// \brief The dylib's install name. + /// The dylib's install name. /// /// Binaries that link against the dylib will embed this path into the dylib /// load command. When loading the binaries at runtime, this is the location /// on disk that the loader will look for the dylib. StringRef installName() const { return _installName; } - /// \brief Whether or not the dylib has side effects during initialization. + /// Whether or not the dylib has side effects during initialization. /// /// Dylibs marked as being dead strippable provide the guarantee that loading /// the dylib has no side effects, allowing the linker to strip out the dylib /// when linking a binary that does not use any of its symbols. bool deadStrippableDylib() const { return _deadStrippableDylib; } - /// \brief Whether or not to use flat namespace. + /// Whether or not to use flat namespace. /// /// MachO usually uses a two-level namespace, where each external symbol /// referenced by the target is associated with the dylib that will provide @@ -282,7 +282,7 @@ public: /// loaded flat_namespace dylibs must be resolvable at build time. bool useFlatNamespace() const { return _flatNamespace; } - /// \brief How to handle undefined symbols. + /// How to handle undefined symbols. /// /// Options are: /// * error: Report an error and terminate linking. @@ -294,7 +294,7 @@ public: /// runtime. UndefinedMode undefinedMode() const { return _undefinedMode; } - /// \brief The path to the executable that will load the bundle at runtime. + /// The path to the executable that will load the bundle at runtime. /// /// When building a Mach-O bundle, this executable will be examined if there /// are undefined symbols after the main link phase. It is expected that this @@ -331,7 +331,7 @@ public: /// Add section alignment constraint on final layout. void addSectionAlignment(StringRef seg, StringRef sect, uint16_t align); - /// \brief Add a section based on a command-line sectcreate option. + /// Add a section based on a command-line sectcreate option. void addSectCreateSection(StringRef seg, StringRef sect, std::unique_ptr<MemoryBuffer> content); |