From 7f501e8b4d7c0637f30132ce6d5e52d10f6f4700 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. llvm-svn: 136499 --- llvm/utils/TableGen/Record.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/llvm/utils/TableGen/Record.cpp b/llvm/utils/TableGen/Record.cpp index 3a022fc151e4..89de3edfd192 100644 --- a/llvm/utils/TableGen/Record.cpp +++ b/llvm/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 {