OSDN Git Service

BPF: emit an error message for unsupported signed division operation
authorAlexei Starovoitov <alexei.starovoitov@gmail.com>
Fri, 18 Mar 2016 22:02:47 +0000 (22:02 +0000)
committerAlexei Starovoitov <alexei.starovoitov@gmail.com>
Fri, 18 Mar 2016 22:02:47 +0000 (22:02 +0000)
Signed-off-by: Yonghong Song <yhs@plumgrid.com>
Signed-off-by: Alexei Starovoitov <ast@fb.com>
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@263842 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/BPF/BPFISelDAGToDAG.cpp
test/CodeGen/BPF/sdiv_error.ll [new file with mode: 0644]

index 9d5f1d4..05348ae 100644 (file)
@@ -130,6 +130,18 @@ SDNode *BPFDAGToDAGISel::Select(SDNode *Node) {
   // tablegen selection should be handled here.
   switch (Opcode) {
   default: break;
+  case ISD::SDIV: {
+    DebugLoc Empty;
+    const DebugLoc &DL = Node->getDebugLoc();
+    if (DL != Empty)
+      errs() << "Error at line " << DL.getLine() << ": ";
+    else
+      errs() << "Error: ";
+    errs() << "Unsupport signed division for DAG: ";
+    Node->dump(CurDAG);
+    errs() << "Please convert to unsigned div/mod.\n";
+    break;
+  }
   case ISD::INTRINSIC_W_CHAIN: {
     unsigned IntNo = cast<ConstantSDNode>(Node->getOperand(1))->getZExtValue();
     switch (IntNo) {
diff --git a/test/CodeGen/BPF/sdiv_error.ll b/test/CodeGen/BPF/sdiv_error.ll
new file mode 100644 (file)
index 0000000..053b82d
--- /dev/null
@@ -0,0 +1,9 @@
+; RUN: not llc -march=bpf < %s 2> %t1
+; RUN: FileCheck %s < %t1
+; CHECK: Unsupport signed division
+
+; Function Attrs: norecurse nounwind readnone
+define i32 @test(i32 %len) #0 {
+  %1 = srem i32 %len, 15
+  ret i32 %1
+}