[llvm] r335576 - [WebAssembly] Fix lowering of varargs functions with non-legal fixed arguments.
Dan Gohman via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 25 20:18:38 PDT 2018
Author: djg
Date: Mon Jun 25 20:18:38 2018
New Revision: 335576
URL: http://llvm.org/viewvc/llvm-project?rev=335576&view=rev
Log:
[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.
Modified:
llvm/trunk/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
llvm/trunk/test/CodeGen/WebAssembly/varargs.ll
Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp?rev=335576&r1=335575&r2=335576&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp Mon Jun 25 20:18:38 2018
@@ -487,6 +487,7 @@ SDValue WebAssemblyTargetLowering::Lower
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::Lower
/*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.
Modified: llvm/trunk/test/CodeGen/WebAssembly/varargs.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WebAssembly/varargs.ll?rev=335576&r1=335575&r2=335576&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/WebAssembly/varargs.ll (original)
+++ llvm/trunk/test/CodeGen/WebAssembly/varargs.ll Mon Jun 25 20:18:38 2018
@@ -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 at 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*)
More information about the llvm-commits
mailing list