[llvm] r260740 - [WebAssembly] Fix byval for empty types.

Dan Gohman via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 12 13:30:18 PST 2016


Author: djg
Date: Fri Feb 12 15:30:18 2016
New Revision: 260740

URL: http://llvm.org/viewvc/llvm-project?rev=260740&view=rev
Log:
[WebAssembly] Fix byval for empty types.

Modified:
    llvm/trunk/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
    llvm/trunk/test/CodeGen/WebAssembly/byval.ll

Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp?rev=260740&r1=260739&r2=260740&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp Fri Feb 12 15:30:18 2016
@@ -308,9 +308,8 @@ SDValue WebAssemblyTargetLowering::Lower
       fail(DL, DAG, "WebAssembly hasn't implemented cons regs arguments");
     if (Out.Flags.isInConsecutiveRegsLast())
       fail(DL, DAG, "WebAssembly hasn't implemented cons regs last arguments");
-    if (Out.Flags.isByVal()) {
+    if (Out.Flags.isByVal() && Out.Flags.getByValSize() != 0) {
       auto *MFI = MF.getFrameInfo();
-      assert(Out.Flags.getByValSize() && "Zero-size byval?");
       int FI = MFI->CreateStackObject(Out.Flags.getByValSize(),
                                       Out.Flags.getByValAlign(),
                                       /*isSS=*/false);

Modified: llvm/trunk/test/CodeGen/WebAssembly/byval.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WebAssembly/byval.ll?rev=260740&r1=260739&r2=260740&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/WebAssembly/byval.ll (original)
+++ llvm/trunk/test/CodeGen/WebAssembly/byval.ll Fri Feb 12 15:30:18 2016
@@ -8,14 +8,17 @@ target triple = "wasm32-unknown-unknown"
 %OddStruct = type { i32, i8, i32 }
 %AlignedStruct = type { double, double }
 %BigStruct = type { double, double, double, double, double, double, double, double, double, double, double, i8, i8, i8 }
+%EmptyStruct = type { }
 
 %BigArray = type { [33 x i8] }
 
 declare void @ext_func(%SmallStruct*)
+declare void @ext_func_empty(%EmptyStruct* byval)
 declare void @ext_byval_func(%SmallStruct* byval)
 declare void @ext_byval_func_align8(%SmallStruct* byval align 8)
 declare void @ext_byval_func_alignedstruct(%AlignedStruct* byval)
 declare void @ext_byval_func_bigarray(%BigArray* byval)
+declare void @ext_byval_func_empty(%EmptyStruct* byval)
 
 ; CHECK-LABEL: byval_arg
 define void @byval_arg(%SmallStruct* %ptr) {
@@ -103,3 +106,19 @@ define void @byval_param(%SmallStruct* b
  call void @ext_func(%SmallStruct* %ptr)
  ret void
 }
+
+; CHECK-LABEL: byval_empty_caller
+define void @byval_empty_caller(%EmptyStruct* %ptr) {
+ ; CHECK: .param i32
+ ; CHECK: call ext_byval_func_empty at FUNCTION, $0
+ call void @ext_byval_func_empty(%EmptyStruct* byval %ptr)
+ ret void
+}
+
+; CHECK-LABEL: byval_empty_callee
+define void @byval_empty_callee(%EmptyStruct* byval %ptr) {
+ ; CHECK: .param i32
+ ; CHECK: call ext_func_empty at FUNCTION, $0
+ call void @ext_func_empty(%EmptyStruct* %ptr)
+ ret void
+}




More information about the llvm-commits mailing list