[PATCH] D37834: [WebAssembly] Use a seperate wasm data segment for each global symbol
Derek Schuff via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 14 11:05:06 PDT 2017
dschuff added inline comments.
================
Comment at: lib/MC/WasmObjectWriter.cpp:99
+struct WasmDataSegment {
+ MCSectionWasm *Section;
----------------
Might be worth putting a comment here (or somewhere) mentioning that because wasm binaries have only one real data section (which is allocated/mapped over the whole memory), each segment has to track its "virtual" section/subsection/whatever we want to call it.
================
Comment at: lib/MC/WasmObjectWriter.cpp:102
+ uint32_t Offset;
+ SmallVector<char, 0> Data;
+};
----------------
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>.
================
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,
----------------
APIs should just take `SmallVectorImpl` parameters, and then any size SmallVector can be used as an argument.
https://reviews.llvm.org/D37834
More information about the llvm-commits
mailing list