[PATCH] D77192: [WebAssembly] EmscriptenEHSjLj: Make __invoke_ functions as imported

Sam Clegg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 31 22:00:15 PDT 2020


sbc100 created this revision.
Herald added subscribers: llvm-commits, sunfish, aheejin, hiraditya, jgravelle-google, dschuff.
Herald added a project: LLVM.
sbc100 added reviewers: aheejin, jgravelle-google.

This means the linker will be expecting them be undefined at link
time an will generate imports from the `env` module rather than
reporting undefined externals.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77192

Files:
  llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp


Index: llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
===================================================================
--- llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
@@ -469,6 +469,17 @@
                                         CalleeFTy->isVarArg());
   Function *F =
       Function::Create(FTy, GlobalValue::ExternalLinkage, "__invoke_" + Sig, M);
+  llvm::AttrBuilder B;
+  // Tell the linker that this function is expected to be imported from the
+  // 'env' module.
+  if (!F->hasFnAttribute("wasm-import-module")) {
+    B.addAttribute("wasm-import-module", "env");
+    F->addAttributes(llvm::AttributeList::FunctionIndex, B);
+  }
+  if (!F->hasFnAttribute("wasm-import-name")) {
+    B.addAttribute("wasm-import-name", F->getName());
+    F->addAttributes(llvm::AttributeList::FunctionIndex, B);
+  }
   InvokeWrappers[Sig] = F;
   return F;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77192.254088.patch
Type: text/x-patch
Size: 967 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200401/7c77827f/attachment.bin>


More information about the llvm-commits mailing list