This is part of an effort to migrate from llvm::Optional to
std::optional.
See also: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
Signed-off-by: Ramkumar Ramachandra <r@artagnon.com>
Paths
| Differential D138984
mlir: replace llvm::None with std::nullopt (NFC) AbandonedPublic Authored by artagnon on Nov 29 2022, 11:57 PM.
Details Summary This is part of an effort to migrate from llvm::Optional to See also: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716 Signed-off-by: Ramkumar Ramachandra <r@artagnon.com>
Diff Detail
Event TimelineHerald added subscribers: • pcwang-thead, stephenneuendorffer, nicolasvasilache, jholewinski. · View Herald Transcript artagnon added a child revision: D138934: mlir/tblgen: use std::optional in generation.Nov 30 2022, 12:09 AM Comment Actions
Are you trying to replace llvm::None first in this patch and then address None (without llvm::) later?
Comment Actions Unfortunately, there is no easy solution to replacing None without the llvm:: prefix. I edited it by hand in a few places.
Comment Actions
Yes, I know what happened: I did a replacement of llvm::None with std::nullopt in mlir/, and replaced the instance in using llvm::None by mistake. Then, I was puzzled about the compile failure: that was the reason for the stray edit. Anyway, the diff should be good now. Comment Actions
Have you considered putting [[deprecated]] in front of inline constexpr std::nullopt_t None = std::nullopt; in llvm/include/llvm/ADT/None.h? Doing so will cause the compiler to warn you every time you use None or llvm::None. You can then extract warnings from your build log and use sed and such to automatically replace llvm::None and None with std::nullopt. If I were you, I would do this mechanical replacements in non-generated code first because if you touch tablegen or .td files, you may have to update corresponding tests that check the automatic generation. You might even choose to update comments in a separate patch. The idea is to break up the big migration into series of super safe steps that are easy to review. Comment Actions Address review comment by @kazu. Now, the patch is generated by the $ find . -exec gsed -i s/llvm::Optional/std::nullopt/ {} \; Comment Actions Thanks for the suggestion @kazu! I'll try to tackle that in a follow-up patch. For now, I've updated the diff to a programmatically-generated and safe-subset replacement of llvm::Optional to std::nullopt. We should have additional assurance from the CI. I understand your concerns about wanting super-safe steps, but D138934 involved a lot of manual work, and I'm not sure how we can fix that: will it be sufficient to trust the CI in that case? Comment Actions
I am not sure how much we can rely on CI. For example, we may not be able to catch performance regressions of generated code. llvm/include/llvm/Support/Casting.h knows about Optional but not std::optional yet, so dyn_cast of an std::optional object quietly returns nullptr, which could in turn cause a missed optimization. There may be other pitfalls like this, so I am not sure if there is a better way than go through every single instance one by one.
Comment Actions
Interesting. Okay, let's try to go through the diff by hand, and find any issues: thanks a lot for volunteering to review this; it's definitely not easy. artagnon removed a child revision: D138934: mlir/tblgen: use std::optional in generation.Dec 13 2022, 6:39 AM
Revision Contents
Diff 479000 mlir/docs/AttributesAndTypes.md
mlir/docs/DialectConversion.md
mlir/docs/OpDefinitions.md
mlir/examples/toy/Ch1/include/toy/AST.h
mlir/examples/toy/Ch2/include/toy/AST.h
mlir/examples/toy/Ch2/include/toy/Ops.td
mlir/examples/toy/Ch2/mlir/MLIRGen.cpp
mlir/examples/toy/Ch3/include/toy/AST.h
mlir/examples/toy/Ch3/include/toy/Ops.td
mlir/examples/toy/Ch3/mlir/MLIRGen.cpp
mlir/examples/toy/Ch4/include/toy/AST.h
mlir/examples/toy/Ch4/include/toy/Ops.td
mlir/examples/toy/Ch4/mlir/MLIRGen.cpp
mlir/examples/toy/Ch5/include/toy/AST.h
mlir/examples/toy/Ch5/include/toy/Ops.td
mlir/examples/toy/Ch5/mlir/MLIRGen.cpp
mlir/examples/toy/Ch6/include/toy/AST.h
mlir/examples/toy/Ch6/include/toy/Ops.td
mlir/examples/toy/Ch6/mlir/MLIRGen.cpp
mlir/examples/toy/Ch7/include/toy/AST.h
mlir/examples/toy/Ch7/include/toy/Ops.td
mlir/examples/toy/Ch7/mlir/MLIRGen.cpp
mlir/include/mlir/AsmParser/AsmParserState.h
mlir/include/mlir/CAPI/Wrap.h
mlir/include/mlir/Conversion/MathToLibm/MathToLibm.h
mlir/include/mlir/Dialect/Affine/Analysis/AffineAnalysis.h
mlir/include/mlir/Dialect/Affine/Analysis/Utils.h
mlir/include/mlir/Dialect/Affine/IR/AffineOps.td
mlir/include/mlir/Dialect/Async/IR/AsyncOps.td
mlir/include/mlir/Dialect/Bufferization/IR/AllocationOpInterface.td
mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h
mlir/include/mlir/Dialect/Func/IR/FuncOps.td
mlir/include/mlir/Dialect/Func/Transforms/DecomposeCallGraphTypes.h
mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
mlir/include/mlir/Dialect/Linalg/Analysis/DependenceAnalysis.h
mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
mlir/include/mlir/Dialect/Linalg/Utils/Utils.h
mlir/include/mlir/Dialect/MLProgram/IR/MLProgramOps.td
mlir/include/mlir/Dialect/PDL/IR/PDLOps.td
mlir/include/mlir/Dialect/SCF/IR/SCFOps.td
mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAvailability.td
mlir/include/mlir/Dialect/SPIRV/IR/SPIRVStructureOps.td
mlir/include/mlir/Dialect/SPIRV/IR/SPIRVTypes.h
mlir/include/mlir/Dialect/SPIRV/IR/TargetAndABI.h
mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td
mlir/include/mlir/Dialect/SparseTensor/Utils/Merger.h
mlir/include/mlir/Dialect/Tensor/IR/TensorOps.td
mlir/include/mlir/Dialect/Tosa/Utils/CoversionUtils.h
mlir/include/mlir/Dialect/Transform/IR/TransformInterfaces.h
mlir/include/mlir/Dialect/Utils/ReshapeOpsUtils.h
mlir/include/mlir/Dialect/Vector/IR/VectorOps.h
mlir/include/mlir/Dialect/Vector/IR/VectorOps.td
mlir/include/mlir/Dialect/Vector/Interfaces/MaskableOpInterface.td
mlir/include/mlir/Dialect/Vector/Transforms/VectorRewritePatterns.h
mlir/include/mlir/ExecutionEngine/ExecutionEngine.h
mlir/include/mlir/IR/BlockSupport.h
mlir/include/mlir/IR/Builders.h
mlir/include/mlir/IR/BuiltinAttributeInterfaces.h
mlir/include/mlir/IR/BuiltinAttributeInterfaces.td
mlir/include/mlir/IR/BuiltinAttributes.td
mlir/include/mlir/IR/BuiltinOps.td
mlir/include/mlir/IR/BuiltinTypeInterfaces.td
mlir/include/mlir/IR/BuiltinTypes.td
mlir/include/mlir/IR/Diagnostics.h
mlir/include/mlir/IR/DialectImplementation.h
mlir/include/mlir/IR/FunctionInterfaces.h
mlir/include/mlir/IR/Matchers.h
mlir/include/mlir/IR/OpBase.td
mlir/include/mlir/IR/OpDefinition.h
mlir/include/mlir/IR/OpImplementation.h
mlir/include/mlir/IR/Operation.h
mlir/include/mlir/IR/OperationSupport.h
mlir/include/mlir/IR/PatternMatch.h
mlir/include/mlir/IR/Region.h
mlir/include/mlir/IR/SubElementInterfaces.h
mlir/include/mlir/IR/SymbolTable.h
mlir/include/mlir/IR/TypeRange.h
mlir/include/mlir/IR/ValueRange.h
mlir/include/mlir/Interfaces/ControlFlowInterfaces.h
mlir/include/mlir/Interfaces/ControlFlowInterfaces.td
mlir/include/mlir/Interfaces/LoopLikeInterface.td
mlir/include/mlir/Interfaces/SideEffectInterfaceBase.td
mlir/include/mlir/Pass/AnalysisManager.h
mlir/include/mlir/Pass/Pass.h
mlir/include/mlir/Pass/PassOptions.h
mlir/include/mlir/Rewrite/FrozenRewritePatternSet.h
mlir/include/mlir/Support/StorageUniquer.h
mlir/include/mlir/Support/Timing.h
mlir/include/mlir/TableGen/Operator.h
mlir/include/mlir/TableGen/Pattern.h
mlir/include/mlir/Tools/PDLL/AST/Diagnostic.h
mlir/include/mlir/Tools/PDLL/AST/Nodes.h
mlir/include/mlir/Tools/PDLL/AST/Types.h
mlir/include/mlir/Tools/mlir-translate/Translation.h
mlir/include/mlir/Transforms/DialectConversion.h
mlir/include/mlir/Transforms/InliningUtils.h
mlir/include/mlir/Transforms/Passes.h
mlir/lib/Analysis/AliasAnalysis/LocalAliasAnalysis.cpp
mlir/lib/Analysis/DataFlow/SparseAnalysis.cpp
mlir/lib/Analysis/Presburger/IntegerRelation.cpp
mlir/lib/Analysis/Presburger/PWMAFunction.cpp
mlir/lib/Analysis/Presburger/PresburgerRelation.cpp
mlir/lib/Analysis/Presburger/Utils.cpp
mlir/lib/AsmParser/AttributeParser.cpp
mlir/lib/AsmParser/Parser.h
mlir/lib/AsmParser/Parser.cpp
mlir/lib/AsmParser/Token.h
mlir/lib/AsmParser/Token.cpp
mlir/lib/AsmParser/TypeParser.cpp
mlir/lib/Bindings/Python/IRCore.cpp
mlir/lib/Bindings/Python/IRModule.cpp
mlir/lib/Bindings/Python/IRTypes.cpp
mlir/lib/Conversion/AsyncToLLVM/AsyncToLLVM.cpp
mlir/lib/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.cpp
mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp
mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp
mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp
mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp
mlir/lib/Conversion/MemRefToSPIRV/MapMemRefStorageClassPass.cpp
mlir/lib/Conversion/NVGPUToNVVM/NVGPUToNVVM.cpp
mlir/lib/Conversion/PDLToPDLInterp/PDLToPDLInterp.cpp
mlir/lib/Conversion/PDLToPDLInterp/Predicate.h
mlir/lib/Conversion/PDLToPDLInterp/PredicateTree.cpp
mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp
mlir/lib/Conversion/SCFToSPIRV/SCFToSPIRV.cpp
mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp
mlir/lib/Conversion/VectorToGPU/VectorToGPU.cpp
mlir/lib/Dialect/Affine/Analysis/AffineAnalysis.cpp
mlir/lib/Dialect/Affine/Analysis/Utils.cpp
mlir/lib/Dialect/Affine/IR/AffineOps.cpp
mlir/lib/Dialect/Affine/Transforms/AffineDataCopyGeneration.cpp
mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp
mlir/lib/Dialect/Arith/IR/ArithOps.cpp
mlir/lib/Dialect/Async/IR/Async.cpp
mlir/lib/Dialect/Bufferization/Transforms/BufferDeallocation.cpp
mlir/lib/Dialect/Bufferization/Transforms/BufferUtils.cpp
mlir/lib/Dialect/Bufferization/Transforms/BufferViewFlowAnalysis.cpp
mlir/lib/Dialect/Bufferization/Transforms/TensorCopyInsertion.cpp
mlir/lib/Dialect/Func/IR/FuncOps.cpp
mlir/lib/Dialect/GPU/TransformOps/GPUTransformOps.cpp
mlir/lib/Dialect/GPU/Transforms/SerializeToBlob.cpp
mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp
mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
mlir/lib/Dialect/LLVMIR/IR/LLVMTypes.cpp
mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp
mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
mlir/lib/Dialect/Linalg/Transforms/ConstantFold.cpp
mlir/lib/Dialect/Linalg/Transforms/DropUnitDims.cpp
mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp
mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp
mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp
mlir/lib/Dialect/Linalg/Utils/Utils.cpp
mlir/lib/Dialect/MemRef/IR/MemRefDialect.cpp
mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp
mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp
mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
mlir/lib/Dialect/SCF/IR/SCF.cpp
mlir/lib/Dialect/SCF/Transforms/StructuralTypeConversions.cpp
mlir/lib/Dialect/SPIRV/IR/SPIRVAttributes.cpp
mlir/lib/Dialect/SPIRV/IR/SPIRVCanonicalization.cpp
mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp
mlir/lib/Dialect/SPIRV/IR/SPIRVTypes.cpp
mlir/lib/Dialect/SPIRV/IR/TargetAndABI.cpp
mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp
mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp
mlir/lib/Dialect/SPIRV/Transforms/UnifyAliasedResourcePass.cpp
mlir/lib/Dialect/Shape/IR/Shape.cpp
mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp
mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp
mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp
mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp
mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp
mlir/lib/Dialect/Tensor/IR/TensorOps.cpp
mlir/lib/Dialect/Traits.cpp
mlir/lib/Dialect/Utils/ReshapeOpsUtils.cpp
mlir/lib/Dialect/Utils/StaticValueUtils.cpp
mlir/lib/Dialect/Vector/IR/VectorOps.cpp
mlir/lib/Dialect/Vector/Transforms/VectorTransforms.cpp
mlir/lib/Dialect/Vector/Transforms/VectorUnroll.cpp
mlir/lib/IR/AffineMap.cpp
mlir/lib/IR/BuiltinAttributes.cpp
mlir/lib/IR/BuiltinTypes.cpp
mlir/lib/IR/Diagnostics.cpp
mlir/lib/IR/ExtensibleDialect.cpp
mlir/lib/IR/MLIRContext.cpp
mlir/lib/IR/SymbolTable.cpp
mlir/lib/Interfaces/ControlFlowInterfaces.cpp
mlir/lib/Pass/Pass.cpp
mlir/lib/Pass/PassStatistics.cpp
mlir/lib/Support/FileUtilities.cpp
mlir/lib/Support/Timing.cpp
mlir/lib/TableGen/AttrOrTypeDef.cpp
mlir/lib/TableGen/Attribute.cpp
mlir/lib/TableGen/Builder.cpp
mlir/lib/TableGen/Constraint.cpp
mlir/lib/TableGen/Interfaces.cpp
mlir/lib/TableGen/Type.cpp
mlir/lib/Target/LLVMIR/DebugTranslation.cpp
mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
mlir/lib/Target/SPIRV/Deserialization/Deserializer.h
mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp
mlir/lib/Tools/PDLL/CodeGen/MLIRGen.cpp
mlir/lib/Tools/PDLL/Parser/Parser.cpp
mlir/lib/Tools/lsp-server-support/SourceMgrUtils.cpp
mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp
mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp
mlir/lib/Tools/mlir-translate/Translation.cpp
mlir/lib/Tools/tblgen-lsp-server/TableGenServer.cpp
mlir/lib/Transforms/Utils/DialectConversion.cpp
mlir/lib/Transforms/ViewOpGraph.cpp
mlir/test/lib/Dialect/Func/TestDecomposeCallGraphTypes.cpp
mlir/test/lib/Dialect/Test/TestAttributes.cpp
mlir/test/lib/Dialect/Test/TestDialect.cpp
mlir/test/lib/Dialect/Test/TestPatterns.cpp
mlir/test/lib/Dialect/Vector/TestVectorTransforms.cpp
mlir/test/mlir-tblgen/attrdefs.td
mlir/test/mlir-tblgen/op-attribute.td
mlir/test/mlir-tblgen/typedefs.td
mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp
mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp
mlir/tools/mlir-tblgen/DialectGen.cpp
mlir/tools/mlir-tblgen/EnumsGen.cpp
mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
mlir/tools/mlir-tblgen/OpFormatGen.cpp
mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp
mlir/unittests/IR/OperationSupportTest.cpp
mlir/unittests/Pass/AnalysisManagerTest.cpp
mlir/unittests/Pass/PassManagerTest.cpp
mlir/unittests/TableGen/EnumsGenTest.cpp
mlir/unittests/Transforms/DialectConversion.cpp
|
Did you mean to replace this one also?