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

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


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

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

Make sure VarBitInits 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=136498&r1=136497&r2=136498&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/Record.cpp (original)
+++ llvm/trunk/utils/TableGen/Record.cpp Fri Jul 29 14:07:22 2011
@@ -1389,7 +1389,16 @@
 }
 
 const VarBitInit *VarBitInit::get(const TypedInit *T, unsigned B) {
-  return new VarBitInit(T, B);
+  typedef std::pair<const TypedInit *, unsigned> Key;
+  typedef DenseMap<Key, VarBitInit *> Pool;
+
+  static Pool ThePool;
+
+  Key TheKey(std::make_pair(T, B));
+
+  VarBitInit *&I = ThePool[TheKey];
+  if (!I) I = new VarBitInit(T, B);
+  return I;
 }
 
 std::string VarBitInit::getAsString() const {





More information about the llvm-commits mailing list