[mlir] llvm::Optional::value => operator*/operator->
authorFangrui Song <i@maskray.me>
Sat, 17 Dec 2022 05:27:33 +0000 (05:27 +0000)
committerFangrui Song <i@maskray.me>
Sat, 17 Dec 2022 05:27:33 +0000 (05:27 +0000)
std::optional::value() has undesired exception checking semantics and is
unavailable in some older Xcode. The call sites block std::optional migration.

mlir/lib/Analysis/Presburger/IntegerRelation.cpp
mlir/lib/Analysis/Presburger/Utils.cpp
mlir/lib/Dialect/Affine/Analysis/Utils.cpp

index a39bb49..1367ff1 100644 (file)
@@ -2030,7 +2030,7 @@ IntegerRelation::unionBoundingBox(const IntegerRelation &otherCst) {
       if (!constLb.has_value() || !constOtherLb.has_value())
         return failure();
       std::fill(minLb.begin(), minLb.end(), 0);
-      minLb.back() = std::min(constLb.value(), constOtherLb.value());
+      minLb.back() = std::min(*constLb, *constOtherLb);
     }
 
     // Do the same for ub's but max of upper bounds. Identify max.
@@ -2046,7 +2046,7 @@ IntegerRelation::unionBoundingBox(const IntegerRelation &otherCst) {
       if (!constUb.has_value() || !constOtherUb.has_value())
         return failure();
       std::fill(maxUb.begin(), maxUb.end(), 0);
-      maxUb.back() = std::max(constUb.value(), constOtherUb.value());
+      maxUb.back() = std::max(*constUb, *constOtherUb);
     }
 
     std::fill(newLb.begin(), newLb.end(), 0);
index eef4ae5..be1e4ca 100644 (file)
@@ -401,7 +401,7 @@ DivisionRepr::divValuesAt(ArrayRef<MPInt> point) const {
         // Division value required, but not found yet.
         if (!divValues[j])
           break;
-        divVal += dividend[getDivOffset() + j] * divValues[j].value();
+        divVal += dividend[getDivOffset() + j] * *divValues[j];
       }
 
       // We have some division values that are still not found, but are required
index df7e13c..bbcf0e9 100644 (file)
@@ -373,7 +373,7 @@ Optional<int64_t> MemRefRegion::getConstantBoundingSizeAndShape(
     Optional<int64_t> diff =
         cstWithShapeBounds.getConstantBoundOnDimSize64(d, &lb, &lbDivisor);
     if (diff.has_value()) {
-      diffConstant = diff.value();
+      diffConstant = *diff;
       assert(diffConstant >= 0 && "Dim size bound can't be negative");
       assert(lbDivisor > 0);
     } else {