From: David Greene Date: Fri, 29 Jul 2011 19:07:23 +0000 (+0000) Subject: [AVX] Make VarListElementInit Unique X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=08f71e3e7437359f94fed3207bc64d8cc54ef3f3;p=oota-llvm.git [AVX] Make VarListElementInit Unique Make sure VarListElementInits are unique and created only once. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136499 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/utils/TableGen/Record.cpp b/utils/TableGen/Record.cpp index 3a022fc151e..89de3edfd19 100644 --- a/utils/TableGen/Record.cpp +++ b/utils/TableGen/Record.cpp @@ -1414,7 +1414,16 @@ const Init *VarBitInit::resolveReferences(Record &R, const VarListElementInit *VarListElementInit::get(const TypedInit *T, unsigned E) { - return new VarListElementInit(T, E); + typedef std::pair Key; + typedef DenseMap 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 {