[AVX] Make VarListElementInit Unique

Make sure VarListElementInits are unique and created only once.

llvm-svn: 136499
This commit is contained in:
David Greene 2011-07-29 19:07:23 +00:00
parent 9aa82842c7
commit 7f501e8b4d
1 changed files with 10 additions and 1 deletions

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 {