[PATCH] D36940: Replace std::vector to std::array in SymbolSerializer

Alex Telishev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 20 13:43:00 PDT 2017


alex.telishev created this revision.
Herald added a subscriber: hiraditya.

`SymbolSerializer::writeOneSymbol` function is called very often and creates a temporary `SymbolSerializer`
`RecordBuffer` is always created with a constant size so it's much faster to allocate this memory on the stack instead of heap


https://reviews.llvm.org/D36940

Files:
  llvm/include/llvm/DebugInfo/CodeView/SymbolSerializer.h
  llvm/lib/DebugInfo/CodeView/SymbolSerializer.cpp


Index: llvm/lib/DebugInfo/CodeView/SymbolSerializer.cpp
===================================================================
--- llvm/lib/DebugInfo/CodeView/SymbolSerializer.cpp
+++ llvm/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) {
Index: llvm/include/llvm/DebugInfo/CodeView/SymbolSerializer.h
===================================================================
--- llvm/include/llvm/DebugInfo/CodeView/SymbolSerializer.h
+++ llvm/include/llvm/DebugInfo/CodeView/SymbolSerializer.h
@@ -22,13 +22,14 @@
 #include "llvm/Support/Error.h"
 #include <cstdint>
 #include <vector>
+#include <array>
 
 namespace llvm {
 namespace codeview {
 
 class SymbolSerializer : public SymbolVisitorCallbacks {
   BumpPtrAllocator &Storage;
-  std::vector<uint8_t> RecordBuffer;
+  std::array<uint8_t, llvm::codeview::MaxRecordLength> RecordBuffer;
   MutableBinaryByteStream Stream;
   BinaryStreamWriter Writer;
   SymbolRecordMapping Mapping;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36940.111903.patch
Type: text/x-patch
Size: 1381 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170820/47f4e6a3/attachment.bin>


More information about the llvm-commits mailing list