[Mlir-commits] [mlir] bef481d - [mlir] Drop uses of operator<<(raw_ostream &OS, const Optional<T> &O)
Fangrui Song
llvmlistbot at llvm.org
Fri Dec 16 12:24:41 PST 2022
Author: Fangrui Song
Date: 2022-12-16T20:24:35Z
New Revision: bef481df8b10e30c8b20ee9a9d622e24688b8411
URL: https://github.com/llvm/llvm-project/commit/bef481df8b10e30c8b20ee9a9d622e24688b8411
DIFF: https://github.com/llvm/llvm-project/commit/bef481df8b10e30c8b20ee9a9d622e24688b8411.diff
LOG: [mlir] Drop uses of operator<<(raw_ostream &OS, const Optional<T> &O)
Added:
Modified:
mlir/include/mlir/Analysis/DataFlow/IntegerRangeAnalysis.h
mlir/include/mlir/IR/PatternMatch.h
mlir/include/mlir/Pass/PassOptions.h
mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp
mlir/lib/Rewrite/FrozenRewritePatternSet.cpp
mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp
mlir/lib/Transforms/Inliner.cpp
mlir/lib/Transforms/Utils/DialectConversion.cpp
mlir/test/lib/Analysis/DataFlow/TestDenseDataFlowAnalysis.cpp
mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/Analysis/DataFlow/IntegerRangeAnalysis.h b/mlir/include/mlir/Analysis/DataFlow/IntegerRangeAnalysis.h
index 70a579eaaa07..f66ff37add9b 100644
--- a/mlir/include/mlir/Analysis/DataFlow/IntegerRangeAnalysis.h
+++ b/mlir/include/mlir/Analysis/DataFlow/IntegerRangeAnalysis.h
@@ -30,7 +30,7 @@ class IntegerValueRange {
static IntegerValueRange getMaxRange(Value value);
/// Create an integer value range lattice value.
- IntegerValueRange(Optional<ConstantIntRanges> value = std::nullopt)
+ IntegerValueRange(std::optional<ConstantIntRanges> value = std::nullopt)
: value(std::move(value)) {}
/// Whether the range is uninitialized. This happens when the state hasn't
@@ -63,7 +63,7 @@ class IntegerValueRange {
private:
/// The known integer value range.
- Optional<ConstantIntRanges> value;
+ std::optional<ConstantIntRanges> value;
};
/// This lattice element represents the integer value range of an SSA value.
diff --git a/mlir/include/mlir/IR/PatternMatch.h b/mlir/include/mlir/IR/PatternMatch.h
index 7790f96f6bd9..0743e377150e 100644
--- a/mlir/include/mlir/IR/PatternMatch.h
+++ b/mlir/include/mlir/IR/PatternMatch.h
@@ -89,7 +89,7 @@ class Pattern {
/// Return the root node that this pattern matches. Patterns that can match
/// multiple root types return std::nullopt.
- Optional<OperationName> getRootKind() const {
+ std::optional<OperationName> getRootKind() const {
if (rootKind == RootKind::OperationName)
return OperationName::getFromOpaquePointer(rootValue);
return std::nullopt;
diff --git a/mlir/include/mlir/Pass/PassOptions.h b/mlir/include/mlir/Pass/PassOptions.h
index d32c3de42751..6717a3585d12 100644
--- a/mlir/include/mlir/Pass/PassOptions.h
+++ b/mlir/include/mlir/Pass/PassOptions.h
@@ -118,7 +118,7 @@ class PassOptions : protected llvm::cl::SubCommand {
using llvm::cl::parser<DataType>::parser;
/// Returns an argument name that maps to the specified value.
- Optional<StringRef> findArgStrForValue(const DataType &value) {
+ std::optional<StringRef> findArgStrForValue(const DataType &value) {
for (auto &it : this->Values)
if (it.V.compare(value))
return it.Name;
@@ -130,8 +130,8 @@ class PassOptions : protected llvm::cl::SubCommand {
template <typename DataT>
static void printValue(raw_ostream &os, GenericOptionParser<DataT> &parser,
const DataT &value) {
- if (Optional<StringRef> argStr = parser.findArgStrForValue(value))
- os << argStr;
+ if (std::optional<StringRef> argStr = parser.findArgStrForValue(value))
+ os << *argStr;
else
llvm_unreachable("unknown data value for option");
}
diff --git a/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp b/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp
index 3341b5e36756..2dfd1b739493 100644
--- a/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp
+++ b/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp
@@ -327,7 +327,7 @@ static void printMemoryAccessAttribute(
if (auto alignment = (alignmentAttrValue ? alignmentAttrValue
: memoryOp.getAlignment())) {
elidedAttrs.push_back(kAlignmentAttrName);
- printer << ", " << alignment;
+ printer << ", " << *alignment;
}
}
printer << "]";
@@ -360,7 +360,7 @@ static void printSourceMemoryAccessAttribute(
if (auto alignment = (alignmentAttrValue ? alignmentAttrValue
: memoryOp.getAlignment())) {
elidedAttrs.push_back(kSourceAlignmentAttrName);
- printer << ", " << alignment;
+ printer << ", " << *alignment;
}
}
printer << "]";
diff --git a/mlir/lib/Rewrite/FrozenRewritePatternSet.cpp b/mlir/lib/Rewrite/FrozenRewritePatternSet.cpp
index 7b83d104befb..fc6cc968aa3d 100644
--- a/mlir/lib/Rewrite/FrozenRewritePatternSet.cpp
+++ b/mlir/lib/Rewrite/FrozenRewritePatternSet.cpp
@@ -100,7 +100,7 @@ FrozenRewritePatternSet::FrozenRewritePatternSet(
continue;
}
- if (Optional<OperationName> rootName = pat->getRootKind()) {
+ if (std::optional<OperationName> rootName = pat->getRootKind()) {
impl->nativeOpSpecificPatternMap[*rootName].push_back(pat.get());
impl->nativeOpSpecificPatternList.push_back(std::move(pat));
continue;
diff --git a/mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp b/mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp
index 84759aa084f6..f9f7ae7d852d 100644
--- a/mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp
+++ b/mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp
@@ -553,7 +553,7 @@ PDLDocument::buildHoverForCoreConstraint(const ast::CoreConstraintDecl *decl,
.Case([&](const ast::OpConstraintDecl *opCst) {
hoverOS << "Op";
if (Optional<StringRef> name = opCst->getName())
- hoverOS << "<" << name << ">";
+ hoverOS << "<" << *name << ">";
})
.Case([&](const ast::TypeConstraintDecl *) { hoverOS << "Type"; })
.Case([&](const ast::TypeRangeConstraintDecl *) {
diff --git a/mlir/lib/Transforms/Inliner.cpp b/mlir/lib/Transforms/Inliner.cpp
index 790810b44b03..5c795f902afc 100644
--- a/mlir/lib/Transforms/Inliner.cpp
+++ b/mlir/lib/Transforms/Inliner.cpp
@@ -382,8 +382,8 @@ static std::string getNodeName(CallOpInterface op) {
/// Return true if the specified `inlineHistoryID` indicates an inline history
/// that already includes `node`.
static bool inlineHistoryIncludes(
- CallGraphNode *node, Optional<size_t> inlineHistoryID,
- MutableArrayRef<std::pair<CallGraphNode *, Optional<size_t>>>
+ CallGraphNode *node, std::optional<size_t> inlineHistoryID,
+ MutableArrayRef<std::pair<CallGraphNode *, std::optional<size_t>>>
inlineHistory) {
while (inlineHistoryID.has_value()) {
assert(inlineHistoryID.value() < inlineHistory.size() &&
@@ -488,7 +488,7 @@ static LogicalResult inlineCallsInSCC(Inliner &inliner, CGUseList &useList,
// When inlining a callee produces new call sites, we want to keep track of
// the fact that they were inlined from the callee. This allows us to avoid
// infinite inlining.
- using InlineHistoryT = Optional<size_t>;
+ using InlineHistoryT = std::optional<size_t>;
SmallVector<std::pair<CallGraphNode *, InlineHistoryT>, 8> inlineHistory;
std::vector<InlineHistoryT> callHistory(calls.size(), InlineHistoryT{});
diff --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp b/mlir/lib/Transforms/Utils/DialectConversion.cpp
index 2fb3422b881e..795293bb0798 100644
--- a/mlir/lib/Transforms/Utils/DialectConversion.cpp
+++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp
@@ -2146,7 +2146,7 @@ void OperationLegalizer::buildLegalizationGraph(
// Build the mapping from operations to the parent ops that may generate them.
applicator.walkAllPatterns([&](const Pattern &pattern) {
- Optional<OperationName> root = pattern.getRootKind();
+ std::optional<OperationName> root = pattern.getRootKind();
// If the pattern has no specific root, we can't analyze the relationship
// between the root op and generated operations. Given that, add all such
@@ -2228,7 +2228,7 @@ void OperationLegalizer::computeLegalizationGraphBenefit(
// decreasing benefit.
applicator.applyCostModel([&](const Pattern &pattern) {
ArrayRef<const Pattern *> orderedPatternList;
- if (Optional<OperationName> rootName = pattern.getRootKind())
+ if (std::optional<OperationName> rootName = pattern.getRootKind())
orderedPatternList = legalizerPatterns[*rootName];
else
orderedPatternList = anyOpLegalizerPatterns;
diff --git a/mlir/test/lib/Analysis/DataFlow/TestDenseDataFlowAnalysis.cpp b/mlir/test/lib/Analysis/DataFlow/TestDenseDataFlowAnalysis.cpp
index 9e81b85dac9e..d4f03ecd1f5e 100644
--- a/mlir/test/lib/Analysis/DataFlow/TestDenseDataFlowAnalysis.cpp
+++ b/mlir/test/lib/Analysis/DataFlow/TestDenseDataFlowAnalysis.cpp
@@ -21,7 +21,7 @@ namespace {
class UnderlyingValue {
public:
/// Create an underlying value state with a known underlying value.
- explicit UnderlyingValue(Optional<Value> underlyingValue = std::nullopt)
+ explicit UnderlyingValue(std::optional<Value> underlyingValue = std::nullopt)
: underlyingValue(underlyingValue) {}
/// Whether the state is uninitialized.
@@ -54,7 +54,7 @@ class UnderlyingValue {
void print(raw_ostream &os) const { os << underlyingValue; }
private:
- Optional<Value> underlyingValue;
+ std::optional<Value> underlyingValue;
};
/// This lattice represents, for a given memory resource, the potential last
diff --git a/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp b/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp
index f9b83895c371..cfa1880b5d3f 100644
--- a/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp
+++ b/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp
@@ -1145,7 +1145,7 @@ if ({1}Iter != attrs.end()) {{
Optional<std::string> cppValue = generateExpression(assignment->value);
if (!cppValue)
return failure();
- stmts.push_back(llvm::formatv("yields.push_back({0});", cppValue));
+ stmts.push_back(llvm::formatv("yields.push_back({0});", *cppValue));
}
if (generatedAssignmentCount != assignments.size())
More information about the Mlir-commits
mailing list