Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MLIR] AffineDataCopyGeneration crashed with error message 'decltype(auto) llvm::cast(const From&) [with To = mlir::VectorType' #61310

Closed
BealZephyr opened this issue Mar 9, 2023 · 5 comments
Assignees
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] mlir:affine

Comments

@BealZephyr
Copy link

BealZephyr commented Mar 9, 2023

Test on commit: 22c0ce9
The same crash occurred in llvm16

steps to reproduce:

mlir-opt test.mlir -affine-data-copy-generate

test case:

module {
  func.func @test_vectorize_trailing_index(%arg0: memref<1x2x4x8xindex>) {
    affine.for %arg1 = 0 to 1 {
      affine.for %arg2 = 0 to 2 {
        affine.for %arg3 = 0 to 4 {
          affine.for %arg4 = 0 to 8 {
            affine.store %arg4, %arg0[%arg1, %arg2, %arg3, %arg4] : memref<1x2x4x8xindex>
          }
        }
      }
    }
    return
  }
}

crash trace:

mlir-opt: /home/verify/llvm-project-22c0ce96912f55f48ba4535800bacc0c48fe9832/llvm/include/llvm/Support/Casting.h:567: decltype(auto) llvm::cast(const From&) [with To = mlir::VectorType; From = mlir::Type]: Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: llvm-project-22c0ce96912f55f48ba4535800bacc0c48fe9832/build/bin/mlir-opt test.mlir -affine-data-copy-generate
 #0 0x000055cfaf459aaa llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (llvm-project-22c0ce96912f55f48ba4535800bacc0c48fe9832/build/bin/mlir-opt+0x221aaa)
 #1 0x000055cfaf456fac SignalHandler(int) Signals.cpp:0:0
 #2 0x00007f717c093980 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x12980)
 #3 0x00007f717b18be87 raise /build/glibc-CVJwZb/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
 #4 0x00007f717b18d7f1 abort /build/glibc-CVJwZb/glibc-2.27/stdlib/abort.c:81:0
 #5 0x00007f717b17d3fa __assert_fail_base /build/glibc-CVJwZb/glibc-2.27/assert/assert.c:89:0
 #6 0x00007f717b17d472 (/lib/x86_64-linux-gnu/libc.so.6+0x30472)
 #7 0x000055cfb0ca295e getMemRefEltSizeInBytes(mlir::MemRefType) Utils.cpp:0:0
 #8 0x000055cfb0ca8afa mlir::MemRefRegion::getRegionSize() (llvm-project-22c0ce96912f55f48ba4535800bacc0c48fe9832/build/bin/mlir-opt+0x1a70afa)
 #9 0x000055cfb0caf253 getMemoryFootprintBytes(mlir::Block&, llvm::ilist_iterator<llvm::ilist_detail::node_options<mlir::Operation, true, false, void>, false, false>, llvm::ilist_iterator<llvm::ilist_detail::node_options<mlir::Operation, true, false, void>, false, false>, int) (.isra.384) Utils.cpp:0:0
#10 0x000055cfb0caf6d4 mlir::getMemoryFootprintBytes(mlir::AffineForOp, int) (llvm-project-22c0ce96912f55f48ba4535800bacc0c48fe9832/build/bin/mlir-opt+0x1a776d4)
#11 0x000055cfaf4f602d (anonymous namespace)::AffineDataCopyGeneration::runOnBlock(mlir::Block*, llvm::DenseSet<mlir::Operation*, llvm::DenseMapInfo<mlir::Operation*, void>>&) AffineDataCopyGeneration.cpp:0:0
#12 0x000055cfaf4f69fa (anonymous namespace)::AffineDataCopyGeneration::runOnOperation() AffineDataCopyGeneration.cpp:0:0
#13 0x000055cfb0d03e59 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (llvm-project-22c0ce96912f55f48ba4535800bacc0c48fe9832/build/bin/mlir-opt+0x1acbe59)
#14 0x000055cfb0d0417a mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (llvm-project-22c0ce96912f55f48ba4535800bacc0c48fe9832/build/bin/mlir-opt+0x1acc17a)
#15 0x000055cfb0d044f8 mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::'lambda'(mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo&)::operator()(mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo&) const Pass.cpp:0:0
#16 0x000055cfb0d03635 mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool) (llvm-project-22c0ce96912f55f48ba4535800bacc0c48fe9832/build/bin/mlir-opt+0x1acb635)
#17 0x000055cfb0d03dca mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (llvm-project-22c0ce96912f55f48ba4535800bacc0c48fe9832/build/bin/mlir-opt+0x1acbdca)
#18 0x000055cfb0d04cb3 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (.constprop.495) Pass.cpp:0:0
#19 0x000055cfb0d0539d mlir::PassManager::run(mlir::Operation*) (llvm-project-22c0ce96912f55f48ba4535800bacc0c48fe9832/build/bin/mlir-opt+0x1acd39d)
#20 0x000055cfb0cf83a3 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#21 0x000055cfb0cf8ad9 processBuffer(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, llvm::ThreadPool*) MlirOptMain.cpp:0:0
#22 0x000055cfb0cf8e01 mlir::LogicalResult llvm::function_ref<mlir::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>::callback_fn<mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&)::'lambda'(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>(long, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) MlirOptMain.cpp:0:0
#23 0x000055cfb0dbd9b0 mlir::splitAndProcessBuffer(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<mlir::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>, llvm::raw_ostream&, bool, bool) (llvm-project-22c0ce96912f55f48ba4535800bacc0c48fe9832/build/bin/mlir-opt+0x1b859b0)
#24 0x000055cfb0cf5ae3 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (llvm-project-22c0ce96912f55f48ba4535800bacc0c48fe9832/build/bin/mlir-opt+0x1abdae3)
#25 0x000055cfb0cf91e8 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&, bool) (llvm-project-22c0ce96912f55f48ba4535800bacc0c48fe9832/build/bin/mlir-opt+0x1ac11e8)
#26 0x000055cfaf425ec0 main (llvm-project-22c0ce96912f55f48ba4535800bacc0c48fe9832/build/bin/mlir-opt+0x1edec0)
#27 0x00007f717b16ec87 __libc_start_main /build/glibc-CVJwZb/glibc-2.27/csu/../csu/libc-start.c:344:0
#28 0x000055cfaf438b5a _start (llvm-project-22c0ce96912f55f48ba4535800bacc0c48fe9832/build/bin/mlir-opt+0x200b5a)
Aborted (core dumped)
@EugeneZelenko EugeneZelenko added mlir:affine crash Prefer [crash-on-valid] or [crash-on-invalid] and removed new issue labels Mar 9, 2023
@llvmbot
Copy link
Collaborator

llvmbot commented Mar 9, 2023

@llvm/issue-subscribers-mlir-affine

@Lewuathe Lewuathe self-assigned this Mar 10, 2023
@Lewuathe
Copy link
Member

Submitted a patch here. https://reviews.llvm.org/D145764

@bondhugula bondhugula self-assigned this Mar 21, 2023
@bondhugula
Copy link
Contributor

Submitted a patch here. https://reviews.llvm.org/D145764

This patch appears to be abandoned. The issue is still there. Are you still working on it? If not, I can fix it.

@bondhugula
Copy link
Contributor

https://reviews.llvm.org/D146495 fixes this.

@Lewuathe
Copy link
Member

@bondhugula Sorry, I replaced the patch with new one because the commit history got dirty. Here is the latest one.
https://reviews.llvm.org/D146019
But either one is okay as long as it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] mlir:affine
Projects
None yet
Development

No branches or pull requests

5 participants