[PATCH] D20471: [BPF] Remove exit-on-error flag in test (PR27766)

Diana Picus via llvm-commits llvm-commits at lists.llvm.org
Fri May 20 08:51:13 PDT 2016


rovka created this revision.
rovka added a reviewer: ast.
rovka added subscribers: llvm-commits, rengolin.

The exit-on-error flag on the many_args1.ll test is needed to avoid an unreachable in BPFTargetLowering::LowerCall. We can also avoid it by ignoring any superfluous arguments to the call (i.e. any arguments after the first 5).

http://reviews.llvm.org/D20471

Files:
  lib/Target/BPF/BPFISelLowering.cpp
  lib/Target/BPF/BPFISelLowering.h
  test/CodeGen/BPF/many_args1.ll

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
 
Index: lib/Target/BPF/BPFISelLowering.h
===================================================================
--- lib/Target/BPF/BPFISelLowering.h
+++ lib/Target/BPF/BPFISelLowering.h
@@ -58,6 +58,9 @@
                           SelectionDAG &DAG,
                           SmallVectorImpl<SDValue> &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<SDValue> &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<SDValue> &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<std::pair<unsigned, SDValue>, 5> RegsToPass;
+  SmallVector<std::pair<unsigned, SDValue>, 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];
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20471.57935.patch
Type: text/x-patch
Size: 2165 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160520/0b2d814f/attachment.bin>


More information about the llvm-commits mailing list