[mlir][spirv] Fix extended insts deserialization generation
authorKonrad Dobros <konrad.dobros@intel.com>
Tue, 6 Oct 2020 17:33:41 +0000 (13:33 -0400)
committerLei Zhang <antiagainst@google.com>
Tue, 6 Oct 2020 17:34:58 +0000 (13:34 -0400)
This change replaces container used for storing temporary
strings for generated code to std::list.
SmallVector may reallocate internal data, which will invalidate
references when more than one extended instruction set is
generated.

Reviewed By: mravishankar, antiagainst

Differential Revision: https://reviews.llvm.org/D88626

mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp

index 21f7349..442afc1 100644 (file)
@@ -27,6 +27,8 @@
 #include "llvm/TableGen/Record.h"
 #include "llvm/TableGen/TableGenBackend.h"
 
+#include <list>
+
 using llvm::ArrayRef;
 using llvm::formatv;
 using llvm::raw_ostream;
@@ -1031,7 +1033,7 @@ emitExtendedSetDeserializationDispatch(const RecordKeeper &recordKeeper,
   // raw_string_ostream needs a string&, use a vector to store all the string
   // that are captured by reference within raw_string_ostream.
   StringMap<raw_string_ostream> extensionSets;
-  SmallVector<std::string, 1> extensionSetNames;
+  std::list<std::string> extensionSetNames;
 
   initExtendedSetDeserializationDispatch(extensionSetName, instructionID, words,
                                          os);