[PATCH] D44149: [WebAssembly] Use StringSaver to retain ownership of ctor function body. NFC
Rui Ueyama via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 6 12:58:32 PST 2018
ruiu added inline comments.
================
Comment at: wasm/Writer.cpp:877
SyntheticFunction *F = make<SyntheticFunction>(
- *Sig, std::move(FunctionBody), WasmSym::CallCtors->getName());
+ *Sig, toArrayRef(Saver.save(FunctionBody)),
+ WasmSym::CallCtors->getName());
----------------
I don't think the amount of data we need to copy is large, so it is presumably OK, and I'm not obsessed with micro-optimization, but here we make a copy of std::string here and then immediately discard the original string at the end of the scope. So this makes a redundant copy of a string.
There is a way to avoid unnecessary copying. If you allocate std::string by `make<std::string>()`, then its body will have the same lifetime as the entire linking process.
Repository:
rLLD LLVM Linker
https://reviews.llvm.org/D44149
More information about the llvm-commits
mailing list