[llvm-commits] [llvm] r136491 - /llvm/trunk/utils/TableGen/Record.cpp

David Greene greened at obbligato.org
Fri Jul 29 12:07:14 PDT 2011


Author: greened
Date: Fri Jul 29 14:07:14 2011
New Revision: 136491

URL: http://llvm.org/viewvc/llvm-project?rev=136491&view=rev
Log:
[AVX] Make StringInit Unique

Use a StringMap to ensure the StringInits are unique.  This is
especially important for AVX where we will have many smallish
strings representing instruction prefixes, suffixes and the like.

Modified:
    llvm/trunk/utils/TableGen/Record.cpp

Modified: llvm/trunk/utils/TableGen/Record.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/Record.cpp?rev=136491&r1=136490&r2=136491&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/Record.cpp (original)
+++ llvm/trunk/utils/TableGen/Record.cpp Fri Jul 29 14:07:14 2011
@@ -21,6 +21,7 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringMap.h"
 
 using namespace llvm;
 
@@ -565,7 +566,12 @@
 }
 
 const StringInit *StringInit::get(const std::string &V) {
-  return new StringInit(V);
+  typedef StringMap<StringInit *> Pool;
+  static Pool ThePool;
+
+  StringInit *&I = ThePool[V];
+  if (!I) I = new StringInit(V);
+  return I;
 }
 
 const CodeInit *CodeInit::get(const std::string &V) {





More information about the llvm-commits mailing list