[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.
This commit is contained in:
Arjun P 2021-12-16 03:06:27 +05:30
parent 501674dc3b
commit 15c8b8ad85
1 changed files with 6 additions and 3 deletions

View File

@ -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;
}