[PATCH] D44149: [WebAssembly] Use StringSaver to retain ownership of ctor function body. NFC
Nicholas Wilson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 6 06:25:46 PST 2018
ncw created this revision.
ncw added reviewers: ruiu, sbc100.
Herald added subscribers: llvm-commits, sunfish, aheejin, jgravelle-google, dschuff, jfb.
Notes:
This makes it easier to create other synthetic functions, which don't need the SyntheticFunction instance to own the body as a std::string.
I should have done this as part of https://reviews.llvm.org/D43933, but at the time I thought what I was doing was better... oh well.
Repository:
rLLD LLVM Linker
https://reviews.llvm.org/D44149
Files:
wasm/InputChunks.h
wasm/Writer.cpp
Index: wasm/Writer.cpp
===================================================================
--- wasm/Writer.cpp
+++ wasm/Writer.cpp
@@ -17,6 +17,7 @@
#include "WriterUtils.h"
#include "lld/Common/ErrorHandler.h"
#include "lld/Common/Memory.h"
+#include "lld/Common/Strings.h"
#include "lld/Common/Threads.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/BinaryFormat/Wasm.h"
@@ -873,7 +874,8 @@
const WasmSignature *Sig = WasmSym::CallCtors->getFunctionType();
SyntheticFunction *F = make<SyntheticFunction>(
- *Sig, std::move(FunctionBody), WasmSym::CallCtors->getName());
+ *Sig, toArrayRef(Saver.save(FunctionBody)),
+ WasmSym::CallCtors->getName());
F->setOutputIndex(FunctionIndex);
F->Live = true;
Index: wasm/InputChunks.h
===================================================================
--- wasm/InputChunks.h
+++ wasm/InputChunks.h
@@ -24,7 +24,6 @@
#include "Config.h"
#include "InputFiles.h"
#include "lld/Common/ErrorHandler.h"
-#include "lld/Common/Strings.h"
#include "llvm/Object/Wasm.h"
using llvm::object::WasmSegment;
@@ -152,16 +151,18 @@
class SyntheticFunction : public InputFunction {
public:
- SyntheticFunction(const WasmSignature &S, std::string Body, StringRef Name)
- : InputFunction(S, nullptr, nullptr), Name(Name), Body(std::move(Body)) {}
+ SyntheticFunction(const WasmSignature &S, ArrayRef<uint8_t> Body,
+ StringRef Name)
+ : InputFunction(S, nullptr, nullptr), Name(Name), Body(Body) {}
StringRef getName() const override { return Name; }
+ StringRef getComdat() const override { return StringRef(); }
protected:
- ArrayRef<uint8_t> data() const override { return toArrayRef(Body); }
+ ArrayRef<uint8_t> data() const override { return Body; }
StringRef Name;
- std::string Body;
+ ArrayRef<uint8_t> Body;
};
} // namespace wasm
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44149.137185.patch
Type: text/x-patch
Size: 1866 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180306/a837f73e/attachment.bin>
More information about the llvm-commits
mailing list