mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-22 04:22:57 +02:00
[WebAssembly] Fix lowering of varargs functions with non-legal fixed arguments.
CallLoweringInfo's NumFixedArgs field gives the number of fixed arguments before legalization. The ISD::OutputArg "Outs" array holds legalized arguments, so when indexing into it to find the non-fixed arguemn, we need to use the number of arguments after legalization. Fixes PR37934. llvm-svn: 335576
This commit is contained in:
parent
702b88ddc2
commit
57d54664d6
@ -487,6 +487,7 @@ SDValue WebAssemblyTargetLowering::LowerCall(
|
||||
|
||||
SmallVectorImpl<ISD::OutputArg> &Outs = CLI.Outs;
|
||||
SmallVectorImpl<SDValue> &OutVals = CLI.OutVals;
|
||||
unsigned NumFixedArgs = 0;
|
||||
for (unsigned i = 0; i < Outs.size(); ++i) {
|
||||
const ISD::OutputArg &Out = Outs[i];
|
||||
SDValue &OutVal = OutVals[i];
|
||||
@ -512,11 +513,11 @@ SDValue WebAssemblyTargetLowering::LowerCall(
|
||||
/*isTailCall*/ false, MachinePointerInfo(), MachinePointerInfo());
|
||||
OutVal = FINode;
|
||||
}
|
||||
// Count the number of fixed args *after* legalization.
|
||||
NumFixedArgs += Out.IsFixed;
|
||||
}
|
||||
|
||||
bool IsVarArg = CLI.IsVarArg;
|
||||
unsigned NumFixedArgs = CLI.NumFixedArgs;
|
||||
|
||||
auto PtrVT = getPointerTy(Layout);
|
||||
|
||||
// Analyze operands of the call, assigning locations to each operand.
|
||||
|
@ -143,6 +143,27 @@ bb1:
|
||||
ret void
|
||||
}
|
||||
|
||||
; Test a call to a varargs function with a non-legal fixed argument.
|
||||
|
||||
declare void @callee_with_nonlegal_fixed(fp128, ...) nounwind
|
||||
|
||||
; CHECK-LABEL: call_nonlegal_fixed:
|
||||
; CHECK: i64.const $push[[L0:[0-9]+]]=, 0
|
||||
; CHECK: i64.const $push[[L1:[0-9]+]]=, 0
|
||||
; CHECK: i32.const $push[[L2:[0-9]+]]=, 0
|
||||
; CHECK: call callee_with_nonlegal_fixed@FUNCTION, $pop[[L0]], $pop[[L1]], $pop[[L2]]{{$}}
|
||||
define void @call_nonlegal_fixed() nounwind {
|
||||
call void (fp128, ...) @callee_with_nonlegal_fixed(fp128 0xL00000000000000000000000000000000)
|
||||
ret void
|
||||
}
|
||||
|
||||
; Test a definition a varargs function with a non-legal fixed argument.
|
||||
|
||||
; CHECK-LABEL: nonlegal_fixed:
|
||||
; CHECK-NEXT: .param i64, i64, i32{{$}}
|
||||
define void @nonlegal_fixed(fp128 %x, ...) nounwind {
|
||||
ret void
|
||||
}
|
||||
|
||||
declare void @llvm.va_start(i8*)
|
||||
declare void @llvm.va_end(i8*)
|
||||
|
Loading…
Reference in New Issue
Block a user