summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Gohman <dan433584@gmail.com>2016-02-12 21:30:18 +0000
committerDan Gohman <dan433584@gmail.com>2016-02-12 21:30:18 +0000
commita6771b37f814b6c5d3f547323d9c49babef4844b (patch)
treecf05223fd58a91326a9167c0160bee4717ba245e
parent026f15e68706822bf26c133f28dbf43b9c85fc95 (diff)
downloadbcm5719-llvm-a6771b37f814b6c5d3f547323d9c49babef4844b.tar.gz
bcm5719-llvm-a6771b37f814b6c5d3f547323d9c49babef4844b.zip
[WebAssembly] Fix byval for empty types.
llvm-svn: 260740
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp3
-rw-r--r--llvm/test/CodeGen/WebAssembly/byval.ll19
2 files changed, 20 insertions, 2 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
index 779e23f7773..7d63d89f17e 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
@@ -308,9 +308,8 @@ SDValue WebAssemblyTargetLowering::LowerCall(
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);
diff --git a/llvm/test/CodeGen/WebAssembly/byval.ll b/llvm/test/CodeGen/WebAssembly/byval.ll
index 5bb350215db..9a9ab6500c8 100644
--- a/llvm/test/CodeGen/WebAssembly/byval.ll
+++ b/llvm/test/CodeGen/WebAssembly/byval.ll
@@ -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* byval align 32 %ptr) {
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@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@FUNCTION, $0
+ call void @ext_func_empty(%EmptyStruct* %ptr)
+ ret void
+}
OpenPOWER on IntegriCloud