[IR] Mark the Type subclass helper methods 'inline' and move their definitions to...
[oota-llvm.git] / include / llvm / IR / FunctionInfo.h
index a8dd2d9249e88af27fd8c1de7c6803d4b2276496..eba088a61bc0ea4acae9d23347c1236c069ad7d4 100644 (file)
@@ -30,7 +30,7 @@ namespace llvm {
 /// This is a separate class from FunctionInfo to enable lazy reading of this
 /// function summary information from the combined index file during imporing.
 class FunctionSummary {
- private:
+private:
   /// \brief Path of module containing function IR, used to locate module when
   /// importing this function.
   ///
@@ -57,7 +57,7 @@ class FunctionSummary {
   /// during the initial compile step when the function index is first built.
   unsigned InstCount;
 
- public:
+public:
   /// Construct a summary object from summary data expected for all
   /// summary records.
   FunctionSummary(unsigned NumInsts) : InstCount(NumInsts) {}
@@ -90,7 +90,7 @@ class FunctionSummary {
 /// record. After parsing the associated summary information from the summary
 /// block the \a FunctionSummary is populated and stored here.
 class FunctionInfo {
- private:
+private:
   /// Function summary information used to help make ThinLTO importing
   /// decisions.
   std::unique_ptr<FunctionSummary> Summary;
@@ -109,7 +109,7 @@ class FunctionInfo {
   /// VST records with the summary records.
   uint64_t BitcodeIndex;
 
- public:
+public:
   /// Constructor used during parsing of VST entries.
   FunctionInfo(uint64_t FuncOffset)
       : Summary(nullptr), BitcodeIndex(FuncOffset) {}
@@ -157,7 +157,7 @@ typedef StringMap<uint64_t> ModulePathStringTableTy;
 /// Class to hold module path string table and function map,
 /// and encapsulate methods for operating on them.
 class FunctionInfoIndex {
- private:
+private:
   /// Map from function name to list of function information instances
   /// for functions of that name (may be duplicates in the COMDAT case, e.g.).
   FunctionInfoMapTy FunctionMap;
@@ -165,9 +165,8 @@ class FunctionInfoIndex {
   /// Holds strings for combined index, mapping to the corresponding module ID.
   ModulePathStringTableTy ModulePathStringTable;
 
- public:
+public:
   FunctionInfoIndex() = default;
-  ~FunctionInfoIndex() = default;
 
   // Disable the copy constructor and assignment operators, so
   // no unexpected copying/moving occurs.
@@ -184,14 +183,19 @@ class FunctionInfoIndex {
     return FunctionMap[FuncName];
   }
 
+  /// Get the list of function info objects for a given function.
+  const const_funcinfo_iterator findFunctionInfoList(StringRef FuncName) const {
+    return FunctionMap.find(FuncName);
+  }
+
   /// Add a function info for a function of the given name.
   void addFunctionInfo(StringRef FuncName, std::unique_ptr<FunctionInfo> Info) {
     FunctionMap[FuncName].push_back(std::move(Info));
   }
 
   /// Iterator to allow writer to walk through table during emission.
-  iterator_range<StringMap<uint64_t>::const_iterator> modPathStringEntries()
-      const {
+  iterator_range<StringMap<uint64_t>::const_iterator>
+  modPathStringEntries() const {
     return llvm::make_range(ModulePathStringTable.begin(),
                             ModulePathStringTable.end());
   }
@@ -223,8 +227,15 @@ class FunctionInfoIndex {
     return ModulePathStringTable.insert(std::make_pair(ModPath, ModId))
         .first->first();
   }
+
+  /// Check if the given Module has any functions available for exporting
+  /// in the index. We consider any module present in the ModulePathStringTable
+  /// to have exported functions.
+  bool hasExportedFunctions(const Module &M) const {
+    return ModulePathStringTable.count(M.getModuleIdentifier());
+  }
 };
 
-}  // End llvm namespace
+} // End llvm namespace
 
 #endif