From 0590f4264010a852dc22c9afa16a7df4d004c19a Mon Sep 17 00:00:00 2001 From: Derek Schuff Date: Fri, 11 Jan 2013 15:29:34 -0800 Subject: Replace DepLibs bitcode record with metadata It keeps the same Module interface as the existing/old deplibs feature, but populates the library list from the metadata after reading the bitcode/LL into the Module. Keeping the same module interface will allow us to keep the existing uses (e.g. in the gold plugin) as they are. Internally it still uses the LibraryList variable, but uses it basically as a cache backed by the metadata. BUG= Review URL: https://codereview.chromium.org/11615013 --- include/llvm/Module.h | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/Module.h b/include/llvm/Module.h index bf9ac51693..ae66edc5a6 100644 --- a/include/llvm/Module.h +++ b/include/llvm/Module.h @@ -21,6 +21,7 @@ #include "llvm/GlobalVariable.h" #include "llvm/Metadata.h" #include "llvm/Support/DataTypes.h" +#include // @LOCALMOD namespace llvm { @@ -120,7 +121,10 @@ public: typedef iplist AliasListType; /// The type for the list of named metadata. typedef ilist NamedMDListType; - + // @LOCALMOD-BEGIN + /// The type for the list of dependent libraries. + typedef std::vector LibraryListType; + // @LOCALMOD-END /// The Global Variable iterator. typedef GlobalListType::iterator global_iterator; /// The Global Variable constant iterator. @@ -140,7 +144,10 @@ public: typedef NamedMDListType::iterator named_metadata_iterator; /// The named metadata constant interators. typedef NamedMDListType::const_iterator const_named_metadata_iterator; - + // @LOCALMOD-BEGIN + /// The Library list iterator. + typedef LibraryListType::const_iterator lib_iterator; + // @LOCALMOD-END /// An enumeration for describing the endianess of the target machine. enum Endianness { AnyEndianness, LittleEndian, BigEndian }; @@ -205,6 +212,8 @@ private: GlobalListType GlobalList; ///< The Global Variables in the module FunctionListType FunctionList; ///< The Functions in the module AliasListType AliasList; ///< The Aliases in the module + // @LOCALMOD + LibraryListType LibraryList; ///< The Libraries needed by the module NamedMDListType NamedMDList; ///< The named metadata in the module std::string GlobalScopeAsm; ///< Inline Asm at global scope. ValueSymbolTable *ValSymTab; ///< Symbol table for values @@ -567,8 +576,28 @@ public: const_iterator end () const { return FunctionList.end(); } size_t size() const { return FunctionList.size(); } bool empty() const { return FunctionList.empty(); } + // @LOCALMOD-BEGIN +/// @} +/// @name Dependent Library Iteration +/// @{ + + /// @brief Get a constant iterator to beginning of dependent library list. + inline lib_iterator lib_begin() const { return LibraryList.begin(); } + /// @brief Get a constant iterator to end of dependent library list. + inline lib_iterator lib_end() const { return LibraryList.end(); } + /// @brief Returns the number of items in the list of libraries. + inline size_t lib_size() const { return LibraryList.size(); } + void convertMetadataToLibraryList(); + void convertLibraryListToMetadata() const; + /// @brief Add a library to the list of dependent libraries + void addLibrary(StringRef Lib); + /// @brief Remove a library from the list of dependent libraries + void removeLibrary(StringRef Lib); + /// @brief Get all the libraries + inline const LibraryListType& getLibraries() const { return LibraryList; } /// @} + // @LOCALMOD-END /// @name Alias Iteration /// @{ -- cgit v1.2.3-70-g09d2