[llvm] [BPF] improve error handling by custom lowering & fail() (PR #75088)

Yingchi Long via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 12 21:32:31 PST 2023


================
@@ -617,6 +622,21 @@ static void NegateCC(SDValue &LHS, SDValue &RHS, ISD::CondCode &CC) {
   }
 }
 
+SDValue BPFTargetLowering::LowerSDIVSREM(SDValue Op, SelectionDAG &DAG) const {
+  SDLoc DL(Op);
+  fail(DL, DAG,
+       "unsupported signed division, please convert to unsigned div/mod.");
+  return DAG.getUNDEF(Op->getValueType(0));
+}
+
+SDValue BPFTargetLowering::LowerDYNAMIC_STACKALLOC(SDValue Op,
+                                                   SelectionDAG &DAG) const {
+  SDLoc DL(Op);
+  fail(DL, DAG, "unsupported dynamic stack allocation");
+  auto Ops = {DAG.getConstant(0, SDLoc(), Op.getValueType()), Op.getOperand(0)};
+  return DAG.getMergeValues(Ops, SDLoc());
----------------
inclyc wrote:

They are "documented" in ISDOpcodes declaration header.

https://github.com/llvm/llvm-project/blob/a2161154334355e9ecdf3cc3a0303b9481aad897/llvm/include/llvm/CodeGen/ISDOpcodes.h#L1032C3-L1039C22

https://github.com/llvm/llvm-project/pull/75088


More information about the llvm-commits mailing list