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

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


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

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

Make sure FieldInits are unique and created only once.

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=136500&r1=136499&r2=136500&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/Record.cpp (original)
+++ llvm/trunk/utils/TableGen/Record.cpp Fri Jul 29 14:07:24 2011
@@ -1475,7 +1475,15 @@
 }
 
 const FieldInit *FieldInit::get(const Init *R, const std::string &FN) {
-  return new FieldInit(R, FN);
+  typedef std::pair<const Init *, TableGenStringKey> Key;
+  typedef DenseMap<Key, FieldInit *> Pool;
+  static Pool ThePool;  
+
+  Key TheKey(std::make_pair(R, FN));
+
+  FieldInit *&I = ThePool[TheKey];
+  if (!I) I = new FieldInit(R, FN);
+  return I;
 }
 
 const Init *FieldInit::resolveBitReference(Record &R, const RecordVal *RV,





More information about the llvm-commits mailing list