[PATCH] D37834: [WebAssembly] Use a seperate wasm data segment for each global symbol

Sam Clegg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 14 15:27:59 PDT 2017


sbc100 added inline comments.


================
Comment at: lib/MC/WasmObjectWriter.cpp:102
+  uint32_t Offset;
+  SmallVector<char, 0> Data;
+};
----------------
dschuff wrote:
> IIRC A SmallVector with size 0 is no better (worse actually) than a std::vector. We could just use std::vector, or I guess if we really do want one segment per LLVM global, then 4 will be the most common size, so we could just use a Smallvector<4>.
Hmm... look like this was inherited from the existing code.  I'll change it to 4 for now and revisit in a followup.


================
Comment at: lib/MC/WasmObjectWriter.cpp:271
                         const SmallVector<WasmFunction, 4> &Functions);
-  uint64_t
-  writeDataSection(const SmallVector<char, 0> &DataBytes);
+  void writeDataSection(const SmallVector<WasmDataSegment, 4> &Segments);
   void writeNameSection(const SmallVector<WasmFunction, 4> &Functions,
----------------
dschuff wrote:
> APIs should just take `SmallVectorImpl` parameters, and then any size SmallVector can be used as an argument.
Actually it looks like these can take ArrayRef?  Would that make sense?  If its OK with you I'll make a separate change for that... maybe I can land that one first?


https://reviews.llvm.org/D37834





More information about the llvm-commits mailing list