From: David Greene Date: Fri, 29 Jul 2011 19:07:21 +0000 (+0000) Subject: [AVX] Make VarInit Unique X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=e0be0e361a8306a7106ccab27dcf0140a748bfbc;p=oota-llvm.git [AVX] Make VarInit Unique Make sure VarInits are unique and created only once. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136497 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/utils/TableGen/Record.cpp b/utils/TableGen/Record.cpp index a6b5c4b884d..68f9f2a2471 100644 --- a/utils/TableGen/Record.cpp +++ b/utils/TableGen/Record.cpp @@ -1294,7 +1294,15 @@ TypedInit::convertInitListSlice(const std::vector &Elements) const { const VarInit *VarInit::get(const std::string &VN, RecTy *T) { - return new VarInit(VN, T); + typedef std::pair Key; + typedef DenseMap 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,