Index: lib/Target/BPF/BPFISelLowering.h =================================================================== --- lib/Target/BPF/BPFISelLowering.h +++ lib/Target/BPF/BPFISelLowering.h @@ -58,6 +58,9 @@ SelectionDAG &DAG, SmallVectorImpl &InVals) const; + // Maximum number of arguments to a call + static const unsigned long MaxArgs; + // Lower a call into CALLSEQ_START - BPFISD:CALL - CALLSEQ_END chain SDValue LowerCall(TargetLowering::CallLoweringInfo &CLI, SmallVectorImpl &InVals) const override; Index: lib/Target/BPF/BPFISelLowering.cpp =================================================================== --- lib/Target/BPF/BPFISelLowering.cpp +++ lib/Target/BPF/BPFISelLowering.cpp @@ -209,6 +209,8 @@ return Chain; } +const unsigned long BPFTargetLowering::MaxArgs = 5; + SDValue BPFTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI, SmallVectorImpl &InVals) const { SelectionDAG &DAG = CLI.DAG; @@ -241,9 +243,8 @@ unsigned NumBytes = CCInfo.getNextStackOffset(); - if (Outs.size() >= 6) { + if (Outs.size() > MaxArgs) fail(CLI.DL, DAG, "too many args to ", Callee); - } for (auto &Arg : Outs) { ISD::ArgFlagsTy Flags = Arg.Flags; @@ -257,10 +258,10 @@ Chain = DAG.getCALLSEQ_START( Chain, DAG.getConstant(NumBytes, CLI.DL, PtrVT, true), CLI.DL); - SmallVector, 5> RegsToPass; + SmallVector, MaxArgs> RegsToPass; // Walk arg assignments - for (unsigned i = 0, e = ArgLocs.size(); i != e; ++i) { + for (unsigned i = 0, e = std::min(ArgLocs.size(), MaxArgs); i != e; ++i) { CCValAssign &VA = ArgLocs[i]; SDValue Arg = OutVals[i]; Index: test/CodeGen/BPF/many_args1.ll =================================================================== --- test/CodeGen/BPF/many_args1.ll +++ test/CodeGen/BPF/many_args1.ll @@ -1,4 +1,4 @@ -; RUN: not llc -march=bpf -exit-on-error < %s 2> %t1 +; RUN: not llc -march=bpf < %s 2> %t1 ; RUN: FileCheck %s < %t1 ; CHECK: too many args