[PATCH] D64318: [WebAssembly] Make sret parameter work with AddMissingPrototypes

Heejin Ahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 8 19:10:26 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL365426: [WebAssembly] Make sret parameter work with AddMissingPrototypes (authored by aheejin, committed by ).

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64318/new/

https://reviews.llvm.org/D64318

Files:
  llvm/trunk/lib/Target/WebAssembly/WebAssemblyAddMissingPrototypes.cpp
  llvm/trunk/test/CodeGen/WebAssembly/add-prototypes.ll


Index: llvm/trunk/test/CodeGen/WebAssembly/add-prototypes.ll
===================================================================
--- llvm/trunk/test/CodeGen/WebAssembly/add-prototypes.ll
+++ llvm/trunk/test/CodeGen/WebAssembly/add-prototypes.ll
@@ -56,6 +56,17 @@
   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()
Index: llvm/trunk/lib/Target/WebAssembly/WebAssemblyAddMissingPrototypes.cpp
===================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyAddMissingPrototypes.cpp
+++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyAddMissingPrototypes.cpp
@@ -78,10 +78,13 @@
       report_fatal_error(
           "Functions with 'no-prototype' attribute must take varargs: " +
           F.getName());
-    if (F.getFunctionType()->getNumParams() != 0)
-      report_fatal_error(
-          "Functions with 'no-prototype' attribute should not have params: " +
-          F.getName());
+    unsigned NumParams = F.getFunctionType()->getNumParams();
+    if (NumParams != 0) {
+      if (!(NumParams == 1 && F.arg_begin()->hasStructRetAttr()))
+        report_fatal_error("Functions with 'no-prototype' attribute should "
+                           "not have params: " +
+                           F.getName());
+    }
 
     // Create a function prototype based on the first call site (first bitcast)
     // that we find.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64318.208571.patch
Type: text/x-patch
Size: 1866 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190709/d3ffc9bb/attachment.bin>


More information about the llvm-commits mailing list