mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-01 01:31:26 +00:00
[WebAssembly] Use StringSaver to retain ownership of ctor function body. NFC
Differential Revision: https://reviews.llvm.org/D44149 llvm-svn: 326885
This commit is contained in:
parent
19f531d31e
commit
8269f37ce6
@ -24,7 +24,6 @@
|
|||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include "InputFiles.h"
|
#include "InputFiles.h"
|
||||||
#include "lld/Common/ErrorHandler.h"
|
#include "lld/Common/ErrorHandler.h"
|
||||||
#include "lld/Common/Strings.h"
|
|
||||||
#include "llvm/Object/Wasm.h"
|
#include "llvm/Object/Wasm.h"
|
||||||
|
|
||||||
using llvm::object::WasmSegment;
|
using llvm::object::WasmSegment;
|
||||||
@ -152,16 +151,18 @@ protected:
|
|||||||
|
|
||||||
class SyntheticFunction : public InputFunction {
|
class SyntheticFunction : public InputFunction {
|
||||||
public:
|
public:
|
||||||
SyntheticFunction(const WasmSignature &S, std::string Body, StringRef Name)
|
SyntheticFunction(const WasmSignature &S, ArrayRef<uint8_t> Body,
|
||||||
: InputFunction(S, nullptr, nullptr), Name(Name), Body(std::move(Body)) {}
|
StringRef Name)
|
||||||
|
: InputFunction(S, nullptr, nullptr), Name(Name), Body(Body) {}
|
||||||
|
|
||||||
StringRef getName() const override { return Name; }
|
StringRef getName() const override { return Name; }
|
||||||
|
StringRef getComdat() const override { return StringRef(); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
ArrayRef<uint8_t> data() const override { return toArrayRef(Body); }
|
ArrayRef<uint8_t> data() const override { return Body; }
|
||||||
|
|
||||||
StringRef Name;
|
StringRef Name;
|
||||||
std::string Body;
|
ArrayRef<uint8_t> Body;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace wasm
|
} // namespace wasm
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#include "WriterUtils.h"
|
#include "WriterUtils.h"
|
||||||
#include "lld/Common/ErrorHandler.h"
|
#include "lld/Common/ErrorHandler.h"
|
||||||
#include "lld/Common/Memory.h"
|
#include "lld/Common/Memory.h"
|
||||||
|
#include "lld/Common/Strings.h"
|
||||||
#include "lld/Common/Threads.h"
|
#include "lld/Common/Threads.h"
|
||||||
#include "llvm/ADT/DenseSet.h"
|
#include "llvm/ADT/DenseSet.h"
|
||||||
#include "llvm/BinaryFormat/Wasm.h"
|
#include "llvm/BinaryFormat/Wasm.h"
|
||||||
@ -873,7 +874,8 @@ void Writer::createCtorFunction() {
|
|||||||
|
|
||||||
const WasmSignature *Sig = WasmSym::CallCtors->getFunctionType();
|
const WasmSignature *Sig = WasmSym::CallCtors->getFunctionType();
|
||||||
SyntheticFunction *F = make<SyntheticFunction>(
|
SyntheticFunction *F = make<SyntheticFunction>(
|
||||||
*Sig, std::move(FunctionBody), WasmSym::CallCtors->getName());
|
*Sig, toArrayRef(Saver.save(FunctionBody)),
|
||||||
|
WasmSym::CallCtors->getName());
|
||||||
|
|
||||||
F->setOutputIndex(FunctionIndex);
|
F->setOutputIndex(FunctionIndex);
|
||||||
F->Live = true;
|
F->Live = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user