summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/TargetInfo.cpp
diff options
context:
space:
mode:
authorDan Gohman <dan433584@gmail.com>2019-01-24 21:08:30 +0000
committerDan Gohman <dan433584@gmail.com>2019-01-24 21:08:30 +0000
commitb432369f6b333378a60efb090db649819743ca95 (patch)
tree123aa207ba7af38523bed3d04102f4a40b75a3e5 /clang/lib/CodeGen/TargetInfo.cpp
parentc1eee1d659155b99fac63cbf72491c27106f0481 (diff)
downloadbcm5719-llvm-b432369f6b333378a60efb090db649819743ca95.tar.gz
bcm5719-llvm-b432369f6b333378a60efb090db649819743ca95.zip
[WebAssembly] Add an import_module function attribute
This adds a C/C++ attribute which corresponds to the LLVM IR wasm-import-module attribute. It allows code to specify an explicit import module. Differential Revision: https://reviews.llvm.org/D57160 llvm-svn: 352106
Diffstat (limited to 'clang/lib/CodeGen/TargetInfo.cpp')
-rw-r--r--clang/lib/CodeGen/TargetInfo.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp
index d36c5fbcd71..675838ed97f 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -760,6 +760,16 @@ public:
void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
CodeGen::CodeGenModule &CGM) const override {
+ TargetCodeGenInfo::setTargetAttributes(D, GV, CGM);
+ if (const auto *FD = dyn_cast_or_null<FunctionDecl>(D)) {
+ if (const auto *Attr = FD->getAttr<WebAssemblyImportModuleAttr>()) {
+ llvm::Function *Fn = cast<llvm::Function>(GV);
+ llvm::AttrBuilder B;
+ B.addAttribute("wasm-import-module", Attr->getImportModuleName());
+ Fn->addAttributes(llvm::AttributeList::FunctionIndex, B);
+ }
+ }
+
if (auto *FD = dyn_cast_or_null<FunctionDecl>(D)) {
llvm::Function *Fn = cast<llvm::Function>(GV);
if (!FD->doesThisDeclarationHaveABody() && !FD->hasPrototype())
OpenPOWER on IntegriCloud