[PATCH] D18339: Add GUID/getGlobalIdentifier() non-static API to global value

Mehdi AMINI via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 21 15:38:25 PDT 2016


joker.eph updated this revision to Diff 51240.
joker.eph added a comment.

clang-format


http://reviews.llvm.org/D18339

Files:
  include/llvm/IR/GlobalValue.h
  lib/IR/Globals.cpp

Index: lib/IR/Globals.cpp
===================================================================
--- lib/IR/Globals.cpp
+++ lib/IR/Globals.cpp
@@ -123,6 +123,11 @@
   return NewName;
 }
 
+std::string GlobalValue::getGlobalIdentifier() {
+  return getGlobalIdentifier(getName(), getLinkage(),
+                             getParent()->getSourceFileName());
+}
+
 const char *GlobalValue::getSection() const {
   if (auto *GA = dyn_cast<GlobalAlias>(this)) {
     // In general we cannot compute this at the IR level, but we try.
Index: include/llvm/IR/GlobalValue.h
===================================================================
--- include/llvm/IR/GlobalValue.h
+++ include/llvm/IR/GlobalValue.h
@@ -316,10 +316,14 @@
                                          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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18339.51240.patch
Type: text/x-patch
Size: 1295 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160321/d9695b50/attachment.bin>


More information about the llvm-commits mailing list