[PATCH] D134005: error for INT64_MIN / -1; clarify signed division; simplify errors
Michael Maitland via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 15 19:34:15 PDT 2022
michaelmaitland created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
michaelmaitland requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D134005
Files:
llvm/docs/TableGen/ProgRef.rst
llvm/lib/TableGen/Record.cpp
llvm/test/TableGen/math.td
Index: llvm/test/TableGen/math.td
===================================================================
--- llvm/test/TableGen/math.td
+++ llvm/test/TableGen/math.td
@@ -1,5 +1,6 @@
// RUN: llvm-tblgen %s | FileCheck %s
// RUN: not llvm-tblgen -DERROR1 %s 2>&1 | FileCheck --check-prefix=ERROR1 %s
+// RUN: not llvm-tblgen -DERROR2 %s 2>&1 | FileCheck --check-prefix=ERROR2 %s
// XFAIL: vg_leak
// CHECK: def shifts
@@ -73,6 +74,11 @@
def v18 : Int<!div(4, 0)>;
#endif
+#ifdef ERROR2
+// ERROR2: error: Illegal operation: INT64_MIN / -1
+def v19 : Int<!div(-9223372036854775808, -1)>;
+#endif
+
// CHECK: def v1a
// CHECK: Value = 1
Index: llvm/lib/TableGen/Record.cpp
===================================================================
--- llvm/lib/TableGen/Record.cpp
+++ llvm/lib/TableGen/Record.cpp
@@ -1187,7 +1187,10 @@
case DIV:
if (RHSv == 0)
PrintFatalError(CurRec->getLoc(),
- Twine("Illegal operation: division by zero"));
+ "Illegal operation: division by zero");
+ else if (LHSv == INT64_MIN && RHSv == -1)
+ PrintFatalError(CurRec->getLoc(),
+ "Illegal operation: INT64_MIN / -1");
else
Result = LHSv / RHSv;
break;
Index: llvm/docs/TableGen/ProgRef.rst
===================================================================
--- llvm/docs/TableGen/ProgRef.rst
+++ llvm/docs/TableGen/ProgRef.rst
@@ -1623,8 +1623,8 @@
``(op a1-value:$name1, a2-value:$name2, ?:$name3)``.
``!div(``\ *a*\ ``,`` *b*\ ``)``
- This operator divides *a* and *b*, and produces the quotient.
- Division by 0 produces an error.
+ This operator preforms signed division of *a* by *b*, and produces the quotient.
+ Division by 0 produces an error. Division by INT64_MIN produces an error.
``!empty(``\ *a*\ ``)``
This operator produces 1 if the string, list, or DAG *a* is empty; 0 otherwise.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134005.460603.patch
Type: text/x-patch
Size: 1963 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220916/9389384f/attachment.bin>
More information about the llvm-commits
mailing list