From 6fd7d680b0a6d101cbeb93f16f3e90a14d8c4fe9 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Mon, 25 Jun 2018 18:47:32 +0000 Subject: [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 --- clang/lib/CodeGen/TargetInfo.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'clang/lib') 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(D)) { + llvm::Function *Fn = cast(GV); + if (!FD->doesThisDeclarationHaveABody() && !FD->hasPrototype()) + Fn->addFnAttr("no-prototype"); + } + } }; /// Classify argument of given type \p Ty. -- cgit v1.2.3