summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
authorSam Clegg <sbc@chromium.org>2018-06-25 18:47:32 +0000
committerSam Clegg <sbc@chromium.org>2018-06-25 18:47:32 +0000
commit6fd7d680b0a6d101cbeb93f16f3e90a14d8c4fe9 (patch)
tree69b2448eff4efc1a85918bf70f39c570da0224e7 /clang/lib/CodeGen
parenta46bcbec583b5ac8256c0698efe77d04789e1b92 (diff)
downloadbcm5719-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.cpp9
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.
OpenPOWER on IntegriCloud