/// 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.
///
/// 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) {}
/// 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;
/// 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) {}
/// 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;
/// 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.
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());
}
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