diff options
author | Sam Clegg <sbc@chromium.org> | 2019-11-05 10:15:56 -0800 |
---|---|---|
committer | Sam Clegg <sbc@chromium.org> | 2019-12-11 11:54:57 -0800 |
commit | 881d877846e2904c731d616731969421ce8cc825 (patch) | |
tree | 39540e2e606f4b5fb1fe0a3675c566094f8c69c8 /clang/lib/CodeGen/TargetInfo.cpp | |
parent | 8db5143b1a1521915c842ebef23cb9fe8fe607ce (diff) | |
download | llvm-881d877846e2904c731d616731969421ce8cc825.zip llvm-881d877846e2904c731d616731969421ce8cc825.tar.gz llvm-881d877846e2904c731d616731969421ce8cc825.tar.bz2 |
[WebAssembly] Add new `export_name` clang attribute for controlling wasm export names
This is equivalent to the existing `import_name` and `import_module`
attributes which control the import names in the final wasm binary
produced by lld.
This maps the existing
This attribute currently requires a string rather than using the
symbol name for a couple of reasons:
1. Avoid confusion with static and dynamic linking which is
based on symbol name. Exporting a function from a wasm module using
this directive is orthogonal to both static and dynamic linking.
2. Avoids name mangling.
Differential Revision: https://reviews.llvm.org/D70520
Diffstat (limited to 'clang/lib/CodeGen/TargetInfo.cpp')
-rw-r--r-- | clang/lib/CodeGen/TargetInfo.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp index 33e7b18..9fd4a5f 100644 --- a/clang/lib/CodeGen/TargetInfo.cpp +++ b/clang/lib/CodeGen/TargetInfo.cpp @@ -779,6 +779,12 @@ public: B.addAttribute("wasm-import-name", Attr->getImportName()); Fn->addAttributes(llvm::AttributeList::FunctionIndex, B); } + if (const auto *Attr = FD->getAttr<WebAssemblyExportNameAttr>()) { + llvm::Function *Fn = cast<llvm::Function>(GV); + llvm::AttrBuilder B; + B.addAttribute("wasm-export-name", Attr->getExportName()); + Fn->addAttributes(llvm::AttributeList::FunctionIndex, B); + } } if (auto *FD = dyn_cast_or_null<FunctionDecl>(D)) { |