[PATCH] D16560: Hash DISubprogram Metadata using pointer for MDString argument instead of value (NFC)

Mehdi AMINI via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 25 15:06:48 PST 2016


joker.eph created this revision.
joker.eph added a reviewer: dexonsmith.
joker.eph added a subscriber: llvm-commits.

MDString are uniqued in the Context on creation, hashing the
pointer is less expensive than hashing the String itself.

http://reviews.llvm.org/D16560

Files:
  lib/IR/DebugInfoMetadata.cpp
  lib/IR/LLVMContextImpl.h

Index: lib/IR/LLVMContextImpl.h
===================================================================
--- lib/IR/LLVMContextImpl.h
+++ lib/IR/LLVMContextImpl.h
@@ -460,8 +460,8 @@
 
 template <> struct MDNodeKeyImpl<DISubprogram> {
   Metadata *Scope;
-  StringRef Name;
-  StringRef LinkageName;
+  MDString *Name;
+  MDString *LinkageName;
   Metadata *File;
   unsigned Line;
   Metadata *Type;
@@ -477,7 +477,7 @@
   Metadata *Declaration;
   Metadata *Variables;
 
-  MDNodeKeyImpl(Metadata *Scope, StringRef Name, StringRef LinkageName,
+  MDNodeKeyImpl(Metadata *Scope, MDString *Name, MDString *LinkageName,
                 Metadata *File, unsigned Line, Metadata *Type,
                 bool IsLocalToUnit, bool IsDefinition, unsigned ScopeLine,
                 Metadata *ContainingType, unsigned Virtuality,
@@ -492,8 +492,8 @@
         TemplateParams(TemplateParams), Declaration(Declaration),
         Variables(Variables) {}
   MDNodeKeyImpl(const DISubprogram *N)
-      : Scope(N->getRawScope()), Name(N->getName()),
-        LinkageName(N->getLinkageName()), File(N->getRawFile()),
+      : Scope(N->getRawScope()), Name(N->getRawName()),
+        LinkageName(N->getRawLinkageName()), File(N->getRawFile()),
         Line(N->getLine()), Type(N->getRawType()),
         IsLocalToUnit(N->isLocalToUnit()), IsDefinition(N->isDefinition()),
         ScopeLine(N->getScopeLine()), ContainingType(N->getRawContainingType()),
@@ -503,8 +503,8 @@
         Declaration(N->getRawDeclaration()), Variables(N->getRawVariables()) {}
 
   bool isKeyOf(const DISubprogram *RHS) const {
-    return Scope == RHS->getRawScope() && Name == RHS->getName() &&
-           LinkageName == RHS->getLinkageName() && File == RHS->getRawFile() &&
+    return Scope == RHS->getRawScope() && Name == RHS->getRawName() &&
+           LinkageName == RHS->getRawLinkageName() && File == RHS->getRawFile() &&
            Line == RHS->getLine() && Type == RHS->getRawType() &&
            IsLocalToUnit == RHS->isLocalToUnit() &&
            IsDefinition == RHS->isDefinition() &&
Index: lib/IR/DebugInfoMetadata.cpp
===================================================================
--- lib/IR/DebugInfoMetadata.cpp
+++ lib/IR/DebugInfoMetadata.cpp
@@ -348,7 +348,7 @@
   assert(isCanonical(Name) && "Expected canonical MDString");
   assert(isCanonical(LinkageName) && "Expected canonical MDString");
   DEFINE_GETIMPL_LOOKUP(DISubprogram,
-                        (Scope, getString(Name), getString(LinkageName), File,
+                        (Scope, Name, LinkageName, File,
                          Line, Type, IsLocalToUnit, IsDefinition, ScopeLine,
                          ContainingType, Virtuality, VirtualIndex, Flags,
                          IsOptimized, TemplateParams, Declaration, Variables));


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16560.45921.patch
Type: text/x-patch
Size: 2798 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160125/d8ab0b40/attachment.bin>


More information about the llvm-commits mailing list