From 08f71e3e7437359f94fed3207bc64d8cc54ef3f3 Mon Sep 17 00:00:00 2001 From: David Greene Date: Fri, 29 Jul 2011 19:07:23 +0000 Subject: [PATCH] [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 --- utils/TableGen/Record.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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 { -- 2.34.1