[Mlir-commits] [mlir] cc037e1 - [mlir] llvm::Optional::value => operator*/operator->

Fangrui Song llvmlistbot at llvm.org
Fri Dec 16 21:27:38 PST 2022


Author: Fangrui Song
Date: 2022-12-17T05:27:33Z
New Revision: cc037e17907dadc5ecb06bce61ce48a6627b274d

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

LOG: [mlir] llvm::Optional::value => operator*/operator->

std::optional::value() has undesired exception checking semantics and is
unavailable in some older Xcode. The call sites block std::optional migration.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Analysis/Presburger/IntegerRelation.cpp b/mlir/lib/Analysis/Presburger/IntegerRelation.cpp
index a39bb499cfd3f..1367ff1910982 100644
--- a/mlir/lib/Analysis/Presburger/IntegerRelation.cpp
+++ b/mlir/lib/Analysis/Presburger/IntegerRelation.cpp
@@ -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);

diff  --git a/mlir/lib/Analysis/Presburger/Utils.cpp b/mlir/lib/Analysis/Presburger/Utils.cpp
index eef4ae5616e3a..be1e4cacbc99e 100644
--- a/mlir/lib/Analysis/Presburger/Utils.cpp
+++ b/mlir/lib/Analysis/Presburger/Utils.cpp
@@ -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

diff  --git a/mlir/lib/Dialect/Affine/Analysis/Utils.cpp b/mlir/lib/Dialect/Affine/Analysis/Utils.cpp
index df7e13caffbdc..bbcf0e9fde971 100644
--- a/mlir/lib/Dialect/Affine/Analysis/Utils.cpp
+++ b/mlir/lib/Dialect/Affine/Analysis/Utils.cpp
@@ -373,7 +373,7 @@ Optional<int64_t> MemRefRegion::getConstantBoundingSizeAndShape(
     Optional<int64_t> 
diff  =
         cstWithShapeBounds.getConstantBoundOnDimSize64(d, &lb, &lbDivisor);
     if (
diff .has_value()) {
-      
diff Constant = 
diff .value();
+      
diff Constant = *
diff ;
       assert(
diff Constant >= 0 && "Dim size bound can't be negative");
       assert(lbDivisor > 0);
     } else {


        


More information about the Mlir-commits mailing list