Index: include/llvm/IR/GlobalValue.h =================================================================== --- include/llvm/IR/GlobalValue.h +++ include/llvm/IR/GlobalValue.h @@ -316,10 +316,16 @@ GlobalValue::LinkageTypes Linkage, StringRef FileName); + std::string getGlobalIdentifier(); + /// Return a 64-bit global unique ID constructed from global value name /// (i.e. returned by getGlobalIdentifier). static uint64_t getGUID(StringRef GlobalName) { return MD5Hash(GlobalName); } + uint64_t getGUID() { + return getGUID(getGlobalIdentifier()); + } + /// @name Materialization /// Materialization is used to construct functions only as they're needed. /// This Index: lib/IR/Globals.cpp =================================================================== --- lib/IR/Globals.cpp +++ lib/IR/Globals.cpp @@ -123,6 +123,10 @@ return NewName; } +std::string GlobalValue::getGlobalIdentifier() { + return getGlobalIdentifier(getName(), getLinkage(), getParent()->getSourceFileName()); +} + const char *GlobalValue::getSection() const { if (auto *GA = dyn_cast(this)) { // In general we cannot compute this at the IR level, but we try.