From 947bfe73fc2f50300fafdf9ef7a025e7d17da30e Mon Sep 17 00:00:00 2001 From: Heejin Ahn Date: Tue, 9 Jul 2019 02:10:33 +0000 Subject: [WebAssembly] Make sret parameter work with AddMissingPrototypes Summary: Even with functions with `no-prototype` attribute, there can be an argument `sret` (structure return) attribute, which is an optimization when a function return type is a struct. Fixes PR42420. Reviewers: sbc100 Subscribers: dschuff, jgravelle-google, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D64318 llvm-svn: 365426 --- llvm/test/CodeGen/WebAssembly/add-prototypes.ll | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'llvm/test/CodeGen') diff --git a/llvm/test/CodeGen/WebAssembly/add-prototypes.ll b/llvm/test/CodeGen/WebAssembly/add-prototypes.ll index f42e4827d2f..84d7657e983 100644 --- a/llvm/test/CodeGen/WebAssembly/add-prototypes.ll +++ b/llvm/test/CodeGen/WebAssembly/add-prototypes.ll @@ -56,6 +56,17 @@ define void @as_paramater() { ret void } +; Check if a sret parameter works in a no-prototype function. +; CHECK-LABEL: @sret_param +; CHECK: call void @make_struct_foo(%struct.foo* sret %foo) +%struct.foo = type { i32, i32 } +declare void @make_struct_foo(%struct.foo* sret, ...) #1 +define void @sret_param() { + %foo = alloca %struct.foo, align 4 + call void bitcast (void (%struct.foo*, ...)* @make_struct_foo to void (%struct.foo*)*)(%struct.foo* sret %foo) + ret void +} + declare void @func_param(i64 (...)*) ; CHECK: declare void @func_not_called() -- cgit v1.2.3