[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
This commit is contained in:
David Greene 2011-07-29 19:07:23 +00:00
parent aa839b8fa3
commit 08f71e3e74

View File

@ -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<const TypedInit *, unsigned> Key;
typedef DenseMap<Key, VarListElementInit *> 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 {