[llvm] r264382 - Add GUID/getGlobalIdentifier() non-static API to global value

Mehdi Amini via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 24 22:57:43 PDT 2016


Author: mehdi_amini
Date: Fri Mar 25 00:57:41 2016
New Revision: 264382

URL: http://llvm.org/viewvc/llvm-project?rev=264382&view=rev
Log:
Add GUID/getGlobalIdentifier() non-static API to global value

Summary:
These are just helpers calling their static counter part to
simplify client code.

Reviewers: tejohnson

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D18339

From: Mehdi Amini <mehdi.amini at apple.com>

Modified:
    llvm/trunk/include/llvm/IR/GlobalValue.h
    llvm/trunk/lib/IR/Globals.cpp

Modified: llvm/trunk/include/llvm/IR/GlobalValue.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/GlobalValue.h?rev=264382&r1=264381&r2=264382&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/GlobalValue.h (original)
+++ llvm/trunk/include/llvm/IR/GlobalValue.h Fri Mar 25 00:57:41 2016
@@ -316,10 +316,18 @@ public:
                                          GlobalValue::LinkageTypes Linkage,
                                          StringRef FileName);
 
+  /// Return the modified name for this global value suitable to be
+  /// used as the key for a global lookup (e.g. profile or ThinLTO).
+  std::string getGlobalIdentifier();
+
   /// Return a 64-bit global unique ID constructed from global value name
-  /// (i.e. returned by getGlobalIdentifier).
+  /// (i.e. returned by getGlobalIdentifier()).
   static uint64_t getGUID(StringRef GlobalName) { return MD5Hash(GlobalName); }
 
+  /// Return a 64-bit global unique ID constructed from global value name
+  /// (i.e. returned by getGlobalIdentifier()).
+  uint64_t getGUID() { return getGUID(getGlobalIdentifier()); }
+
   /// @name Materialization
   /// Materialization is used to construct functions only as they're needed.
   /// This

Modified: llvm/trunk/lib/IR/Globals.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Globals.cpp?rev=264382&r1=264381&r2=264382&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Globals.cpp (original)
+++ llvm/trunk/lib/IR/Globals.cpp Fri Mar 25 00:57:41 2016
@@ -123,6 +123,11 @@ std::string GlobalValue::getGlobalIdenti
   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.




More information about the llvm-commits mailing list