[PATCH] D41893: [WebAssembly] Create synthetic __wasm_call_ctors function
Sam Clegg via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 9 17:56:17 PST 2018
sbc100 added inline comments.
================
Comment at: wasm/Driver.cpp:285
+ Config->CtorSymbol = Symtab->addDefinedFunction(
+ Config->CtorFunction, &Signature, WASM_SYMBOL_VISIBILITY_HIDDEN);
Config->StackPointerSymbol = Symtab->addDefinedGlobal("__stack_pointer");
----------------
ruiu wrote:
> Since no one sets Config->CtorFunction, I'd inline it and directly write "__wasm_call_ctors" here.
I was going to make this configurable via flag, but maybe I'll wait until we really need that before adding it.
================
Comment at: wasm/InputChunks.h:137
+class SyntheticFunction : public InputFunction {
+public:
----------------
ruiu wrote:
> I'd try to make the class hierarchy as shallow as possible. Do you think inheriting InputFunction is better than inheriting InputChunk?
Right now the CodeSection is built from a vector of `InputFunction *` so this is needed. I think I tried refactoring and failed, but I can try again.
================
Comment at: wasm/Writer.cpp:689
+
+void Writer::createCtorFunction() {
+ uint32_t FunctionIndex = ImportedFunctions.size() + DefinedFunctions.size();
----------------
ruiu wrote:
> Are you going to do the same thing for .dtors in a follow-up patch?
>
> Please write a comment to describe this function creates a linker-synthesized function that calls initialization functions, which in turn be called by the startup routine on process startup.
llvm already lowers all the dtors to ctors that call __cxa_atexit.
See: https://reviews.llvm.org/D41211
Repository:
rLLD LLVM Linker
https://reviews.llvm.org/D41893
More information about the llvm-commits
mailing list