Changeset View
Changeset View
Standalone View
Standalone View
include/llvm/IR/FunctionInfo.h
Show First 20 Lines • Show All 237 Lines • ▼ Show 20 Lines | |||||
/// insertions and resizing. | /// insertions and resizing. | ||||
typedef std::map<uint64_t, GlobalValueInfoList> GlobalValueInfoMapTy; | typedef std::map<uint64_t, GlobalValueInfoList> GlobalValueInfoMapTy; | ||||
/// Type used for iterating through the global value info map. | /// Type used for iterating through the global value info map. | ||||
typedef GlobalValueInfoMapTy::const_iterator const_globalvalueinfo_iterator; | typedef GlobalValueInfoMapTy::const_iterator const_globalvalueinfo_iterator; | ||||
typedef GlobalValueInfoMapTy::iterator globalvalueinfo_iterator; | typedef GlobalValueInfoMapTy::iterator globalvalueinfo_iterator; | ||||
/// String table to hold/own module path strings, which additionally holds the | /// String table to hold/own module path strings, which additionally holds the | ||||
/// module ID assigned to each module during the plugin step. The StringMap | /// module ID assigned to each module during the plugin step, as well as a hash | ||||
/// makes a copy of and owns inserted strings. | /// of the module. The StringMap makes a copy of and owns inserted strings. | ||||
typedef StringMap<uint64_t> ModulePathStringTableTy; | typedef StringMap<std::pair<uint64_t, unsigned>> ModulePathStringTableTy; | ||||
/// Class to hold module path string table and global value map, | /// Class to hold module path string table and global value map, | ||||
/// and encapsulate methods for operating on them. | /// and encapsulate methods for operating on them. | ||||
/// FIXME: Rename this and other uses of Function.*Index to something | /// FIXME: Rename this and other uses of Function.*Index to something | ||||
/// that reflects the now-expanded scope of the summary beyond just functions. | /// that reflects the now-expanded scope of the summary beyond just functions. | ||||
class FunctionInfoIndex { | class FunctionInfoIndex { | ||||
private: | private: | ||||
/// Map from value name to list of information instances for values of that | /// Map from value name to list of information instances for values of that | ||||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | public: | ||||
/// Add a global value info for a value of the given GUID. | /// Add a global value info for a value of the given GUID. | ||||
void addGlobalValueInfo(uint64_t ValueGUID, | void addGlobalValueInfo(uint64_t ValueGUID, | ||||
std::unique_ptr<GlobalValueInfo> Info) { | std::unique_ptr<GlobalValueInfo> Info) { | ||||
GlobalValueMap[ValueGUID].push_back(std::move(Info)); | GlobalValueMap[ValueGUID].push_back(std::move(Info)); | ||||
} | } | ||||
/// Iterator to allow writer to walk through table during emission. | /// Iterator to allow writer to walk through table during emission. | ||||
const StringMap<uint64_t> &modulePaths() const { | const StringMap<std::pair<uint64_t, unsigned>> &modulePaths() const { | ||||
return ModulePathStringTable; | |||||
} | |||||
/// Iterator | |||||
StringMap<std::pair<uint64_t, unsigned>> &modulePaths() { | |||||
return ModulePathStringTable; | return ModulePathStringTable; | ||||
} | } | ||||
/// Get the module ID recorded for the given module path. | /// Get the module ID recorded for the given module path. | ||||
uint64_t getModuleId(const StringRef ModPath) const { | uint64_t getModuleId(const StringRef ModPath) const { | ||||
return ModulePathStringTable.lookup(ModPath); | return ModulePathStringTable.lookup(ModPath).first; | ||||
} | |||||
/// Get the module ID recorded for the given module path. | |||||
unsigned getModuleHash(const StringRef ModPath) const { | |||||
return ModulePathStringTable.lookup(ModPath).second; | |||||
} | } | ||||
/// Add the given per-module index into this module index/summary, | /// Add the given per-module index into this module index/summary, | ||||
/// assigning it the given module ID. Each module merged in should have | /// assigning it the given module ID. Each module merged in should have | ||||
/// a unique ID, necessary for consistent renaming of promoted | /// a unique ID, necessary for consistent renaming of promoted | ||||
/// static (local) variables. | /// static (local) variables. | ||||
void mergeFrom(std::unique_ptr<FunctionInfoIndex> Other, | void mergeFrom(std::unique_ptr<FunctionInfoIndex> Other, | ||||
uint64_t NextModuleId); | uint64_t NextModuleId); | ||||
/// Convenience method for creating a promoted global name | /// Convenience method for creating a promoted global name | ||||
/// for the given value name of a local, and its original module's ID. | /// for the given value name of a local, and its original module's ID. | ||||
static std::string getGlobalNameForLocal(StringRef Name, uint64_t ModId) { | static std::string getGlobalNameForLocal(StringRef Name, uint64_t ModId) { | ||||
SmallString<256> NewName(Name); | SmallString<256> NewName(Name); | ||||
NewName += ".llvm."; | NewName += ".llvm."; | ||||
raw_svector_ostream(NewName) << ModId; | raw_svector_ostream(NewName) << ModId; | ||||
return NewName.str(); | return NewName.str(); | ||||
} | } | ||||
/// Add a new module path, mapped to the given module Id, and return StringRef | /// Add a new module path, mapped to the given module Id, and return StringRef | ||||
/// owned by string table map. | /// owned by string table map. | ||||
StringRef addModulePath(StringRef ModPath, uint64_t ModId) { | StringRef addModulePath(StringRef ModPath, uint64_t ModId, | ||||
return ModulePathStringTable.insert(std::make_pair(ModPath, ModId)) | unsigned Hash = 0) { | ||||
return ModulePathStringTable.insert(std::make_pair( | |||||
ModPath, std::make_pair(ModId, 0))) | |||||
.first->first(); | .first->first(); | ||||
} | } | ||||
/// Check if the given Module has any functions available for exporting | /// Check if the given Module has any functions available for exporting | ||||
/// in the index. We consider any module present in the ModulePathStringTable | /// in the index. We consider any module present in the ModulePathStringTable | ||||
/// to have exported functions. | /// to have exported functions. | ||||
bool hasExportedFunctions(const Module &M) const { | bool hasExportedFunctions(const Module &M) const { | ||||
return ModulePathStringTable.count(M.getModuleIdentifier()); | return ModulePathStringTable.count(M.getModuleIdentifier()); | ||||
Show All 13 Lines |