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

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


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

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

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





More information about the llvm-commits mailing list