diff --git a/utils/TableGen/Record.cpp b/utils/TableGen/Record.cpp index 54edfe5ea8f..ee5db4713dc 100644 --- a/utils/TableGen/Record.cpp +++ b/utils/TableGen/Record.cpp @@ -21,6 +21,7 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringExtras.h" +#include "llvm/ADT/StringMap.h" using namespace llvm; @@ -565,7 +566,12 @@ IntInit::convertInitializerBitRange(const std::vector &Bits) const { } const StringInit *StringInit::get(const std::string &V) { - return new StringInit(V); + typedef StringMap Pool; + static Pool ThePool; + + StringInit *&I = ThePool[V]; + if (!I) I = new StringInit(V); + return I; } const CodeInit *CodeInit::get(const std::string &V) {