[PATCH] D41893: [WebAssembly] Create synthetic __wasm_call_ctors function

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 9 17:49:42 PST 2018


ruiu 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");
----------------
Since no one sets Config->CtorFunction, I'd inline it and directly write "__wasm_call_ctors" here.


================
Comment at: wasm/InputChunks.h:137
 
+class SyntheticFunction : public InputFunction {
+public:
----------------
I'd try to make the class hierarchy as shallow as possible. Do you think inheriting InputFunction is better than inheriting InputChunk?


================
Comment at: wasm/Writer.cpp:689
+
+void Writer::createCtorFunction() {
+  uint32_t FunctionIndex = ImportedFunctions.size() + DefinedFunctions.size();
----------------
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.


================
Comment at: wasm/Writer.cpp:708
+
+void Writer::calculateInitFunctions() {
+  for (ObjFile *File : Symtab->ObjectFiles) {
----------------
Please add a comment.


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D41893





More information about the llvm-commits mailing list