From: Fangrui Song Date: Sat, 17 Dec 2022 19:23:50 +0000 (+0000) Subject: [mlir] llvm::Optional::value() && => operator*/operator-> X-Git-Tag: upstream/17.0.6~23392 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=76b11003728dc1e37a28d69db81fb7952c7486e9;p=platform%2Fupstream%2Fllvm.git [mlir] llvm::Optional::value() && => operator*/operator-> std::optional::value() has undesired exception checking semantics and is unavailable in older Xcode (see _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS). The call sites block std::optional migration. --- diff --git a/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp index 1790f4b..0c582ed 100644 --- a/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp @@ -221,7 +221,7 @@ private: // 'return' takes an optional expression, handle that case here. mlir::Value expr = nullptr; if (ret.getExpr().has_value()) { - if (!(expr = mlirGen(*ret.getExpr().value()))) + if (!(expr = mlirGen(**ret.getExpr()))) return mlir::failure(); } diff --git a/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp index 1790f4b..0c582ed 100644 --- a/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp @@ -221,7 +221,7 @@ private: // 'return' takes an optional expression, handle that case here. mlir::Value expr = nullptr; if (ret.getExpr().has_value()) { - if (!(expr = mlirGen(*ret.getExpr().value()))) + if (!(expr = mlirGen(**ret.getExpr()))) return mlir::failure(); } diff --git a/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp index d5061d9..8348361 100644 --- a/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp @@ -225,7 +225,7 @@ private: // 'return' takes an optional expression, handle that case here. mlir::Value expr = nullptr; if (ret.getExpr().has_value()) { - if (!(expr = mlirGen(*ret.getExpr().value()))) + if (!(expr = mlirGen(**ret.getExpr()))) return mlir::failure(); } diff --git a/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp index d5061d9..8348361 100644 --- a/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp @@ -225,7 +225,7 @@ private: // 'return' takes an optional expression, handle that case here. mlir::Value expr = nullptr; if (ret.getExpr().has_value()) { - if (!(expr = mlirGen(*ret.getExpr().value()))) + if (!(expr = mlirGen(**ret.getExpr()))) return mlir::failure(); } diff --git a/mlir/examples/toy/Ch6/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch6/mlir/MLIRGen.cpp index d5061d9..8348361 100644 --- a/mlir/examples/toy/Ch6/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch6/mlir/MLIRGen.cpp @@ -225,7 +225,7 @@ private: // 'return' takes an optional expression, handle that case here. mlir::Value expr = nullptr; if (ret.getExpr().has_value()) { - if (!(expr = mlirGen(*ret.getExpr().value()))) + if (!(expr = mlirGen(**ret.getExpr()))) return mlir::failure(); } diff --git a/mlir/examples/toy/Ch7/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch7/mlir/MLIRGen.cpp index 93c9bd5..ed367b8 100644 --- a/mlir/examples/toy/Ch7/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch7/mlir/MLIRGen.cpp @@ -358,7 +358,7 @@ private: // 'return' takes an optional expression, handle that case here. mlir::Value expr = nullptr; if (ret.getExpr().has_value()) { - if (!(expr = mlirGen(*ret.getExpr().value()))) + if (!(expr = mlirGen(**ret.getExpr()))) return mlir::failure(); } diff --git a/mlir/lib/Dialect/Arith/IR/ArithCanonicalization.td b/mlir/lib/Dialect/Arith/IR/ArithCanonicalization.td index 6f88a77..4a96d99 100644 --- a/mlir/lib/Dialect/Arith/IR/ArithCanonicalization.td +++ b/mlir/lib/Dialect/Arith/IR/ArithCanonicalization.td @@ -126,7 +126,7 @@ def MulSIExtendedToMulI : def IsScalarOrSplatOne : Constraint, - CPred<"getIntOrSplatIntValue($0).value() == 1">]>>; + CPred<"*getIntOrSplatIntValue($0) == 1">]>>; // mulsi_extended(x, 1) -> [x, extsi(cmpi slt, x, 0)] def MulSIExtendedRHSOne : @@ -284,7 +284,7 @@ def TruncationMatchesShiftAmount : Constraint, CPred<"(getScalarOrElementWidth($0) - getScalarOrElementWidth($1)) == " - "getIntOrSplatIntValue($2).value()">]>>; + "*getIntOrSplatIntValue($2)">]>>; // trunci(shrsi(x, c)) -> trunci(shrui(x, c)) def TruncIShrSIToTrunciShrUI : diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp index 4bc24af..680ef8d 100644 --- a/mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp +++ b/mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp @@ -1172,7 +1172,7 @@ static Operation *genFor(Merger &merger, CodeGen &codegen, OpBuilder &builder, bool isParallel = isParallelFor(codegen, isOuter, isSparse); Operation *loop = - genLoopBoundary(codegen, merger, [&](MutableArrayRef reduc) { + *genLoopBoundary(codegen, merger, [&](MutableArrayRef reduc) { if (merger.isFilterLoop(idx)) { // extraTids/extraDims must be empty because filter loops only // corresponding to the one and only sparse tensor level. @@ -1187,7 +1187,7 @@ static Operation *genFor(Merger &merger, CodeGen &codegen, OpBuilder &builder, } return codegen.loopEmitter.enterLoopOverTensorAtDim( builder, loc, tid, dim, reduc, isParallel, extraTids, extraDims); - }).value(); + }); assert(loop); return loop; } @@ -1200,12 +1200,12 @@ static Operation *genWhile(Merger &merger, CodeGen &codegen, OpBuilder &builder, ArrayRef extraDims) { Operation *loop = - genLoopBoundary(codegen, merger, [&](MutableArrayRef reduc) { + *genLoopBoundary(codegen, merger, [&](MutableArrayRef reduc) { // Construct the while-loop with a parameter for each index. return codegen.loopEmitter.enterCoIterationOverTensorsAtDims( builder, op.getLoc(), condTids, condDims, needsUniv, reduc, extraTids, extraDims); - }).value(); + }); assert(loop); return loop; } @@ -1277,7 +1277,7 @@ static scf::IfOp genIf(Merger &merger, CodeGen &codegen, OpBuilder &builder, Value clause; if (isCompressedDLT(merger.getDimLevelType(b)) || isSingletonDLT(merger.getDimLevelType(b))) { - auto dim = merger.getDimNum(tensor, idx).value(); + auto dim = *merger.getDimNum(tensor, idx); Value op1 = codegen.loopEmitter.getCoord()[tensor][dim]; Value op2 = codegen.getLoopIdxValue(idx); clause = builder.create(loc, arith::CmpIPredicate::eq, op1, @@ -1486,7 +1486,7 @@ static void translateBitsToTidDimPairs( // Note that we generate dense indices of the output tensor // unconditionally, since they may not appear in the lattice, but may be // needed for linearized codegen. - auto dim = merger.getDimNum(merger.getOutTensorID(), idx).value(); + auto dim = *merger.getDimNum(merger.getOutTensorID(), idx); extraTids.push_back(merger.getOutTensorID()); extraDims.push_back(dim); }