[PATCH] D67768: [DebugInfo] Add interface for pre-calculating the size of emitted DWARF

David Stenberg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 14 13:25:30 PDT 2019


dstenb marked an inline comment as done.
dstenb added inline comments.


================
Comment at: llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h:337
+    SmallString<32> Bytes;
+    SmallVector<std::string, 8> Comments;
+    BufferByteStreamer BS;
----------------
aprantl wrote:
> A SmallVector<std::string> doesn't seem to make that much sense, since strings are always heap-allocated. Either this should be a vector<string> or a SmallVector<SmallString>.
Good point!

I made this a `SmallVector<std::string>` as BufferByteStreamer expects that, so that is what is already used in DebugLocStream:

```
  SmallString<256> DWARFBytes;    
  SmallVector<std::string, 32> Comments;    
```

However, when building a RelWithDebInfo clang-8 build, the average size of that Comments vector was actually around ~10000, so it seems that a small vector is not beneficial here (in addition to the issue with "allocating" std::strings on the stack as you point out). The size of DWARFBytes is the same as Comments, so perhaps they both should be std::vectors. If so, I'll do that change as a preparatory NFC commit.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67768/new/

https://reviews.llvm.org/D67768





More information about the llvm-commits mailing list