[Mlir-commits] [mlir] 15c8b8a - [MLIR] Simplex: Assert on the restoreRow return value instead of ignoring it

Arjun P llvmlistbot at llvm.org
Wed Dec 15 14:03:41 PST 2021


Author: Arjun P
Date: 2021-12-16T03:27:50+05:30
New Revision: 15c8b8ad85c196df25aa3c22bca3d8458f86525a

URL: https://github.com/llvm/llvm-project/commit/15c8b8ad85c196df25aa3c22bca3d8458f86525a
DIFF: https://github.com/llvm/llvm-project/commit/15c8b8ad85c196df25aa3c22bca3d8458f86525a.diff

LOG: [MLIR] Simplex: Assert on the restoreRow return value instead of ignoring it

Previously, the LogicalResult return value of restoreRow was being ignored in
places where it was expected to always be success. Instead, check the result
and go to an `llvm_unreachable` if it turns out to be failure.

Added: 
    

Modified: 
    mlir/lib/Analysis/Presburger/Simplex.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Analysis/Presburger/Simplex.cpp b/mlir/lib/Analysis/Presburger/Simplex.cpp
index 9a4ae16bd4bfe..a52712aa44b4e 100644
--- a/mlir/lib/Analysis/Presburger/Simplex.cpp
+++ b/mlir/lib/Analysis/Presburger/Simplex.cpp
@@ -558,8 +558,10 @@ Optional<Fraction> Simplex::computeOptimum(Direction direction, Unknown &u) {
   unsigned row = u.pos;
   Optional<Fraction> optimum = computeRowOptimum(direction, row);
   if (u.restricted && direction == Direction::Down &&
-      (!optimum || *optimum < Fraction(0, 1)))
-    (void)restoreRow(u);
+      (!optimum || *optimum < Fraction(0, 1))) {
+    if (failed(restoreRow(u)))
+      llvm_unreachable("Could not restore row!");
+  }
   return optimum;
 }
 
@@ -623,7 +625,8 @@ void Simplex::detectRedundant() {
     if (!minimum || *minimum < Fraction(0, 1)) {
       // Constraint is unbounded below or can attain negative sample values and
       // hence is not redundant.
-      (void)restoreRow(u);
+      if (failed(restoreRow(u)))
+        llvm_unreachable("Could not restore non-redundant row!");
       continue;
     }
 


        


More information about the Mlir-commits mailing list