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