[WebAssembly] Fix byval for empty types.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@260740 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dan Gohman 2016-02-12 21:30:18 +00:00
parent a5e85e7117
commit f97f532728
2 changed files with 20 additions and 2 deletions

View File

@ -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);

View File

@ -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
}