From 4651b6857f4bdcdab15e2a3d29f818f682efbb76 Mon Sep 17 00:00:00 2001 From: Jay Foad Date: Sat, 21 Sep 2024 10:05:25 +0100 Subject: [PATCH 1/2] [mlir] Use {} instead of std::nullopt to initialize empty ArrayRef Follow up to #109133. --- mlir/include/mlir/AsmParser/AsmParserState.h | 2 +- mlir/include/mlir/CAPI/Wrap.h | 2 +- mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td | 2 +- mlir/include/mlir/Dialect/PDL/IR/PDLOps.td | 2 +- .../mlir/ExecutionEngine/ExecutionEngine.h | 2 +- mlir/include/mlir/IR/BlockSupport.h | 2 +- mlir/include/mlir/IR/Builders.h | 4 ++-- mlir/include/mlir/IR/BuiltinAttributes.td | 2 +- mlir/include/mlir/IR/BuiltinTypes.td | 4 ++-- mlir/include/mlir/IR/Matchers.h | 2 +- mlir/include/mlir/IR/PatternMatch.h | 4 ++-- mlir/include/mlir/IR/Region.h | 2 +- mlir/include/mlir/IR/SymbolTable.h | 2 +- mlir/include/mlir/IR/TypeRange.h | 4 +++- mlir/include/mlir/IR/ValueRange.h | 5 +++-- .../mlir/Rewrite/FrozenRewritePatternSet.h | 4 ++-- mlir/include/mlir/Support/StorageUniquer.h | 2 +- mlir/include/mlir/Tools/PDLL/AST/Nodes.h | 2 +- mlir/include/mlir/Tools/PDLL/AST/Types.h | 2 +- mlir/include/mlir/Transforms/Passes.h | 4 ++-- .../PDLToPDLInterp/PDLToPDLInterp.cpp | 2 +- .../Conversion/TosaToLinalg/TosaToLinalg.cpp | 14 ++++++------- mlir/lib/Dialect/Async/IR/Async.cpp | 2 +- mlir/lib/Dialect/EmitC/IR/EmitC.cpp | 2 +- mlir/lib/Dialect/Func/IR/FuncOps.cpp | 2 +- .../GPU/Transforms/DecomposeMemRefs.cpp | 4 ++-- mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp | 2 +- mlir/lib/Dialect/LLVMIR/IR/TypeDetail.h | 2 +- mlir/lib/Dialect/Shape/IR/Shape.cpp | 2 +- mlir/lib/IR/Diagnostics.cpp | 2 +- mlir/lib/Interfaces/FunctionInterfaces.cpp | 4 ++-- mlir/lib/Pass/PassStatistics.cpp | 2 +- mlir/lib/Reducer/Tester.cpp | 2 +- .../LLVMIR/LoopAnnotationTranslation.cpp | 2 +- mlir/lib/Target/LLVMIR/ModuleTranslation.cpp | 2 +- mlir/lib/Tools/PDLL/CodeGen/MLIRGen.cpp | 2 +- mlir/lib/Tools/PDLL/Parser/Parser.cpp | 10 +++++----- .../Tools/mlir-pdll-lsp-server/PDLLServer.cpp | 4 ++-- mlir/test/lib/Dialect/Test/TestAttributes.cpp | 2 +- mlir/test/lib/Dialect/Test/TestPatterns.cpp | 4 ++-- .../FileLineColLocBreakpointManagerTest.cpp | 2 +- mlir/unittests/IR/OperationSupportTest.cpp | 20 +++++++++---------- .../Transforms/DialectConversion.cpp | 2 +- 43 files changed, 75 insertions(+), 72 deletions(-) diff --git a/mlir/include/mlir/AsmParser/AsmParserState.h b/mlir/include/mlir/AsmParser/AsmParserState.h index 98bdc4696b846..e47cb32ee4027 100644 --- a/mlir/include/mlir/AsmParser/AsmParserState.h +++ b/mlir/include/mlir/AsmParser/AsmParserState.h @@ -195,7 +195,7 @@ class AsmParserState { /// Finalize the most recently started operation definition. void finalizeOperationDefinition( Operation *op, SMRange nameLoc, SMLoc endLoc, - ArrayRef> resultGroups = std::nullopt); + ArrayRef> resultGroups = {}); /// Start a definition for a region nested under the current operation. void startRegionDefinition(); diff --git a/mlir/include/mlir/CAPI/Wrap.h b/mlir/include/mlir/CAPI/Wrap.h index 5b68f417a3df4..fd5b6e18d4952 100644 --- a/mlir/include/mlir/CAPI/Wrap.h +++ b/mlir/include/mlir/CAPI/Wrap.h @@ -44,7 +44,7 @@ static llvm::ArrayRef unwrapList(size_t size, CTy *first, "incompatible C and C++ types"); if (size == 0) - return std::nullopt; + return {}; assert(storage.empty() && "expected to populate storage"); storage.reserve(size); diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td index 8584a25f8b3d6..18dbdba746269 100644 --- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td +++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td @@ -371,7 +371,7 @@ def LLVM_LoadOp : LLVM_MemAccessOpBase<"load", auto *inst = builder.CreateLoad($_resultType, $addr, $volatile_); $res = inst; if ($invariant) { - llvm::MDNode *metadata = llvm::MDNode::get(inst->getContext(), std::nullopt); + llvm::MDNode *metadata = llvm::MDNode::get(inst->getContext(), {}); inst->setMetadata(llvm::LLVMContext::MD_invariant_load, metadata); } }] # setOrderingCode diff --git a/mlir/include/mlir/Dialect/PDL/IR/PDLOps.td b/mlir/include/mlir/Dialect/PDL/IR/PDLOps.td index 1e108c3d8ac77..22d905ebb0a40 100644 --- a/mlir/include/mlir/Dialect/PDL/IR/PDLOps.td +++ b/mlir/include/mlir/Dialect/PDL/IR/PDLOps.td @@ -363,7 +363,7 @@ def PDL_OperationOp : PDL_Op<"operation", [AttrSizedOperandSegments]> { let builders = [ OpBuilder<(ins CArg<"std::optional", "std::nullopt">:$name, CArg<"ValueRange", "std::nullopt">:$operandValues, - CArg<"ArrayRef", "std::nullopt">:$attrNames, + CArg<"ArrayRef", "{}">:$attrNames, CArg<"ValueRange", "std::nullopt">:$attrValues, CArg<"ValueRange", "std::nullopt">:$resultTypes), [{ auto nameAttr = name ? $_builder.getStringAttr(*name) : StringAttr(); diff --git a/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h b/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h index 66f49c787c190..594cee107790f 100644 --- a/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h +++ b/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h @@ -158,7 +158,7 @@ class ExecutionEngine { /// Invokes the function with the given name passing it the list of opaque /// pointers to the actual arguments. llvm::Error invokePacked(StringRef name, - MutableArrayRef args = std::nullopt); + MutableArrayRef args = {}); /// Trait that defines how a given type is passed to the JIT code. This /// defaults to passing the address but can be specialized. diff --git a/mlir/include/mlir/IR/BlockSupport.h b/mlir/include/mlir/IR/BlockSupport.h index ff508891ac2ff..c8a70a5a1d959 100644 --- a/mlir/include/mlir/IR/BlockSupport.h +++ b/mlir/include/mlir/IR/BlockSupport.h @@ -106,7 +106,7 @@ class BlockRange final Block *, Block *, Block *> { public: using RangeBaseT::RangeBaseT; - BlockRange(ArrayRef blocks = std::nullopt); + BlockRange(ArrayRef blocks = {}); BlockRange(SuccessorRange successors); template , Arg>::value>> diff --git a/mlir/include/mlir/IR/Builders.h b/mlir/include/mlir/IR/Builders.h index 196d34e12d9b2..c2bfe84d5093f 100644 --- a/mlir/include/mlir/IR/Builders.h +++ b/mlir/include/mlir/IR/Builders.h @@ -463,14 +463,14 @@ class OpBuilder : public Builder { /// should match the size of `argTypes`. Block *createBlock(Region *parent, Region::iterator insertPt = {}, TypeRange argTypes = std::nullopt, - ArrayRef locs = std::nullopt); + ArrayRef locs = {}); /// Add new block with 'argTypes' arguments and set the insertion point to the /// end of it. The block is placed before 'insertBefore'. `locs` contains the /// locations of the inserted arguments, and should match the size of /// `argTypes`. Block *createBlock(Block *insertBefore, TypeRange argTypes = std::nullopt, - ArrayRef locs = std::nullopt); + ArrayRef locs = {}); //===--------------------------------------------------------------------===// // Operation Creation diff --git a/mlir/include/mlir/IR/BuiltinAttributes.td b/mlir/include/mlir/IR/BuiltinAttributes.td index f0d4175400140..9aa46b978cb03 100644 --- a/mlir/include/mlir/IR/BuiltinAttributes.td +++ b/mlir/include/mlir/IR/BuiltinAttributes.td @@ -516,7 +516,7 @@ def Builtin_DictionaryAttr : Builtin_Attr<"Dictionary", "dictionary"> { }]; let parameters = (ins ArrayRefParameter<"NamedAttribute", "">:$value); let builders = [ - AttrBuilder<(ins CArg<"ArrayRef", "std::nullopt">:$value)> + AttrBuilder<(ins CArg<"ArrayRef", "{}">:$value)> ]; let extraClassDeclaration = [{ using ValueType = ArrayRef; diff --git a/mlir/include/mlir/IR/BuiltinTypes.td b/mlir/include/mlir/IR/BuiltinTypes.td index c283c20f36e91..40894236d3242 100644 --- a/mlir/include/mlir/IR/BuiltinTypes.td +++ b/mlir/include/mlir/IR/BuiltinTypes.td @@ -1070,7 +1070,7 @@ def Builtin_UnrankedMemRef : Builtin_Type<"UnrankedMemRef", "unranked_memref", [ using ShapedType::Trait::getDimSize; using ShapedType::Trait::getDynamicDimIndex; - ArrayRef getShape() const { return std::nullopt; } + ArrayRef getShape() const { return {}; } /// [deprecated] Returns the memory space in old raw integer representation. /// New `Attribute getMemorySpace()` method should be used instead. @@ -1129,7 +1129,7 @@ def Builtin_UnrankedTensor : Builtin_Type<"UnrankedTensor", "unranked_tensor", [ using ShapedType::Trait::getDimSize; using ShapedType::Trait::getDynamicDimIndex; - ArrayRef getShape() const { return std::nullopt; } + ArrayRef getShape() const { return {}; } }]; let skipDefaultBuilders = 1; let genVerifyDecl = 1; diff --git a/mlir/include/mlir/IR/Matchers.h b/mlir/include/mlir/IR/Matchers.h index 6fa5a47109d20..41a8ce2d58cb9 100644 --- a/mlir/include/mlir/IR/Matchers.h +++ b/mlir/include/mlir/IR/Matchers.h @@ -88,7 +88,7 @@ struct constant_op_binder { // Fold the constant to an attribute. SmallVector foldedOp; - LogicalResult result = op->fold(/*operands=*/std::nullopt, foldedOp); + LogicalResult result = op->fold(/*operands=*/{}, foldedOp); (void)result; assert(succeeded(result) && "expected ConstantLike op to be foldable"); diff --git a/mlir/include/mlir/IR/PatternMatch.h b/mlir/include/mlir/IR/PatternMatch.h index 896fdf1c899e3..2ae25449480da 100644 --- a/mlir/include/mlir/IR/PatternMatch.h +++ b/mlir/include/mlir/IR/PatternMatch.h @@ -847,7 +847,7 @@ class RewritePatternSet { RewritePatternSet &add(ConstructorArg &&arg, ConstructorArgs &&...args) { // The following expands a call to emplace_back for each of the pattern // types 'Ts'. - (addImpl(/*debugLabels=*/std::nullopt, + (addImpl(/*debugLabels=*/{}, std::forward(arg), std::forward(args)...), ...); @@ -931,7 +931,7 @@ class RewritePatternSet { RewritePatternSet &insert(ConstructorArg &&arg, ConstructorArgs &&...args) { // The following expands a call to emplace_back for each of the pattern // types 'Ts'. - (addImpl(/*debugLabels=*/std::nullopt, arg, args...), ...); + (addImpl(/*debugLabels=*/{}, arg, args...), ...); return *this; } diff --git a/mlir/include/mlir/IR/Region.h b/mlir/include/mlir/IR/Region.h index 93fc9dbb430ee..cfcd920b33460 100644 --- a/mlir/include/mlir/IR/Region.h +++ b/mlir/include/mlir/IR/Region.h @@ -353,7 +353,7 @@ class RegionRange public: using RangeBaseT::RangeBaseT; - RegionRange(MutableArrayRef regions = std::nullopt); + RegionRange(MutableArrayRef regions = {}); template >, Arg>::value>> diff --git a/mlir/include/mlir/IR/SymbolTable.h b/mlir/include/mlir/IR/SymbolTable.h index 597c6a9a1d891..090b01a324581 100644 --- a/mlir/include/mlir/IR/SymbolTable.h +++ b/mlir/include/mlir/IR/SymbolTable.h @@ -395,7 +395,7 @@ class SymbolUserMap { /// Return the users of the provided symbol operation. ArrayRef getUsers(Operation *symbol) const { auto it = symbolToUsers.find(symbol); - return it != symbolToUsers.end() ? it->second.getArrayRef() : std::nullopt; + return it != symbolToUsers.end() ? it->second.getArrayRef() : ArrayRef(); } /// Return true if the given symbol has no uses. diff --git a/mlir/include/mlir/IR/TypeRange.h b/mlir/include/mlir/IR/TypeRange.h index 99fabab334f92..424366d6a5a8d 100644 --- a/mlir/include/mlir/IR/TypeRange.h +++ b/mlir/include/mlir/IR/TypeRange.h @@ -36,7 +36,7 @@ class TypeRange : public llvm::detail::indexed_accessor_range_base< Type, Type, Type> { public: using RangeBaseT::RangeBaseT; - TypeRange(ArrayRef types = std::nullopt); + TypeRange(ArrayRef types = {}); explicit TypeRange(OperandRange values); explicit TypeRange(ResultRange values); explicit TypeRange(ValueRange values); @@ -47,6 +47,8 @@ class TypeRange : public llvm::detail::indexed_accessor_range_base< template , Arg>::value>> TypeRange(Arg &&arg) : TypeRange(ArrayRef(std::forward(arg))) {} + TypeRange(std::nullopt_t) + : TypeRange(ArrayRef()) {} TypeRange(std::initializer_list types) : TypeRange(ArrayRef(types)) {} diff --git a/mlir/include/mlir/IR/ValueRange.h b/mlir/include/mlir/IR/ValueRange.h index 4b421c08d8418..b934622fa80c1 100644 --- a/mlir/include/mlir/IR/ValueRange.h +++ b/mlir/include/mlir/IR/ValueRange.h @@ -123,7 +123,7 @@ class MutableOperandRange { /// and range length. `operandSegments` is an optional set of operand segments /// to be updated when mutating the operand list. MutableOperandRange(Operation *owner, unsigned start, unsigned length, - ArrayRef operandSegments = std::nullopt); + ArrayRef operandSegments = {}); MutableOperandRange(Operation *owner); /// Construct a new mutable range for the given OpOperand. @@ -392,6 +392,7 @@ class ValueRange final std::is_constructible, Arg>::value && !std::is_convertible::value>> ValueRange(Arg &&arg) : ValueRange(ArrayRef(std::forward(arg))) {} + ValueRange(std::nullopt_t) : ValueRange(ArrayRef()) {} ValueRange(const Value &value) : ValueRange(&value, /*count=*/1) {} ValueRange(const std::initializer_list &values) : ValueRange(ArrayRef(values)) {} @@ -401,7 +402,7 @@ class ValueRange final : ValueRange(ResultRange(values)) {} ValueRange(ArrayRef values) : ValueRange(ArrayRef(values.data(), values.size())) {} - ValueRange(ArrayRef values = std::nullopt); + ValueRange(ArrayRef values = {}); ValueRange(OperandRange values); ValueRange(ResultRange values); diff --git a/mlir/include/mlir/Rewrite/FrozenRewritePatternSet.h b/mlir/include/mlir/Rewrite/FrozenRewritePatternSet.h index 4c6e3cd9ce6f4..aeec4e875f4b2 100644 --- a/mlir/include/mlir/Rewrite/FrozenRewritePatternSet.h +++ b/mlir/include/mlir/Rewrite/FrozenRewritePatternSet.h @@ -49,8 +49,8 @@ class FrozenRewritePatternSet { /// their type name. FrozenRewritePatternSet( RewritePatternSet &&patterns, - ArrayRef disabledPatternLabels = std::nullopt, - ArrayRef enabledPatternLabels = std::nullopt); + ArrayRef disabledPatternLabels = {}, + ArrayRef enabledPatternLabels = {}); /// Return the op specific native patterns held by this list. const OpSpecificNativePatternListT &getOpSpecificNativePatterns() const { diff --git a/mlir/include/mlir/Support/StorageUniquer.h b/mlir/include/mlir/Support/StorageUniquer.h index 26bdf09abba21..1a89081074ec1 100644 --- a/mlir/include/mlir/Support/StorageUniquer.h +++ b/mlir/include/mlir/Support/StorageUniquer.h @@ -97,7 +97,7 @@ class StorageUniquer { template ArrayRef copyInto(ArrayRef elements) { if (elements.empty()) - return std::nullopt; + return {}; auto result = allocator.Allocate(elements.size()); std::uninitialized_copy(elements.begin(), elements.end(), result); return ArrayRef(result, elements.size()); diff --git a/mlir/include/mlir/Tools/PDLL/AST/Nodes.h b/mlir/include/mlir/Tools/PDLL/AST/Nodes.h index aed2562e4d30d..49b596e47c61d 100644 --- a/mlir/include/mlir/Tools/PDLL/AST/Nodes.h +++ b/mlir/include/mlir/Tools/PDLL/AST/Nodes.h @@ -897,7 +897,7 @@ class UserConstraintDecl final ArrayRef results, const CompoundStmt *body, Type resultType) { - return createImpl(ctx, name, inputs, /*nativeInputTypes=*/std::nullopt, + return createImpl(ctx, name, inputs, /*nativeInputTypes=*/{}, results, /*codeBlock=*/std::nullopt, body, resultType); } diff --git a/mlir/include/mlir/Tools/PDLL/AST/Types.h b/mlir/include/mlir/Tools/PDLL/AST/Types.h index 89c8e193ddc32..620351f737129 100644 --- a/mlir/include/mlir/Tools/PDLL/AST/Types.h +++ b/mlir/include/mlir/Tools/PDLL/AST/Types.h @@ -254,7 +254,7 @@ class TupleType : public Type::TypeBase { static TupleType get(Context &context, ArrayRef elementTypes, ArrayRef elementNames); static TupleType get(Context &context, - ArrayRef elementTypes = std::nullopt); + ArrayRef elementTypes = {}); /// Return the element types of this tuple. ArrayRef getElementTypes() const; diff --git a/mlir/include/mlir/Transforms/Passes.h b/mlir/include/mlir/Transforms/Passes.h index 8e4a43c3f2458..b0afc7b16fc41 100644 --- a/mlir/include/mlir/Transforms/Passes.h +++ b/mlir/include/mlir/Transforms/Passes.h @@ -61,8 +61,8 @@ std::unique_ptr createCanonicalizerPass(); /// set to their type name. std::unique_ptr createCanonicalizerPass(const GreedyRewriteConfig &config, - ArrayRef disabledPatterns = std::nullopt, - ArrayRef enabledPatterns = std::nullopt); + ArrayRef disabledPatterns = {}, + ArrayRef enabledPatterns = {}); /// Creates a pass to perform control-flow sinking. std::unique_ptr createControlFlowSinkPass(); diff --git a/mlir/lib/Conversion/PDLToPDLInterp/PDLToPDLInterp.cpp b/mlir/lib/Conversion/PDLToPDLInterp/PDLToPDLInterp.cpp index b00cd0dee3ae8..cb10671ac5b79 100644 --- a/mlir/lib/Conversion/PDLToPDLInterp/PDLToPDLInterp.cpp +++ b/mlir/lib/Conversion/PDLToPDLInterp/PDLToPDLInterp.cpp @@ -991,7 +991,7 @@ void PDLToPDLInterpPass::runOnOperation() { module.getLoc(), pdl_interp::PDLInterpDialect::getMatcherFunctionName(), builder.getFunctionType(builder.getType(), /*results=*/std::nullopt), - /*attrs=*/std::nullopt); + /*attrs=*/ArrayRef()); // Create a nested module to hold the functions invoked for rewriting the IR // after a successful match. diff --git a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp index 93e284af05188..0780105761169 100644 --- a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp +++ b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp @@ -250,7 +250,7 @@ static Value createLinalgBodyCalculationForElementwiseOp( rewriter.create(loc, resultTypes, args[0], subtract) ->getResults(); auto truncated = - rewriter.create(loc, i1Ty, shifted, std::nullopt); + rewriter.create(loc, i1Ty, shifted, llvm::ArrayRef()); auto isInputOdd = rewriter.create(loc, i1Ty, truncated, i1one); @@ -453,20 +453,20 @@ static Value createLinalgBodyCalculationForElementwiseOp( if (isa(srcTy) && isa(dstTy) && bitExtend) return rewriter.create(loc, resultTypes, args, - std::nullopt); + llvm::ArrayRef()); if (isa(srcTy) && isa(dstTy) && !bitExtend) return rewriter.create(loc, resultTypes, args, - std::nullopt); + llvm::ArrayRef()); // 1-bit integers need to be treated as signless. if (srcTy.isInteger(1) && arith::UIToFPOp::areCastCompatible(srcTy, dstTy)) return rewriter.create(loc, resultTypes, args, - std::nullopt); + llvm::ArrayRef()); if (srcTy.isInteger(1) && isa(dstTy) && bitExtend) return rewriter.create(loc, resultTypes, args, - std::nullopt); + llvm::ArrayRef()); // Unsigned integers need an unrealized cast so that they can be passed // to UIToFP. @@ -484,7 +484,7 @@ static Value createLinalgBodyCalculationForElementwiseOp( // All other si-to-fp conversions should be handled by SIToFP. if (arith::SIToFPOp::areCastCompatible(srcTy, dstTy)) return rewriter.create(loc, resultTypes, args, - std::nullopt); + llvm::ArrayRef()); // Casting to boolean, floats need to only be checked as not-equal to zero. if (isa(srcTy) && dstTy.isInteger(1)) { @@ -590,7 +590,7 @@ static Value createLinalgBodyCalculationForElementwiseOp( if (isa(srcTy) && isa(dstTy) && bitExtend) return rewriter.create(loc, resultTypes, args, - std::nullopt); + llvm::ArrayRef()); if (isa(srcTy) && isa(dstTy) && !bitExtend) { return rewriter.create(loc, dstTy, args[0]); diff --git a/mlir/lib/Dialect/Async/IR/Async.cpp b/mlir/lib/Dialect/Async/IR/Async.cpp index a3e3f80954efc..fda8516a15c39 100644 --- a/mlir/lib/Dialect/Async/IR/Async.cpp +++ b/mlir/lib/Dialect/Async/IR/Async.cpp @@ -309,7 +309,7 @@ void FuncOp::build(OpBuilder &builder, OperationState &state, StringRef name, return; assert(type.getNumInputs() == argAttrs.size()); function_interface_impl::addArgAndResultAttrs( - builder, state, argAttrs, /*resultAttrs=*/std::nullopt, + builder, state, argAttrs, /*resultAttrs=*/{}, getArgAttrsAttrName(state.name), getResAttrsAttrName(state.name)); } diff --git a/mlir/lib/Dialect/EmitC/IR/EmitC.cpp b/mlir/lib/Dialect/EmitC/IR/EmitC.cpp index fdc21d6c6e24b..17afc274e07a2 100644 --- a/mlir/lib/Dialect/EmitC/IR/EmitC.cpp +++ b/mlir/lib/Dialect/EmitC/IR/EmitC.cpp @@ -530,7 +530,7 @@ void FuncOp::build(OpBuilder &builder, OperationState &state, StringRef name, return; assert(type.getNumInputs() == argAttrs.size()); function_interface_impl::addArgAndResultAttrs( - builder, state, argAttrs, /*resultAttrs=*/std::nullopt, + builder, state, argAttrs, /*resultAttrs=*/{}, getArgAttrsAttrName(state.name), getResAttrsAttrName(state.name)); } diff --git a/mlir/lib/Dialect/Func/IR/FuncOps.cpp b/mlir/lib/Dialect/Func/IR/FuncOps.cpp index a490b4c3c4ab4..3037735d30c3b 100644 --- a/mlir/lib/Dialect/Func/IR/FuncOps.cpp +++ b/mlir/lib/Dialect/Func/IR/FuncOps.cpp @@ -191,7 +191,7 @@ void FuncOp::build(OpBuilder &builder, OperationState &state, StringRef name, return; assert(type.getNumInputs() == argAttrs.size()); function_interface_impl::addArgAndResultAttrs( - builder, state, argAttrs, /*resultAttrs=*/std::nullopt, + builder, state, argAttrs, /*resultAttrs=*/{}, getArgAttrsAttrName(state.name), getResAttrsAttrName(state.name)); } diff --git a/mlir/lib/Dialect/GPU/Transforms/DecomposeMemRefs.cpp b/mlir/lib/Dialect/GPU/Transforms/DecomposeMemRefs.cpp index 2b2d10a7733ec..7199aa2a41e80 100644 --- a/mlir/lib/Dialect/GPU/Transforms/DecomposeMemRefs.cpp +++ b/mlir/lib/Dialect/GPU/Transforms/DecomposeMemRefs.cpp @@ -44,7 +44,7 @@ static bool isInsideLaunch(Operation *op) { static std::tuple> getFlatOffsetAndStrides(OpBuilder &rewriter, Location loc, Value source, ArrayRef subOffsets, - ArrayRef subStrides = std::nullopt) { + ArrayRef subStrides = {}) { auto sourceType = cast(source.getType()); auto sourceRank = static_cast(sourceType.getRank()); @@ -100,7 +100,7 @@ static Value getFlatMemref(OpBuilder &rewriter, Location loc, Value source, getFlatOffsetAndStrides(rewriter, loc, source, offsetsTemp); auto retType = cast(base.getType()); return rewriter.create(loc, retType, base, offset, - std::nullopt, std::nullopt); + llvm::ArrayRef(), llvm::ArrayRef()); } static bool needFlatten(Value val) { diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp index 205d7494d4378..964a16ec3841b 100644 --- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp @@ -2304,7 +2304,7 @@ void LLVMFuncOp::build(OpBuilder &builder, OperationState &result, assert(llvm::cast(type).getNumParams() == argAttrs.size() && "expected as many argument attribute lists as arguments"); function_interface_impl::addArgAndResultAttrs( - builder, result, argAttrs, /*resultAttrs=*/std::nullopt, + builder, result, argAttrs, /*resultAttrs=*/{}, getArgAttrsAttrName(result.name), getResAttrsAttrName(result.name)); } diff --git a/mlir/lib/Dialect/LLVMIR/IR/TypeDetail.h b/mlir/lib/Dialect/LLVMIR/IR/TypeDetail.h index 8767b1c3ffc5b..081a89d0b5dc7 100644 --- a/mlir/lib/Dialect/LLVMIR/IR/TypeDetail.h +++ b/mlir/lib/Dialect/LLVMIR/IR/TypeDetail.h @@ -69,7 +69,7 @@ struct LLVMStructTypeStorage : public TypeStorage { class Key { public: /// Constructs a key for an identified struct. - Key(StringRef name, bool opaque, ArrayRef types = std::nullopt) + Key(StringRef name, bool opaque, ArrayRef types = {}) : types(types), name(name), identified(true), packed(false), opaque(opaque) {} /// Constructs a key for a literal struct. diff --git a/mlir/lib/Dialect/Shape/IR/Shape.cpp b/mlir/lib/Dialect/Shape/IR/Shape.cpp index 8eb8e579954fa..0aaa657ef2e16 100644 --- a/mlir/lib/Dialect/Shape/IR/Shape.cpp +++ b/mlir/lib/Dialect/Shape/IR/Shape.cpp @@ -1290,7 +1290,7 @@ void FuncOp::build(OpBuilder &builder, OperationState &state, StringRef name, return; assert(type.getNumInputs() == argAttrs.size()); function_interface_impl::addArgAndResultAttrs( - builder, state, argAttrs, /*resultAttrs=*/std::nullopt, + builder, state, argAttrs, /*resultAttrs=*/{}, getArgAttrsAttrName(state.name), getResAttrsAttrName(state.name)); } diff --git a/mlir/lib/IR/Diagnostics.cpp b/mlir/lib/IR/Diagnostics.cpp index 7eb3d5bcd07f1..ef61a65735ae1 100644 --- a/mlir/lib/IR/Diagnostics.cpp +++ b/mlir/lib/IR/Diagnostics.cpp @@ -710,7 +710,7 @@ SourceMgrDiagnosticVerifierHandlerImpl::computeExpectedDiags( raw_ostream &os, llvm::SourceMgr &mgr, const llvm::MemoryBuffer *buf) { // If the buffer is invalid, return an empty list. if (!buf) - return std::nullopt; + return {}; auto &expectedDiags = expectedDiagsPerFile[buf->getBufferIdentifier()]; // The number of the last line that did not correlate to a designator. diff --git a/mlir/lib/Interfaces/FunctionInterfaces.cpp b/mlir/lib/Interfaces/FunctionInterfaces.cpp index 80f47a3f83676..6ac5aead96926 100644 --- a/mlir/lib/Interfaces/FunctionInterfaces.cpp +++ b/mlir/lib/Interfaces/FunctionInterfaces.cpp @@ -44,14 +44,14 @@ function_interface_impl::getResultAttrDict(FunctionOpInterface op, ArrayRef function_interface_impl::getArgAttrs(FunctionOpInterface op, unsigned index) { auto argDict = getArgAttrDict(op, index); - return argDict ? argDict.getValue() : std::nullopt; + return argDict ? argDict.getValue() : ArrayRef(); } ArrayRef function_interface_impl::getResultAttrs(FunctionOpInterface op, unsigned index) { auto resultDict = getResultAttrDict(op, index); - return resultDict ? resultDict.getValue() : std::nullopt; + return resultDict ? resultDict.getValue() : ArrayRef(); } /// Get either the argument or result attributes array. diff --git a/mlir/lib/Pass/PassStatistics.cpp b/mlir/lib/Pass/PassStatistics.cpp index 779dcfe7b6661..01191aa824440 100644 --- a/mlir/lib/Pass/PassStatistics.cpp +++ b/mlir/lib/Pass/PassStatistics.cpp @@ -27,7 +27,7 @@ struct Statistic { /// Utility to print a pass entry in the statistics output. static void printPassEntry(raw_ostream &os, unsigned indent, StringRef pass, - MutableArrayRef stats = std::nullopt) { + MutableArrayRef stats = {}) { os.indent(indent) << pass << "\n"; if (stats.empty()) return; diff --git a/mlir/lib/Reducer/Tester.cpp b/mlir/lib/Reducer/Tester.cpp index 14760c0be70df..03f12af174839 100644 --- a/mlir/lib/Reducer/Tester.cpp +++ b/mlir/lib/Reducer/Tester.cpp @@ -68,7 +68,7 @@ Tester::Interestingness Tester::isInteresting(StringRef testCase) const { std::string errMsg; int result = llvm::sys::ExecuteAndWait( - testScript, testerArgs, /*Env=*/std::nullopt, /*Redirects=*/std::nullopt, + testScript, testerArgs, /*Env=*/std::nullopt, /*Redirects=*/{}, /*SecondsToWait=*/0, /*MemoryLimit=*/0, &errMsg); if (result < 0) diff --git a/mlir/lib/Target/LLVMIR/LoopAnnotationTranslation.cpp b/mlir/lib/Target/LLVMIR/LoopAnnotationTranslation.cpp index 1dde457b5c34f..d98a90016c109 100644 --- a/mlir/lib/Target/LLVMIR/LoopAnnotationTranslation.cpp +++ b/mlir/lib/Target/LLVMIR/LoopAnnotationTranslation.cpp @@ -206,7 +206,7 @@ void LoopAnnotationConversion::convertLocation(FusedLoc location) { llvm::MDNode *LoopAnnotationConversion::convert() { // Reserve operand 0 for loop id self reference. - auto dummy = llvm::MDNode::getTemporary(ctx, std::nullopt); + auto dummy = llvm::MDNode::getTemporary(ctx, {}); metadataNodes.push_back(dummy.get()); if (FusedLoc startLoc = attr.getStartLoc()) diff --git a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp index fcb329eb7a92c..a73bc790ca3cb 100644 --- a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp +++ b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp @@ -1673,7 +1673,7 @@ ModuleTranslation::getOrCreateAliasScope(AliasScopeAttr aliasScopeAttr) { if (!scopeInserted) return scopeIt->second; llvm::LLVMContext &ctx = llvmModule->getContext(); - auto dummy = llvm::MDNode::getTemporary(ctx, std::nullopt); + auto dummy = llvm::MDNode::getTemporary(ctx, {}); // Convert the domain metadata node if necessary. auto [domainIt, insertedDomain] = aliasDomainMetadataMapping.try_emplace( aliasScopeAttr.getDomain(), nullptr); diff --git a/mlir/lib/Tools/PDLL/CodeGen/MLIRGen.cpp b/mlir/lib/Tools/PDLL/CodeGen/MLIRGen.cpp index 964d94c9c0a46..94a2766774d66 100644 --- a/mlir/lib/Tools/PDLL/CodeGen/MLIRGen.cpp +++ b/mlir/lib/Tools/PDLL/CodeGen/MLIRGen.cpp @@ -351,7 +351,7 @@ Value CodeGen::genNonInitializerVar(const ast::VariableDecl *varDecl, loc, pdl::RangeType::get(builder.getType()), /*types=*/ArrayAttr()); return builder.create( - loc, opType.getName(), operands, std::nullopt, ValueRange(), results); + loc, opType.getName(), operands, llvm::ArrayRef(), ValueRange(), results); } if (ast::RangeType rangeTy = dyn_cast(type)) { diff --git a/mlir/lib/Tools/PDLL/Parser/Parser.cpp b/mlir/lib/Tools/PDLL/Parser/Parser.cpp index 575fb4aacd947..378c032f0ba5a 100644 --- a/mlir/lib/Tools/PDLL/Parser/Parser.cpp +++ b/mlir/lib/Tools/PDLL/Parser/Parser.cpp @@ -984,7 +984,7 @@ ast::Decl *Parser::createODSNativePDLLConstraintDecl( // Build the native constraint. auto *constraintDecl = ast::UserConstraintDecl::createNative( ctx, ast::Name::create(ctx, name, loc), paramVar, - /*results=*/std::nullopt, codeBlock, ast::TupleType::get(ctx), + /*results=*/{}, codeBlock, ast::TupleType::get(ctx), nativeType); constraintDecl->setDocComment(ctx, docString); curDeclScope->add(constraintDecl); @@ -1780,7 +1780,7 @@ Parser::parseConstraint(std::optional &typeConstraint, FailureOr Parser::parseArgOrResultConstraint() { std::optional typeConstraint; - return parseConstraint(typeConstraint, /*existingConstraints=*/std::nullopt, + return parseConstraint(typeConstraint, /*existingConstraints=*/{}, /*allowInlineTypeConstraints=*/false); } @@ -2877,7 +2877,7 @@ Parser::validateOperationOperands(SMRange loc, std::optional name, SmallVectorImpl &operands) { return validateOperationOperandsOrResults( "operand", loc, odsOp ? odsOp->getLoc() : std::optional(), name, - operands, odsOp ? odsOp->getOperands() : std::nullopt, valueTy, + operands, odsOp ? odsOp->getOperands() : ArrayRef(), valueTy, valueRangeTy); } @@ -2887,7 +2887,7 @@ Parser::validateOperationResults(SMRange loc, std::optional name, SmallVectorImpl &results) { return validateOperationOperandsOrResults( "result", loc, odsOp ? odsOp->getLoc() : std::optional(), name, - results, odsOp ? odsOp->getResults() : std::nullopt, typeTy, typeRangeTy); + results, odsOp ? odsOp->getResults() : ArrayRef(), typeTy, typeRangeTy); } void Parser::checkOperationResultTypeInferrence(SMRange loc, StringRef opName, @@ -2987,7 +2987,7 @@ LogicalResult Parser::validateOperationOperandsOrResults( // adhere to the ODS signature. for (unsigned i = 0, e = odsValues.size(); i < e; ++i) { values.push_back(ast::RangeExpr::create( - ctx, loc, /*elements=*/std::nullopt, rangeTy)); + ctx, loc, /*elements=*/{}, rangeTy)); } return success(); } diff --git a/mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp b/mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp index 76b066feb6930..3ef3aebe0c88e 100644 --- a/mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp +++ b/mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp @@ -1044,7 +1044,7 @@ class LSPSignatureHelpContext : public CodeCompleteContext { const ods::Operation *odsOp = opName ? odsContext.lookupOperation(*opName) : nullptr; codeCompleteOperationOperandOrResultSignature( - opName, odsOp, odsOp ? odsOp->getOperands() : std::nullopt, + opName, odsOp, odsOp ? odsOp->getOperands() : ArrayRef(), currentNumOperands, "operand", "Value"); } @@ -1053,7 +1053,7 @@ class LSPSignatureHelpContext : public CodeCompleteContext { const ods::Operation *odsOp = opName ? odsContext.lookupOperation(*opName) : nullptr; codeCompleteOperationOperandOrResultSignature( - opName, odsOp, odsOp ? odsOp->getResults() : std::nullopt, + opName, odsOp, odsOp ? odsOp->getResults() : ArrayRef(), currentNumResults, "result", "Type"); } diff --git a/mlir/test/lib/Dialect/Test/TestAttributes.cpp b/mlir/test/lib/Dialect/Test/TestAttributes.cpp index e09ea10906164..d62f7a24a65b3 100644 --- a/mlir/test/lib/Dialect/Test/TestAttributes.cpp +++ b/mlir/test/lib/Dialect/Test/TestAttributes.cpp @@ -194,7 +194,7 @@ void TestSubElementsAccessAttr::print(::mlir::AsmPrinter &printer) const { ArrayRef TestExtern1DI64ElementsAttr::getElements() const { if (auto *blob = getHandle().getBlob()) return blob->getDataAs(); - return std::nullopt; + return {}; } //===----------------------------------------------------------------------===// diff --git a/mlir/test/lib/Dialect/Test/TestPatterns.cpp b/mlir/test/lib/Dialect/Test/TestPatterns.cpp index 3cbc307835afd..5886fcda15a1d 100644 --- a/mlir/test/lib/Dialect/Test/TestPatterns.cpp +++ b/mlir/test/lib/Dialect/Test/TestPatterns.cpp @@ -903,7 +903,7 @@ struct TestPassthroughInvalidOp : public ConversionPattern { matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const final { rewriter.replaceOpWithNewOp(op, std::nullopt, operands, - std::nullopt); + llvm::ArrayRef()); return success(); } }; @@ -919,7 +919,7 @@ struct TestDropAndReplaceInvalidOp : public ConversionPattern { matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const final { rewriter.replaceOpWithNewOp(op, std::nullopt, ValueRange(), - std::nullopt); + llvm::ArrayRef()); return success(); } }; diff --git a/mlir/unittests/Debug/FileLineColLocBreakpointManagerTest.cpp b/mlir/unittests/Debug/FileLineColLocBreakpointManagerTest.cpp index 5b48e80749c8b..e9a57f9084220 100644 --- a/mlir/unittests/Debug/FileLineColLocBreakpointManagerTest.cpp +++ b/mlir/unittests/Debug/FileLineColLocBreakpointManagerTest.cpp @@ -25,7 +25,7 @@ static Operation *createOp(MLIRContext *context, Location loc, context->allowUnregisteredDialects(); return Operation::create(loc, OperationName(operationName, context), std::nullopt, std::nullopt, std::nullopt, - OpaqueProperties(nullptr), std::nullopt, numRegions); + OpaqueProperties(nullptr), BlockRange(), numRegions); } namespace { diff --git a/mlir/unittests/IR/OperationSupportTest.cpp b/mlir/unittests/IR/OperationSupportTest.cpp index f94dc78445807..4d0f32aadb96d 100644 --- a/mlir/unittests/IR/OperationSupportTest.cpp +++ b/mlir/unittests/IR/OperationSupportTest.cpp @@ -19,13 +19,13 @@ using namespace mlir; using namespace mlir::detail; static Operation *createOp(MLIRContext *context, - ArrayRef operands = std::nullopt, - ArrayRef resultTypes = std::nullopt, + ArrayRef operands = {}, + ArrayRef resultTypes = {}, unsigned int numRegions = 0) { context->allowUnregisteredDialects(); return Operation::create( UnknownLoc::get(context), OperationName("foo.bar", context), resultTypes, - operands, std::nullopt, nullptr, std::nullopt, numRegions); + operands, std::nullopt, nullptr, BlockRange(), numRegions); } namespace { @@ -34,7 +34,7 @@ TEST(OperandStorageTest, NonResizable) { Builder builder(&context); Operation *useOp = - createOp(&context, /*operands=*/std::nullopt, builder.getIntegerType(16)); + createOp(&context, /*operands=*/{}, builder.getIntegerType(16)); Value operand = useOp->getResult(0); // Create a non-resizable operation with one operand. @@ -58,7 +58,7 @@ TEST(OperandStorageTest, Resizable) { Builder builder(&context); Operation *useOp = - createOp(&context, /*operands=*/std::nullopt, builder.getIntegerType(16)); + createOp(&context, /*operands=*/{}, builder.getIntegerType(16)); Value operand = useOp->getResult(0); // Create a resizable operation with one operand. @@ -86,7 +86,7 @@ TEST(OperandStorageTest, RangeReplace) { Builder builder(&context); Operation *useOp = - createOp(&context, /*operands=*/std::nullopt, builder.getIntegerType(16)); + createOp(&context, /*operands=*/{}, builder.getIntegerType(16)); Value operand = useOp->getResult(0); // Create a resizable operation with one operand. @@ -122,7 +122,7 @@ TEST(OperandStorageTest, MutableRange) { Builder builder(&context); Operation *useOp = - createOp(&context, /*operands=*/std::nullopt, builder.getIntegerType(16)); + createOp(&context, /*operands=*/{}, builder.getIntegerType(16)); Value operand = useOp->getResult(0); // Create a resizable operation with one operand. @@ -160,7 +160,7 @@ TEST(OperandStorageTest, RangeErase) { Type type = builder.getNoneType(); Operation *useOp = - createOp(&context, /*operands=*/std::nullopt, {type, type}); + createOp(&context, /*operands=*/{}, {type, type}); Value operand1 = useOp->getResult(0); Value operand2 = useOp->getResult(1); @@ -190,8 +190,8 @@ TEST(OperationOrderTest, OrderIsAlwaysValid) { MLIRContext context; Builder builder(&context); - Operation *containerOp = createOp(&context, /*operands=*/std::nullopt, - /*resultTypes=*/std::nullopt, + Operation *containerOp = createOp(&context, /*operands=*/{}, + /*resultTypes=*/{}, /*numRegions=*/1); Region ®ion = containerOp->getRegion(0); Block *block = new Block(); diff --git a/mlir/unittests/Transforms/DialectConversion.cpp b/mlir/unittests/Transforms/DialectConversion.cpp index 10d7fb041278d..389d80c19963f 100644 --- a/mlir/unittests/Transforms/DialectConversion.cpp +++ b/mlir/unittests/Transforms/DialectConversion.cpp @@ -15,7 +15,7 @@ static Operation *createOp(MLIRContext *context) { context->allowUnregisteredDialects(); return Operation::create( UnknownLoc::get(context), OperationName("foo.bar", context), std::nullopt, - std::nullopt, std::nullopt, /*properties=*/nullptr, std::nullopt, 0); + std::nullopt, std::nullopt, /*properties=*/nullptr, BlockRange(), 0); } namespace { From 27ad38f3e83e275a8a2a8e4f65acd1da3acca424 Mon Sep 17 00:00:00 2001 From: Jay Foad Date: Sat, 21 Sep 2024 10:49:25 +0100 Subject: [PATCH 2/2] clang-format --- .../include/mlir/ExecutionEngine/ExecutionEngine.h | 3 +-- mlir/include/mlir/IR/PatternMatch.h | 3 +-- mlir/include/mlir/IR/SymbolTable.h | 3 ++- mlir/include/mlir/IR/TypeRange.h | 3 +-- .../include/mlir/Rewrite/FrozenRewritePatternSet.h | 7 +++---- mlir/include/mlir/Tools/PDLL/AST/Nodes.h | 4 ++-- mlir/include/mlir/Tools/PDLL/AST/Types.h | 3 +-- mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp | 4 ++-- .../Dialect/GPU/Transforms/DecomposeMemRefs.cpp | 5 +++-- mlir/lib/Tools/PDLL/CodeGen/MLIRGen.cpp | 5 +++-- mlir/lib/Tools/PDLL/Parser/Parser.cpp | 14 +++++++------- mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp | 6 ++++-- mlir/unittests/IR/OperationSupportTest.cpp | 6 ++---- 13 files changed, 32 insertions(+), 34 deletions(-) diff --git a/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h b/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h index 594cee107790f..96ccebcd5685e 100644 --- a/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h +++ b/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h @@ -157,8 +157,7 @@ class ExecutionEngine { /// Invokes the function with the given name passing it the list of opaque /// pointers to the actual arguments. - llvm::Error invokePacked(StringRef name, - MutableArrayRef args = {}); + llvm::Error invokePacked(StringRef name, MutableArrayRef args = {}); /// Trait that defines how a given type is passed to the JIT code. This /// defaults to passing the address but can be specialized. diff --git a/mlir/include/mlir/IR/PatternMatch.h b/mlir/include/mlir/IR/PatternMatch.h index 2ae25449480da..93ca1d9d5aa3c 100644 --- a/mlir/include/mlir/IR/PatternMatch.h +++ b/mlir/include/mlir/IR/PatternMatch.h @@ -847,8 +847,7 @@ class RewritePatternSet { RewritePatternSet &add(ConstructorArg &&arg, ConstructorArgs &&...args) { // The following expands a call to emplace_back for each of the pattern // types 'Ts'. - (addImpl(/*debugLabels=*/{}, - std::forward(arg), + (addImpl(/*debugLabels=*/{}, std::forward(arg), std::forward(args)...), ...); return *this; diff --git a/mlir/include/mlir/IR/SymbolTable.h b/mlir/include/mlir/IR/SymbolTable.h index 090b01a324581..b3953cdf42bdf 100644 --- a/mlir/include/mlir/IR/SymbolTable.h +++ b/mlir/include/mlir/IR/SymbolTable.h @@ -395,7 +395,8 @@ class SymbolUserMap { /// Return the users of the provided symbol operation. ArrayRef getUsers(Operation *symbol) const { auto it = symbolToUsers.find(symbol); - return it != symbolToUsers.end() ? it->second.getArrayRef() : ArrayRef(); + return it != symbolToUsers.end() ? it->second.getArrayRef() + : ArrayRef(); } /// Return true if the given symbol has no uses. diff --git a/mlir/include/mlir/IR/TypeRange.h b/mlir/include/mlir/IR/TypeRange.h index 424366d6a5a8d..67897c2c3db8f 100644 --- a/mlir/include/mlir/IR/TypeRange.h +++ b/mlir/include/mlir/IR/TypeRange.h @@ -47,8 +47,7 @@ class TypeRange : public llvm::detail::indexed_accessor_range_base< template , Arg>::value>> TypeRange(Arg &&arg) : TypeRange(ArrayRef(std::forward(arg))) {} - TypeRange(std::nullopt_t) - : TypeRange(ArrayRef()) {} + TypeRange(std::nullopt_t) : TypeRange(ArrayRef()) {} TypeRange(std::initializer_list types) : TypeRange(ArrayRef(types)) {} diff --git a/mlir/include/mlir/Rewrite/FrozenRewritePatternSet.h b/mlir/include/mlir/Rewrite/FrozenRewritePatternSet.h index aeec4e875f4b2..d6c431206e06e 100644 --- a/mlir/include/mlir/Rewrite/FrozenRewritePatternSet.h +++ b/mlir/include/mlir/Rewrite/FrozenRewritePatternSet.h @@ -47,10 +47,9 @@ class FrozenRewritePatternSet { /// `RewritePatternSet::addWithLabel`. Debug names may be empty, but patterns /// created with `RewritePattern::create` have their default debug name set to /// their type name. - FrozenRewritePatternSet( - RewritePatternSet &&patterns, - ArrayRef disabledPatternLabels = {}, - ArrayRef enabledPatternLabels = {}); + FrozenRewritePatternSet(RewritePatternSet &&patterns, + ArrayRef disabledPatternLabels = {}, + ArrayRef enabledPatternLabels = {}); /// Return the op specific native patterns held by this list. const OpSpecificNativePatternListT &getOpSpecificNativePatterns() const { diff --git a/mlir/include/mlir/Tools/PDLL/AST/Nodes.h b/mlir/include/mlir/Tools/PDLL/AST/Nodes.h index 49b596e47c61d..7a9e5048aebe7 100644 --- a/mlir/include/mlir/Tools/PDLL/AST/Nodes.h +++ b/mlir/include/mlir/Tools/PDLL/AST/Nodes.h @@ -897,8 +897,8 @@ class UserConstraintDecl final ArrayRef results, const CompoundStmt *body, Type resultType) { - return createImpl(ctx, name, inputs, /*nativeInputTypes=*/{}, - results, /*codeBlock=*/std::nullopt, body, resultType); + return createImpl(ctx, name, inputs, /*nativeInputTypes=*/{}, results, + /*codeBlock=*/std::nullopt, body, resultType); } /// Return the name of the constraint. diff --git a/mlir/include/mlir/Tools/PDLL/AST/Types.h b/mlir/include/mlir/Tools/PDLL/AST/Types.h index 620351f737129..aa483a81f87f5 100644 --- a/mlir/include/mlir/Tools/PDLL/AST/Types.h +++ b/mlir/include/mlir/Tools/PDLL/AST/Types.h @@ -253,8 +253,7 @@ class TupleType : public Type::TypeBase { /// Return an instance of the Tuple type. static TupleType get(Context &context, ArrayRef elementTypes, ArrayRef elementNames); - static TupleType get(Context &context, - ArrayRef elementTypes = {}); + static TupleType get(Context &context, ArrayRef elementTypes = {}); /// Return the element types of this tuple. ArrayRef getElementTypes() const; diff --git a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp index 0780105761169..ca4abe09f8d95 100644 --- a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp +++ b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp @@ -249,8 +249,8 @@ static Value createLinalgBodyCalculationForElementwiseOp( auto shifted = rewriter.create(loc, resultTypes, args[0], subtract) ->getResults(); - auto truncated = - rewriter.create(loc, i1Ty, shifted, llvm::ArrayRef()); + auto truncated = rewriter.create( + loc, i1Ty, shifted, llvm::ArrayRef()); auto isInputOdd = rewriter.create(loc, i1Ty, truncated, i1one); diff --git a/mlir/lib/Dialect/GPU/Transforms/DecomposeMemRefs.cpp b/mlir/lib/Dialect/GPU/Transforms/DecomposeMemRefs.cpp index 7199aa2a41e80..9040260f6bb41 100644 --- a/mlir/lib/Dialect/GPU/Transforms/DecomposeMemRefs.cpp +++ b/mlir/lib/Dialect/GPU/Transforms/DecomposeMemRefs.cpp @@ -99,8 +99,9 @@ static Value getFlatMemref(OpBuilder &rewriter, Location loc, Value source, auto &&[base, offset, ignore] = getFlatOffsetAndStrides(rewriter, loc, source, offsetsTemp); auto retType = cast(base.getType()); - return rewriter.create(loc, retType, base, offset, - llvm::ArrayRef(), llvm::ArrayRef()); + return rewriter.create( + loc, retType, base, offset, llvm::ArrayRef(), + llvm::ArrayRef()); } static bool needFlatten(Value val) { diff --git a/mlir/lib/Tools/PDLL/CodeGen/MLIRGen.cpp b/mlir/lib/Tools/PDLL/CodeGen/MLIRGen.cpp index 94a2766774d66..f91abd714e285 100644 --- a/mlir/lib/Tools/PDLL/CodeGen/MLIRGen.cpp +++ b/mlir/lib/Tools/PDLL/CodeGen/MLIRGen.cpp @@ -350,8 +350,9 @@ Value CodeGen::genNonInitializerVar(const ast::VariableDecl *varDecl, Value results = builder.create( loc, pdl::RangeType::get(builder.getType()), /*types=*/ArrayAttr()); - return builder.create( - loc, opType.getName(), operands, llvm::ArrayRef(), ValueRange(), results); + return builder.create(loc, opType.getName(), operands, + llvm::ArrayRef(), + ValueRange(), results); } if (ast::RangeType rangeTy = dyn_cast(type)) { diff --git a/mlir/lib/Tools/PDLL/Parser/Parser.cpp b/mlir/lib/Tools/PDLL/Parser/Parser.cpp index 378c032f0ba5a..fd10f21749144 100644 --- a/mlir/lib/Tools/PDLL/Parser/Parser.cpp +++ b/mlir/lib/Tools/PDLL/Parser/Parser.cpp @@ -984,8 +984,7 @@ ast::Decl *Parser::createODSNativePDLLConstraintDecl( // Build the native constraint. auto *constraintDecl = ast::UserConstraintDecl::createNative( ctx, ast::Name::create(ctx, name, loc), paramVar, - /*results=*/{}, codeBlock, ast::TupleType::get(ctx), - nativeType); + /*results=*/{}, codeBlock, ast::TupleType::get(ctx), nativeType); constraintDecl->setDocComment(ctx, docString); curDeclScope->add(constraintDecl); return constraintDecl; @@ -2877,8 +2876,8 @@ Parser::validateOperationOperands(SMRange loc, std::optional name, SmallVectorImpl &operands) { return validateOperationOperandsOrResults( "operand", loc, odsOp ? odsOp->getLoc() : std::optional(), name, - operands, odsOp ? odsOp->getOperands() : ArrayRef(), valueTy, - valueRangeTy); + operands, odsOp ? odsOp->getOperands() : ArrayRef(), + valueTy, valueRangeTy); } LogicalResult @@ -2887,7 +2886,8 @@ Parser::validateOperationResults(SMRange loc, std::optional name, SmallVectorImpl &results) { return validateOperationOperandsOrResults( "result", loc, odsOp ? odsOp->getLoc() : std::optional(), name, - results, odsOp ? odsOp->getResults() : ArrayRef(), typeTy, typeRangeTy); + results, odsOp ? odsOp->getResults() : ArrayRef(), + typeTy, typeRangeTy); } void Parser::checkOperationResultTypeInferrence(SMRange loc, StringRef opName, @@ -2986,8 +2986,8 @@ LogicalResult Parser::validateOperationOperandsOrResults( // Otherwise, create dummy values for each of the entries so that we // adhere to the ODS signature. for (unsigned i = 0, e = odsValues.size(); i < e; ++i) { - values.push_back(ast::RangeExpr::create( - ctx, loc, /*elements=*/{}, rangeTy)); + values.push_back( + ast::RangeExpr::create(ctx, loc, /*elements=*/{}, rangeTy)); } return success(); } diff --git a/mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp b/mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp index 3ef3aebe0c88e..3a822f9d0d4bb 100644 --- a/mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp +++ b/mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp @@ -1044,7 +1044,8 @@ class LSPSignatureHelpContext : public CodeCompleteContext { const ods::Operation *odsOp = opName ? odsContext.lookupOperation(*opName) : nullptr; codeCompleteOperationOperandOrResultSignature( - opName, odsOp, odsOp ? odsOp->getOperands() : ArrayRef(), + opName, odsOp, + odsOp ? odsOp->getOperands() : ArrayRef(), currentNumOperands, "operand", "Value"); } @@ -1053,7 +1054,8 @@ class LSPSignatureHelpContext : public CodeCompleteContext { const ods::Operation *odsOp = opName ? odsContext.lookupOperation(*opName) : nullptr; codeCompleteOperationOperandOrResultSignature( - opName, odsOp, odsOp ? odsOp->getResults() : ArrayRef(), + opName, odsOp, + odsOp ? odsOp->getResults() : ArrayRef(), currentNumResults, "result", "Type"); } diff --git a/mlir/unittests/IR/OperationSupportTest.cpp b/mlir/unittests/IR/OperationSupportTest.cpp index 4d0f32aadb96d..d4be24410d6b9 100644 --- a/mlir/unittests/IR/OperationSupportTest.cpp +++ b/mlir/unittests/IR/OperationSupportTest.cpp @@ -18,8 +18,7 @@ using namespace mlir; using namespace mlir::detail; -static Operation *createOp(MLIRContext *context, - ArrayRef operands = {}, +static Operation *createOp(MLIRContext *context, ArrayRef operands = {}, ArrayRef resultTypes = {}, unsigned int numRegions = 0) { context->allowUnregisteredDialects(); @@ -159,8 +158,7 @@ TEST(OperandStorageTest, RangeErase) { Builder builder(&context); Type type = builder.getNoneType(); - Operation *useOp = - createOp(&context, /*operands=*/{}, {type, type}); + Operation *useOp = createOp(&context, /*operands=*/{}, {type, type}); Value operand1 = useOp->getResult(0); Value operand2 = useOp->getResult(1);