HomePhabricator

[mlir][Vector][Affine] Improve affine vectorizer algorithm

Authored by dcaballe on Mar 10 2021, 10:11 AM.

Description

[mlir][Vector][Affine] Improve affine vectorizer algorithm

This patch replaces the root-terminal vectorization approach implemented in the
Affine vectorizer with a topological order approach that vectorizes all the
operations within the target loop nest. These are the most important changes
introduced by the new algorithm:

  • Removed tracking of root and terminal ops. Existing vectorization functionality is preserved and extended so that loop nests without root-terminal chains can be vectorized.
  • Vectorizing a loop nest now only requires a single topological traversal.
  • A new vector loop nest is incrementally built along the vectorization process. The original scalar loop is kept intact. No cloning guard is needed to recover the scalar loop if vectorization fails. This approach also simplifies the challenging task of replacing a loop operation amid the vectorization process without invalidating the analysis information that depends on the original loop.
  • Vectorization of specific operations has been implemented as independent, preparing them to be moved to a potential vectorization interface.

Reviewed By: nicolasvasilache

Differential Revision: https://reviews.llvm.org/D97442

Event Timeline

ftynse added a subscriber: ftynse.Mar 10 2021, 11:30 AM

I had to roll this back because it broke tests if run under ASAN, which hints at a bigger underlying problem. The error is a use-after-free in the code that arguably predates this patch, but I don't know enough details to understand whether the error was already present before or was introduced as a side effect of this patch. It appears that NestedMatch in vectorizeLoops contains a reference to a loop op that was rewritten/replaced.

==1682072==ERROR: AddressSanitizer: heap-use-after-free on address 0x60d000000210 at pc 0x000005fb466a bp 0x7ffcdceb5670 sp 0x7ffcdceb4e38
READ of size 8 at 0x60d000000210 thread T0
    #0 0x5fb4669 in __asan_memcpy llvm/compiler-rt/lib/asan/asan_interceptors_memintrinsics.cpp:22:3
    #1 0x6c692c8 in mlir::Operation::getName() /home/zinenko/llvm-project/mlir/include/mlir/IR/Operation.h:57:36
    #2 0x6c68fc2 in mlir::Operation::getAbstractOperation() /home/zinenko/llvm-project/mlir/include/mlir/IR/Operation.h:62:12
    #3 0x6cb7d5c in mlir::Op<mlir::AffineForOp, mlir::OpTrait::OneRegion, mlir::OpTrait::VariadicResults, mlir::OpTrait::ZeroSuccessor, mlir::OpTrait::VariadicOperands, mlir::OpTrait::SingleBlockImplicitTerminator<mlir::AffineYieldOp>::Impl, mlir::OpTrait::HasRecursiveSideEffects, mlir::LoopLikeOpInterface::Trait>::classof(mlir::Operation*) /home/zinenko/llvm-project/mlir/include/mlir/IR/OpDefinition.h:1530:32
    #4 0x6cb7b64 in llvm::isa_impl<mlir::AffineForOp, mlir::Operation, void>::doit(mlir::Operation const&) /home/zinenko/llvm-project/mlir/include/mlir/IR/Operation.h:763:12
    #5 0x6cb7b37 in llvm::isa_impl_cl<mlir::AffineForOp, mlir::Operation const*>::doit(mlir::Operation const*) /home/zinenko/llvm-project/llvm/include/llvm/Support/Casting.h:105:12
    #6 0x6cb7abc in llvm::isa_impl_wrap<mlir::AffineForOp, mlir::Operation const*, mlir::Operation const*>::doit(mlir::Operation const* const&) /home/zinenko/llvm-project/llvm/include/llvm/Support/Casting.h:131:12
    #7 0x6cb7a17 in llvm::isa_impl_wrap<mlir::AffineForOp, mlir::Operation* const, mlir::Operation const*>::doit(mlir::Operation* const&) /home/zinenko/llvm-project/llvm/include/llvm/Support/Casting.h:121:12
    #8 0x6cb6b64 in bool llvm::isa<mlir::AffineForOp, mlir::Operation*>(mlir::Operation* const&) /home/zinenko/llvm-project/llvm/include/llvm/Support/Casting.h:142:10
    #9 0x6ccf602 in llvm::cast_retty<mlir::AffineForOp, mlir::Operation*>::ret_type llvm::cast<mlir::AffineForOp, mlir::Operation>(mlir::Operation*) /home/zinenko/llvm-project/llvm/include/llvm/Support/Casting.h:269:3
    #10 0x6d9c51d in getMatchedAffineLoopsRec(mlir::NestedMatch, unsigned int, std::vector<llvm::SmallVector<mlir::AffineForOp, 2u>, std::allocator<llvm::SmallVector<mlir::AffineForOp, 2u> > >&) /home/zinenko/llvm-project/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp:1165:33
    #11 0x6d9c6e7 in getMatchedAffineLoopsRec(mlir::NestedMatch, unsigned int, std::vector<llvm::SmallVector<mlir::AffineForOp, 2u>, std::allocator<llvm::SmallVector<mlir::AffineForOp, 2u> > >&) /home/zinenko/llvm-project/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp:1167:5
    #12 0x6d9c1b2 in getMatchedAffineLoops(mlir::NestedMatch, std::vector<llvm::SmallVector<mlir::AffineForOp, 2u>, std::allocator<llvm::SmallVector<mlir::AffineForOp, 2u> > >&) /home/zinenko/llvm-project/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp:1179:3
    #13 0x6d9a832 in vectorizeRootMatch(mlir::NestedMatch, mlir::VectorizationStrategy const&) /home/zinenko/llvm-project/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp:1250:3
    #14 0x6d97058 in vectorizeLoops(mlir::Operation*, llvm::DenseSet<mlir::Operation*, llvm::DenseMapInfo<mlir::Operation*> >&, llvm::ArrayRef<long>, llvm::ArrayRef<long>) /home/zinenko/llvm-project/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp:1287:13
    #15 0x6daa914 in (anonymous namespace)::Vectorize::runOnFunction() /home/zinenko/llvm-project/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp:1321:3
    #16 0x6d47eb3 in mlir::FunctionPass::runOnOperation() /home/zinenko/llvm-project/mlir/include/mlir/Pass/Pass.h:378:7
    #17 0xd7d8a12 in mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) /home/zinenko/llvm-project/mlir/lib/Pass/Pass.cpp:402:11
    #18 0xd7d9fd4 in mlir::detail::OpToOpPassAdaptor::runPipeline(llvm::iterator_range<llvm::pointee_iterator<std::unique_ptr<mlir::Pass, std::default_delete<mlir::Pass> >*, mlir::Pass> >, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) /home/zinenko/llvm-project/mlir/lib/Pass/Pass.cpp:444:16
    #19 0xd7f4f03 in mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_8::operator()(llvm::MutableArrayRef<mlir::OpPassManager>) const /home/zinenko/llvm-project/mlir/lib/Pass/Pass.cpp:619:15
    #20 0xd7f3abe in mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_8 std::for_each<llvm::SmallVector<mlir::OpPassManager, 1u>*, mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_8>(llvm::SmallVector<mlir::OpPassManager, 1u>*, llvm::SmallVector<mlir::OpPassManager, 1u>*, mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_8) /home/zinenko/llvm-project/build2/../.sysroot/usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_algo.h:3839:2
    #21 0xd7f3821 in void llvm::parallel::detail::parallel_for_each<llvm::SmallVector<mlir::OpPassManager, 1u>*, mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_8>(llvm::SmallVector<mlir::OpPassManager, 1u>*, llvm::SmallVector<mlir::OpPassManager, 1u>*, mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_8) /home/zinenko/llvm-project/llvm/include/llvm/Support/Parallel.h:143:3
    #22 0xd7de58a in void llvm::parallelForEach<llvm::SmallVector<mlir::OpPassManager, 1u>*, mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_8>(llvm::SmallVector<mlir::OpPassManager, 1u>*, llvm::SmallVector<mlir::OpPassManager, 1u>*, mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_8) /home/zinenko/llvm-project/llvm/include/llvm/Support/Parallel.h:233:5
    #23 0xd7dc800 in mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool) /home/zinenko/llvm-project/mlir/lib/Pass/Pass.cpp:597:3
    #24 0xd7d921c in mlir::detail::OpToOpPassAdaptor::runOnOperation(bool) /home/zinenko/llvm-project/mlir/lib/Pass/Pass.cpp:519:5
    #25 0xd7d89a5 in mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) /home/zinenko/llvm-project/mlir/lib/Pass/Pass.cpp:400:14
    #26 0xd7d9fd4 in mlir::detail::OpToOpPassAdaptor::runPipeline(llvm::iterator_range<llvm::pointee_iterator<std::unique_ptr<mlir::Pass, std::default_delete<mlir::Pass> >*, mlir::Pass> >, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) /home/zinenko/llvm-project/mlir/lib/Pass/Pass.cpp:444:16
    #27 0xd7e223e in mlir::PassManager::run(mlir::Operation*) /home/zinenko/llvm-project/mlir/lib/Pass/Pass.cpp:895:13
    #28 0xd6fd848 in performActions(llvm::raw_ostream&, bool, bool, llvm::SourceMgr&, mlir::MLIRContext*, mlir::PassPipelineCLParser const&) /home/zinenko/llvm-project/mlir/lib/Support/MlirOptMain.cpp:76:17
    #29 0xd6f9ae7 in processBuffer(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer> >, bool, bool, bool, bool, mlir::PassPipelineCLParser const&, mlir::DialectRegistry&) /home/zinenko/llvm-project/mlir/lib/Support/MlirOptMain.cpp:110:12
    #30 0xd6f955b in mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer> >, mlir::PassPipelineCLParser const&, mlir::DialectRegistry&, bool, bool, bool, bool, bool) /home/zinenko/llvm-project/mlir/lib/Support/MlirOptMain.cpp:147:10
    #31 0xd6fc62c in mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&, bool) /home/zinenko/llvm-project/mlir/lib/Support/MlirOptMain.cpp:251:14
    #32 0x5fe8060 in main /home/zinenko/llvm-project/mlir/tools/mlir-opt/mlir-opt.cpp:187:17
    #33 0x7f0006f0cd09 in __libc_start_main csu/../csu/libc-start.c:308:16
    #34 0x5f3bae9 in _start (/home/zinenko/llvm-project/build2/bin/mlir-opt+0x5f3bae9)

0x60d000000210 is located 48 bytes inside of 136-byte region [0x60d0000001e0,0x60d000000268)
freed by thread T0 here:
    #0 0x5fb4f8d in free llvm/compiler-rt/lib/asan/asan_malloc_linux.cpp:123:3
    #1 0xe0eeca7 in mlir::Operation::destroy() /home/zinenko/llvm-project/mlir/lib/IR/Operation.cpp:206:3
    #2 0xe0f16c4 in llvm::ilist_traits<mlir::Operation>::deleteNode(mlir::Operation*) /home/zinenko/llvm-project/mlir/lib/IR/Operation.cpp:429:7
    #3 0x9b7e1b0 in llvm::iplist_impl<llvm::simple_ilist<mlir::Operation>, llvm::ilist_traits<mlir::Operation> >::erase(llvm::ilist_iterator<llvm::ilist_detail::node_options<mlir::Operation, false, false, void>, false, false>) /home/zinenko/llvm-project/llvm/include/llvm/ADT/ilist.h:268:5
    #4 0x9b7dfdb in llvm::iplist_impl<llvm::simple_ilist<mlir::Operation>, llvm::ilist_traits<mlir::Operation> >::pop_back() /home/zinenko/llvm-project/llvm/include/llvm/ADT/ilist.h:320:25
    #5 0x9b7ba35 in mlir::Block::clear() /home/zinenko/llvm-project/mlir/include/mlir/IR/Block.h:41:18
    #6 0xdd9fbfd in mlir::Block::~Block() /home/zinenko/llvm-project/mlir/lib/IR/Block.cpp:21:3
    #7 0x6de74e6 in llvm::ilist_alloc_traits<mlir::Block>::deleteNode(mlir::Block*) /home/zinenko/llvm-project/llvm/include/llvm/ADT/ilist.h:41:39
    #8 0x6de7420 in llvm::iplist_impl<llvm::simple_ilist<mlir::Block>, llvm::ilist_traits<mlir::Block> >::erase(llvm::ilist_iterator<llvm::ilist_detail::node_options<mlir::Block, false, false, void>, false, false>) /home/zinenko/llvm-project/llvm/include/llvm/ADT/ilist.h:268:5
    #9 0x6de71e8 in llvm::iplist_impl<llvm::simple_ilist<mlir::Block>, llvm::ilist_traits<mlir::Block> >::erase(llvm::ilist_iterator<llvm::ilist_detail::node_options<mlir::Block, false, false, void>, false, false>, llvm::ilist_iterator<llvm::ilist_detail::node_options<mlir::Block, false, false, void>, false, false>) /home/zinenko/llvm-project/llvm/include/llvm/ADT/ilist.h:305:15
    #10 0x6de6bff in llvm::iplist_impl<llvm::simple_ilist<mlir::Block>, llvm::ilist_traits<mlir::Block> >::clear() /home/zinenko/llvm-project/llvm/include/llvm/ADT/ilist.h:309:18
    #11 0xe1570d4 in llvm::iplist_impl<llvm::simple_ilist<mlir::Block>, llvm::ilist_traits<mlir::Block> >::~iplist_impl() /home/zinenko/llvm-project/llvm/include/llvm/ADT/ilist.h:210:20
    #12 0xe156ce7 in llvm::iplist<mlir::Block>::~iplist() /home/zinenko/llvm-project/llvm/include/llvm/ADT/ilist.h:390:7
    #13 0xe151a74 in mlir::Region::~Region() /home/zinenko/llvm-project/mlir/lib/IR/Region.cpp:20:1
    #14 0xe0eebc6 in mlir::Operation::~Operation() /home/zinenko/llvm-project/mlir/lib/IR/Operation.cpp:196:12
    #15 0xe0eec9e in mlir::Operation::destroy() /home/zinenko/llvm-project/mlir/lib/IR/Operation.cpp:205:9
    #16 0xe0f16c4 in llvm::ilist_traits<mlir::Operation>::deleteNode(mlir::Operation*) /home/zinenko/llvm-project/mlir/lib/IR/Operation.cpp:429:7
    #17 0x9b7e1b0 in llvm::iplist_impl<llvm::simple_ilist<mlir::Operation>, llvm::ilist_traits<mlir::Operation> >::erase(llvm::ilist_iterator<llvm::ilist_detail::node_options<mlir::Operation, false, false, void>, false, false>) /home/zinenko/llvm-project/llvm/include/llvm/ADT/ilist.h:268:5
    #18 0xe1188de in llvm::iplist_impl<llvm::simple_ilist<mlir::Operation>, llvm::ilist_traits<mlir::Operation> >::erase(mlir::Operation*) /home/zinenko/llvm-project/llvm/include/llvm/ADT/ilist.h:272:39
    #19 0xe0f1ca3 in mlir::Operation::erase() /home/zinenko/llvm-project/mlir/lib/IR/Operation.cpp:478:29
    #20 0x6dca64c in mlir::OpState::erase() /home/zinenko/llvm-project/mlir/include/mlir/IR/OpDefinition.h:150:25
    #21 0x6d9df56 in eraseLoopNest(mlir::AffineForOp) /home/zinenko/llvm-project/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp:763:9
    #22 0x6d9e18e in (anonymous namespace)::VectorizationState::finishVectorizationPattern(mlir::AffineForOp) /home/zinenko/llvm-project/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp:769:3
    #23 0x6d988f0 in vectorizeLoopNest(std::vector<llvm::SmallVector<mlir::AffineForOp, 2u>, std::allocator<llvm::SmallVector<mlir::AffineForOp, 2u> > >&, mlir::VectorizationStrategy const&) /home/zinenko/llvm-project/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp:1240:9
    #24 0x6d9a846 in vectorizeRootMatch(mlir::NestedMatch, mlir::VectorizationStrategy const&) /home/zinenko/llvm-project/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp:1251:10
    #25 0x6d97058 in vectorizeLoops(mlir::Operation*, llvm::DenseSet<mlir::Operation*, llvm::DenseMapInfo<mlir::Operation*> >&, llvm::ArrayRef<long>, llvm::ArrayRef<long>) /home/zinenko/llvm-project/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp:1287:13
    #26 0x6daa914 in (anonymous namespace)::Vectorize::runOnFunction() /home/zinenko/llvm-project/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp:1321:3
    #27 0x6d47eb3 in mlir::FunctionPass::runOnOperation() /home/zinenko/llvm-project/mlir/include/mlir/Pass/Pass.h:378:7
    #28 0xd7d8a12 in mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) /home/zinenko/llvm-project/mlir/lib/Pass/Pass.cpp:402:11
    #29 0xd7d9fd4 in mlir::detail::OpToOpPassAdaptor::runPipeline(llvm::iterator_range<llvm::pointee_iterator<std::unique_ptr<mlir::Pass, std::default_delete<mlir::Pass> >*, mlir::Pass> >, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) /home/zinenko/llvm-project/mlir/lib/Pass/Pass.cpp:444:16

previously allocated by thread T0 here:
    #0 0x5fb520d in malloc llvm/compiler-rt/lib/asan/asan_malloc_linux.cpp:145:3
    #1 0xe0ec91f in mlir::Operation::create(mlir::Location, mlir::OperationName, mlir::TypeRange, mlir::ValueRange, mlir::DictionaryAttr, mlir::BlockRange, unsigned int) /home/zinenko/llvm-project/mlir/lib/IR/Operation.cpp:136:46
    #2 0xe0edd0f in mlir::Operation::create(mlir::Location, mlir::OperationName, mlir::TypeRange, mlir::ValueRange, mlir::DictionaryAttr, mlir::BlockRange, mlir::RegionRange) /home/zinenko/llvm-project/mlir/lib/IR/Operation.cpp:94:19
    #3 0xe0ed52c in mlir::Operation::create(mlir::OperationState const&) /home/zinenko/llvm-project/mlir/lib/IR/Operation.cpp:83:10
    #4 0xddc2733 in mlir::OpBuilder::createOperation(mlir::OperationState const&) /home/zinenko/llvm-project/mlir/lib/IR/Builders.cpp:393:17
    #5 0xd772824 in (anonymous namespace)::OperationParser::parseCustomOperation(llvm::ArrayRef<std::tuple<llvm::StringRef, unsigned int, llvm::SMLoc> >) /home/zinenko/llvm-project/mlir/lib/Parser/Parser.cpp:1680:29
    #6 0xd76b935 in (anonymous namespace)::OperationParser::parseOperation() /home/zinenko/llvm-project/mlir/lib/Parser/Parser.cpp:693:10
    #7 0xd79607d in (anonymous namespace)::OperationParser::parseBlockBody(mlir::Block*) /home/zinenko/llvm-project/mlir/lib/Parser/Parser.cpp:1868:9
    #8 0xd794267 in (anonymous namespace)::OperationParser::parseBlock(mlir::Block*&) /home/zinenko/llvm-project/mlir/lib/Parser/Parser.cpp:1835:12
    #9 0xd7924ed in (anonymous namespace)::OperationParser::parseRegion(mlir::Region&, llvm::ArrayRef<std::pair<(anonymous namespace)::OperationParser::SSAUseInfo, mlir::Type> >, bool) /home/zinenko/llvm-project/mlir/lib/Parser/Parser.cpp:1781:7
    #10 0xd785c1f in (anonymous namespace)::CustomOpAsmParser::parseRegion(mlir::Region&, llvm::ArrayRef<mlir::OpAsmParser::OperandType>, llvm::ArrayRef<mlir::Type>, bool) /home/zinenko/llvm-project/mlir/lib/Parser/Parser.cpp:1453:16
    #11 0x6b943b2 in parseAffineForOp(mlir::OpAsmParser&, mlir::OperationState&) /home/zinenko/llvm-project/mlir/lib/Dialect/Affine/IR/AffineOps.cpp:1436:14
    #12 0x6b9199e in mlir::AffineForOp::parse(mlir::OpAsmParser&, mlir::OperationState&) /home/zinenko/llvm-project/build2/tools/mlir/include/mlir/Dialect/Affine/IR/AffineOps.cpp.inc:395:10
    #13 0xe08ed09 in mlir::AbstractOperation::parseAssembly(mlir::OpAsmParser&, mlir::OperationState&) const /home/zinenko/llvm-project/mlir/lib/IR/MLIRContext.cpp:686:10
    #14 0xd777a39 in (anonymous namespace)::CustomOpAsmParser::parseOperation(mlir::OperationState&) /home/zinenko/llvm-project/mlir/lib/Parser/Parser.cpp:895:23
    #15 0xd772745 in (anonymous namespace)::OperationParser::parseCustomOperation(llvm::ArrayRef<std::tuple<llvm::StringRef, unsigned int, llvm::SMLoc> >) /home/zinenko/llvm-project/mlir/lib/Parser/Parser.cpp:1672:19
    #16 0xd76b935 in (anonymous namespace)::OperationParser::parseOperation() /home/zinenko/llvm-project/mlir/lib/Parser/Parser.cpp:693:10
    #17 0xd79607d in (anonymous namespace)::OperationParser::parseBlockBody(mlir::Block*) /home/zinenko/llvm-project/mlir/lib/Parser/Parser.cpp:1868:9
    #18 0xd794267 in (anonymous namespace)::OperationParser::parseBlock(mlir::Block*&) /home/zinenko/llvm-project/mlir/lib/Parser/Parser.cpp:1835:12
    #19 0xd7924ed in (anonymous namespace)::OperationParser::parseRegion(mlir::Region&, llvm::ArrayRef<std::pair<(anonymous namespace)::OperationParser::SSAUseInfo, mlir::Type> >, bool) /home/zinenko/llvm-project/mlir/lib/Parser/Parser.cpp:1781:7
    #20 0xd785c1f in (anonymous namespace)::CustomOpAsmParser::parseRegion(mlir::Region&, llvm::ArrayRef<mlir::OpAsmParser::OperandType>, llvm::ArrayRef<mlir::Type>, bool) /home/zinenko/llvm-project/mlir/lib/Parser/Parser.cpp:1453:16
    #21 0x6b943b2 in parseAffineForOp(mlir::OpAsmParser&, mlir::OperationState&) /home/zinenko/llvm-project/mlir/lib/Dialect/Affine/IR/AffineOps.cpp:1436:14
    #22 0x6b9199e in mlir::AffineForOp::parse(mlir::OpAsmParser&, mlir::OperationState&) /home/zinenko/llvm-project/build2/tools/mlir/include/mlir/Dialect/Affine/IR/AffineOps.cpp.inc:395:10
    #23 0xe08ed09 in mlir::AbstractOperation::parseAssembly(mlir::OpAsmParser&, mlir::OperationState&) const /home/zinenko/llvm-project/mlir/lib/IR/MLIRContext.cpp:686:10
    #24 0xd777a39 in (anonymous namespace)::CustomOpAsmParser::parseOperation(mlir::OperationState&) /home/zinenko/llvm-project/mlir/lib/Parser/Parser.cpp:895:23
    #25 0xd772745 in (anonymous namespace)::OperationParser::parseCustomOperation(llvm::ArrayRef<std::tuple<llvm::StringRef, unsigned int, llvm::SMLoc> >) /home/zinenko/llvm-project/mlir/lib/Parser/Parser.cpp:1672:19
    #26 0xd76b935 in (anonymous namespace)::OperationParser::parseOperation() /home/zinenko/llvm-project/mlir/lib/Parser/Parser.cpp:693:10
    #27 0xd79607d in (anonymous namespace)::OperationParser::parseBlockBody(mlir::Block*) /home/zinenko/llvm-project/mlir/lib/Parser/Parser.cpp:1868:9
    #28 0xd794267 in (anonymous namespace)::OperationParser::parseBlock(mlir::Block*&) /home/zinenko/llvm-project/mlir/lib/Parser/Parser.cpp:1835:12
    #29 0xd7924ed in (anonymous namespace)::OperationParser::parseRegion(mlir::Region&, llvm::ArrayRef<std::pair<(anonymous namespace)::OperationParser::SSAUseInfo, mlir::Type> >, bool) /home/zinenko/llvm-project/mlir/lib/Parser/Parser.cpp:1781:7

SUMMARY: AddressSanitizer: heap-use-after-free

Sorry, Alex. Let me look into that.