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

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


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

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

Make sure VarInits 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=136497&r1=136496&r2=136497&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/Record.cpp (original)
+++ llvm/trunk/utils/TableGen/Record.cpp Fri Jul 29 14:07:21 2011
@@ -1294,7 +1294,15 @@
 
 
 const VarInit *VarInit::get(const std::string &VN, RecTy *T) {
-  return new VarInit(VN, T);
+  typedef std::pair<RecTy *, TableGenStringKey> Key;
+  typedef DenseMap<Key, VarInit *> Pool;
+  static Pool ThePool;
+
+  Key TheKey(std::make_pair(T, VN));
+
+  VarInit *&I = ThePool[TheKey];
+  if (!I) I = new VarInit(VN, T);
+  return I;
 }
 
 const Init *VarInit::resolveBitReference(Record &R, const RecordVal *IRV,





More information about the llvm-commits mailing list