diff options
author | Sam Clegg <sbc@chromium.org> | 2018-06-25 18:47:32 +0000 |
---|---|---|
committer | Sam Clegg <sbc@chromium.org> | 2018-06-25 18:47:32 +0000 |
commit | 6fd7d680b0a6d101cbeb93f16f3e90a14d8c4fe9 (patch) | |
tree | 69b2448eff4efc1a85918bf70f39c570da0224e7 /clang/lib/CodeGen | |
parent | a46bcbec583b5ac8256c0698efe77d04789e1b92 (diff) | |
download | bcm5719-llvm-6fd7d680b0a6d101cbeb93f16f3e90a14d8c4fe9.tar.gz bcm5719-llvm-6fd7d680b0a6d101cbeb93f16f3e90a14d8c4fe9.zip |
[WebAssembly] Add no-prototype attribute to prototype-less C functions
The WebAssembly backend in particular benefits from being
able to distinguish between varargs functions (...) and prototype-less
C functions.
Differential Revision: https://reviews.llvm.org/D48443
llvm-svn: 335510
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r-- | clang/lib/CodeGen/TargetInfo.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp index b29bcce237c..3fcafbbfd37 100644 --- a/clang/lib/CodeGen/TargetInfo.cpp +++ b/clang/lib/CodeGen/TargetInfo.cpp @@ -747,6 +747,15 @@ class WebAssemblyTargetCodeGenInfo final : public TargetCodeGenInfo { public: explicit WebAssemblyTargetCodeGenInfo(CodeGen::CodeGenTypes &CGT) : TargetCodeGenInfo(new WebAssemblyABIInfo(CGT)) {} + + void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV, + CodeGen::CodeGenModule &CGM) const override { + if (auto *FD = dyn_cast_or_null<FunctionDecl>(D)) { + llvm::Function *Fn = cast<llvm::Function>(GV); + if (!FD->doesThisDeclarationHaveABody() && !FD->hasPrototype()) + Fn->addFnAttr("no-prototype"); + } + } }; /// Classify argument of given type \p Ty. |