From: David Greene Date: Fri, 29 Jul 2011 19:07:15 +0000 (+0000) Subject: [AVX] Make CodeInit Unique X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=637b4ffa01f42a6df598d4fc367d645a600128e1;p=oota-llvm.git [AVX] Make CodeInit Unique Use a StringMap to ensure CodeInits are unique and created only once. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136492 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/utils/TableGen/Record.cpp b/utils/TableGen/Record.cpp index ee5db4713dc..133a1581c0e 100644 --- a/utils/TableGen/Record.cpp +++ b/utils/TableGen/Record.cpp @@ -575,7 +575,12 @@ const StringInit *StringInit::get(const std::string &V) { } const CodeInit *CodeInit::get(const std::string &V) { - return new CodeInit(V); + typedef StringMap Pool; + static Pool ThePool; + + CodeInit *&I = ThePool[V]; + if (!I) I = new CodeInit(V); + return I; } const ListInit *ListInit::get(ArrayRef Range, RecTy *EltTy) {