[AVX] Make VarInit Unique

Make sure VarInits are unique and created only once.

llvm-svn: 136497
diff --git a/llvm/utils/TableGen/Record.cpp b/llvm/utils/TableGen/Record.cpp
index a6b5c4b..68f9f2a 100644
--- a/llvm/utils/TableGen/Record.cpp
+++ b/llvm/utils/TableGen/Record.cpp
@@ -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,