Index: llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolSerializer.h =================================================================== --- llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolSerializer.h +++ llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolSerializer.h @@ -28,7 +28,10 @@ class SymbolSerializer : public SymbolVisitorCallbacks { BumpPtrAllocator &Storage; - std::vector RecordBuffer; + // Since this is a fixed size buffer, use a stack allocated buffer. This + // yields measurable performance increase over the repeated heap allocations + // when serializing many independent records via writeOneSymbol. + std::array RecordBuffer; MutableBinaryByteStream Stream; BinaryStreamWriter Writer; SymbolRecordMapping Mapping; Index: llvm/trunk/lib/DebugInfo/CodeView/SymbolSerializer.cpp =================================================================== --- llvm/trunk/lib/DebugInfo/CodeView/SymbolSerializer.cpp +++ llvm/trunk/lib/DebugInfo/CodeView/SymbolSerializer.cpp @@ -21,8 +21,7 @@ SymbolSerializer::SymbolSerializer(BumpPtrAllocator &Allocator, CodeViewContainer Container) - : Storage(Allocator), RecordBuffer(MaxRecordLength), - Stream(RecordBuffer, support::little), Writer(Stream), + : Storage(Allocator), Stream(RecordBuffer, support::little), Writer(Stream), Mapping(Writer, Container) {} Error SymbolSerializer::visitSymbolBegin(CVSymbol &Record) {