llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[mlir][bug][Affine][fuzzer-found] delinearize_index fold casts a vector constant to IntegerAttr

Open Kiritobl opened this issue 1 month ago • 3 comments

Version

LLVM/MLIR 24.0.0git, commit c275ebd64bf5b05e36a3a8e8b8daa32ba9a52aac (optimized build with assertions).

Bug Description

Observed failure: delinearize_index fold casts a vector constant to IntegerAttr. The input passes verification without the pass, but the command below crashes. This bug was found by a fuzzer.

Likely Cause

The constant-linear-index fold for affine.delinearize_index assumes a scalar IntegerAttr. A verifier-accepted vector<4xindex> constant is a DenseIntElementsAttr; the unconditional cast<IntegerAttr> fails during canonicalization.

Steps to Reproduce

mlir-opt --allow-unregistered-dialect -canonicalize=test-convergence reproducer.mlir -o /dev/null

Reproducer (reproducer.mlir)

module {
  func.func @f() -> vector<4xindex> {
    %c = arith.constant dense<[0, 1, 2, 3]> : vector<4xindex>
    %0:3 = affine.delinearize_index %c into (2, 4, 8) : vector<4xindex>, vector<4xindex>, vector<4xindex>
    return %0#0 : vector<4xindex>
  }
}

Stack Dump (full stderr)

mlir-opt: llvm/include/llvm/Support/Casting.h:560: decltype(auto) llvm::cast(const From&) [with To = mlir::IntegerAttr; From = mlir::Attribute]: 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 and instructions to reproduce the bug.
Stack dump:
0.	Program arguments: mlir-opt --allow-unregistered-dialect -canonicalize=test-convergence reproducer.mlir -o /dev/null
 #0 0x000055a432454699 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (mlir-opt+0x1fa0699)
 #1 0x000055a432450e9c llvm::sys::RunSignalHandlers() (mlir-opt+0x1f9ce9c)
 #2 0x000055a432451006 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #3 0x00007f799e3ee520 (libc.so.6+0x42520)
 #4 0x00007f799e4429bc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #5 0x00007f799e4429bc __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #6 0x00007f799e4429bc pthread_kill ./nptl/pthread_kill.c:89:10
 #7 0x00007f799e3ee476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #8 0x00007f799e3d47f3 abort ./stdlib/abort.c:81:7
 #9 0x00007f799e3d471b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#10 0x00007f799e3e5e96 (libc.so.6+0x39e96)
#11 0x000055a43a4b5d72 (mlir-opt+0xa001d72)
#12 0x000055a43a4fc645 mlir::affine::AffineDelinearizeIndexOp::fold(mlir::affine::AffineDelinearizeIndexOpGenericAdaptor<llvm::ArrayRef<mlir::Attribute>>, llvm::SmallVectorImpl<mlir::OpFoldResult>&) (mlir-opt+0xa048645)
#13 0x000055a43a4fc89d mlir::RegisteredOperationName::Model<mlir::affine::AffineDelinearizeIndexOp>::foldHook(mlir::Operation*, llvm::ArrayRef<mlir::Attribute>, llvm::SmallVectorImpl<mlir::OpFoldResult>&) (mlir-opt+0xa04889d)
#14 0x000055a43accae34 mlir::Operation::fold(llvm::ArrayRef<mlir::Attribute>, llvm::SmallVectorImpl<mlir::OpFoldResult>&) (mlir-opt+0xa816e34)
#15 0x000055a43accb2db mlir::Operation::fold(llvm::SmallVectorImpl<mlir::OpFoldResult>&) (mlir-opt+0xa8172db)
#16 0x000055a43a8b5421 (anonymous namespace)::GreedyPatternRewriteDriver::processWorklist() GreedyPatternRewriteDriver.cpp:0:0
#17 0x000055a43a8b9336 mlir::applyPatternsGreedily(mlir::Region&, mlir::FrozenRewritePatternSet const&, mlir::GreedyRewriteConfig, bool*) (mlir-opt+0xa405336)
#18 0x000055a43a803682 (anonymous namespace)::Canonicalizer::runOnOperation() Canonicalizer.cpp:0:0
#19 0x000055a43a953449 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (mlir-opt+0xa49f449)
#20 0x000055a43a9537b4 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (mlir-opt+0xa49f7b4)
#21 0x000055a43a9556f2 mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) (mlir-opt+0xa4a16f2)
#22 0x000055a43a9566c9 mlir::PassManager::run(mlir::Operation*) (mlir-opt+0xa4a26c9)
#23 0x000055a43251a9b3 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#24 0x000055a43251b2de processBuffer(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::MemoryBufferRef, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, mlir::SourceMgrDiagnosticVerifierHandler*, llvm::ThreadPoolInterface*) MlirOptMain.cpp:0:0
#25 0x000055a43251b521 llvm::LogicalResult llvm::function_ref<llvm::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::MemoryBufferRef const&, 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::MemoryBufferRef, llvm::raw_ostream&)>(long, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::MemoryBufferRef const&, llvm::raw_ostream&) MlirOptMain.cpp:0:0
#26 0x000055a43ad25a2d mlir::splitAndProcessBuffer(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<llvm::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::MemoryBufferRef const&, llvm::raw_ostream&)>, llvm::raw_ostream&, llvm::StringRef, llvm::StringRef) (mlir-opt+0xa871a2d)
#27 0x000055a4325162da mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (.part.0) MlirOptMain.cpp:0:0
#28 0x000055a43251baf8 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (mlir-opt+0x2067af8)
#29 0x000055a43251bd54 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (mlir-opt+0x2067d54)
#30 0x000055a4323c85cc main (mlir-opt+0x1f145cc)
#31 0x00007f799e3d5d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#32 0x00007f799e3d5e40 call_init ./csu/../csu/libc-start.c:128:20
#33 0x00007f799e3d5e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#34 0x000055a432433f35 _start (mlir-opt+0x1f7ff35)

Kiritobl avatar Oct 14 '26 09:10 Kiritobl

@llvm/issue-subscribers-mlir

Author: Kirito (Kiritobl)

#### Version

LLVM/MLIR 24.0.0git, commit c275ebd64bf5b05e36a3a8e8b8daa32ba9a52aac (optimized build with assertions).

Bug Description

Observed failure: delinearize_index fold casts a vector constant to IntegerAttr. The input passes verification without the pass, but the command below crashes. This bug was found by a fuzzer.

Likely Cause

The constant-linear-index fold for affine.delinearize_index assumes a scalar IntegerAttr. A verifier-accepted vector&lt;4xindex&gt; constant is a DenseIntElementsAttr; the unconditional cast&lt;IntegerAttr&gt; fails during canonicalization.

Steps to Reproduce

mlir-opt --allow-unregistered-dialect -canonicalize=test-convergence reproducer.mlir -o /dev/null

Reproducer (reproducer.mlir)

module {
  func.func @<!-- -->f() -&gt; vector&lt;4xindex&gt; {
    %c = arith.constant dense&lt;[0, 1, 2, 3]&gt; : vector&lt;4xindex&gt;
    %0:3 = affine.delinearize_index %c into (2, 4, 8) : vector&lt;4xindex&gt;, vector&lt;4xindex&gt;, vector&lt;4xindex&gt;
    return %0#<!-- -->0 : vector&lt;4xindex&gt;
  }
}

Stack Dump (full stderr)

mlir-opt: llvm/include/llvm/Support/Casting.h:560: decltype(auto) llvm::cast(const From&amp;) [with To = mlir::IntegerAttr; From = mlir::Attribute]: Assertion `isa&lt;To&gt;(Val) &amp;&amp; "cast&lt;Ty&gt;() argument of incompatible type!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0.	Program arguments: mlir-opt --allow-unregistered-dialect -canonicalize=test-convergence reproducer.mlir -o /dev/null
 #<!-- -->0 0x000055a432454699 llvm::sys::PrintStackTrace(llvm::raw_ostream&amp;, int) (mlir-opt+0x1fa0699)
 #<!-- -->1 0x000055a432450e9c llvm::sys::RunSignalHandlers() (mlir-opt+0x1f9ce9c)
 #<!-- -->2 0x000055a432451006 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #<!-- -->3 0x00007f799e3ee520 (libc.so.6+0x42520)
 #<!-- -->4 0x00007f799e4429bc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #<!-- -->5 0x00007f799e4429bc __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #<!-- -->6 0x00007f799e4429bc pthread_kill ./nptl/pthread_kill.c:89:10
 #<!-- -->7 0x00007f799e3ee476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #<!-- -->8 0x00007f799e3d47f3 abort ./stdlib/abort.c:81:7
 #<!-- -->9 0x00007f799e3d471b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#<!-- -->10 0x00007f799e3e5e96 (libc.so.6+0x39e96)
#<!-- -->11 0x000055a43a4b5d72 (mlir-opt+0xa001d72)
#<!-- -->12 0x000055a43a4fc645 mlir::affine::AffineDelinearizeIndexOp::fold(mlir::affine::AffineDelinearizeIndexOpGenericAdaptor&lt;llvm::ArrayRef&lt;mlir::Attribute&gt;&gt;, llvm::SmallVectorImpl&lt;mlir::OpFoldResult&gt;&amp;) (mlir-opt+0xa048645)
#<!-- -->13 0x000055a43a4fc89d mlir::RegisteredOperationName::Model&lt;mlir::affine::AffineDelinearizeIndexOp&gt;::foldHook(mlir::Operation*, llvm::ArrayRef&lt;mlir::Attribute&gt;, llvm::SmallVectorImpl&lt;mlir::OpFoldResult&gt;&amp;) (mlir-opt+0xa04889d)
#<!-- -->14 0x000055a43accae34 mlir::Operation::fold(llvm::ArrayRef&lt;mlir::Attribute&gt;, llvm::SmallVectorImpl&lt;mlir::OpFoldResult&gt;&amp;) (mlir-opt+0xa816e34)
#<!-- -->15 0x000055a43accb2db mlir::Operation::fold(llvm::SmallVectorImpl&lt;mlir::OpFoldResult&gt;&amp;) (mlir-opt+0xa8172db)
#<!-- -->16 0x000055a43a8b5421 (anonymous namespace)::GreedyPatternRewriteDriver::processWorklist() GreedyPatternRewriteDriver.cpp:0:0
#<!-- -->17 0x000055a43a8b9336 mlir::applyPatternsGreedily(mlir::Region&amp;, mlir::FrozenRewritePatternSet const&amp;, mlir::GreedyRewriteConfig, bool*) (mlir-opt+0xa405336)
#<!-- -->18 0x000055a43a803682 (anonymous namespace)::Canonicalizer::runOnOperation() Canonicalizer.cpp:0:0
#<!-- -->19 0x000055a43a953449 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (mlir-opt+0xa49f449)
#<!-- -->20 0x000055a43a9537b4 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&amp;, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (mlir-opt+0xa49f7b4)
#<!-- -->21 0x000055a43a9556f2 mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) (mlir-opt+0xa4a16f2)
#<!-- -->22 0x000055a43a9566c9 mlir::PassManager::run(mlir::Operation*) (mlir-opt+0xa4a26c9)
#<!-- -->23 0x000055a43251a9b3 performActions(llvm::raw_ostream&amp;, std::shared_ptr&lt;llvm::SourceMgr&gt; const&amp;, mlir::MLIRContext*, mlir::MlirOptMainConfig const&amp;) MlirOptMain.cpp:0:0
#<!-- -->24 0x000055a43251b2de processBuffer(llvm::raw_ostream&amp;, std::unique_ptr&lt;llvm::MemoryBuffer, std::default_delete&lt;llvm::MemoryBuffer&gt;&gt;, llvm::MemoryBufferRef, mlir::MlirOptMainConfig const&amp;, mlir::DialectRegistry&amp;, mlir::SourceMgrDiagnosticVerifierHandler*, llvm::ThreadPoolInterface*) MlirOptMain.cpp:0:0
#<!-- -->25 0x000055a43251b521 llvm::LogicalResult llvm::function_ref&lt;llvm::LogicalResult (std::unique_ptr&lt;llvm::MemoryBuffer, std::default_delete&lt;llvm::MemoryBuffer&gt;&gt;, llvm::MemoryBufferRef const&amp;, llvm::raw_ostream&amp;)&gt;::callback_fn&lt;mlir::MlirOptMain(llvm::raw_ostream&amp;, std::unique_ptr&lt;llvm::MemoryBuffer, std::default_delete&lt;llvm::MemoryBuffer&gt;&gt;, mlir::DialectRegistry&amp;, mlir::MlirOptMainConfig const&amp;)::'lambda'(std::unique_ptr&lt;llvm::MemoryBuffer, std::default_delete&lt;llvm::MemoryBuffer&gt;&gt;, llvm::MemoryBufferRef, llvm::raw_ostream&amp;)&gt;(long, std::unique_ptr&lt;llvm::MemoryBuffer, std::default_delete&lt;llvm::MemoryBuffer&gt;&gt;, llvm::MemoryBufferRef const&amp;, llvm::raw_ostream&amp;) MlirOptMain.cpp:0:0
#<!-- -->26 0x000055a43ad25a2d mlir::splitAndProcessBuffer(std::unique_ptr&lt;llvm::MemoryBuffer, std::default_delete&lt;llvm::MemoryBuffer&gt;&gt;, llvm::function_ref&lt;llvm::LogicalResult (std::unique_ptr&lt;llvm::MemoryBuffer, std::default_delete&lt;llvm::MemoryBuffer&gt;&gt;, llvm::MemoryBufferRef const&amp;, llvm::raw_ostream&amp;)&gt;, llvm::raw_ostream&amp;, llvm::StringRef, llvm::StringRef) (mlir-opt+0xa871a2d)
#<!-- -->27 0x000055a4325162da mlir::MlirOptMain(llvm::raw_ostream&amp;, std::unique_ptr&lt;llvm::MemoryBuffer, std::default_delete&lt;llvm::MemoryBuffer&gt;&gt;, mlir::DialectRegistry&amp;, mlir::MlirOptMainConfig const&amp;) (.part.0) MlirOptMain.cpp:0:0
#<!-- -->28 0x000055a43251baf8 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&amp;) (mlir-opt+0x2067af8)
#<!-- -->29 0x000055a43251bd54 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&amp;) (mlir-opt+0x2067d54)
#<!-- -->30 0x000055a4323c85cc main (mlir-opt+0x1f145cc)
#<!-- -->31 0x00007f799e3d5d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#<!-- -->32 0x00007f799e3d5e40 call_init ./csu/../csu/libc-start.c:128:20
#<!-- -->33 0x00007f799e3d5e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#<!-- -->34 0x000055a432433f35 _start (mlir-opt+0x1f7ff35)

@llvm/issue-subscribers-mlir-affine

Author: Kirito (Kiritobl)

#### Version

LLVM/MLIR 24.0.0git, commit c275ebd64bf5b05e36a3a8e8b8daa32ba9a52aac (optimized build with assertions).

Bug Description

Observed failure: delinearize_index fold casts a vector constant to IntegerAttr. The input passes verification without the pass, but the command below crashes. This bug was found by a fuzzer.

Likely Cause

The constant-linear-index fold for affine.delinearize_index assumes a scalar IntegerAttr. A verifier-accepted vector&lt;4xindex&gt; constant is a DenseIntElementsAttr; the unconditional cast&lt;IntegerAttr&gt; fails during canonicalization.

Steps to Reproduce

mlir-opt --allow-unregistered-dialect -canonicalize=test-convergence reproducer.mlir -o /dev/null

Reproducer (reproducer.mlir)

module {
  func.func @<!-- -->f() -&gt; vector&lt;4xindex&gt; {
    %c = arith.constant dense&lt;[0, 1, 2, 3]&gt; : vector&lt;4xindex&gt;
    %0:3 = affine.delinearize_index %c into (2, 4, 8) : vector&lt;4xindex&gt;, vector&lt;4xindex&gt;, vector&lt;4xindex&gt;
    return %0#<!-- -->0 : vector&lt;4xindex&gt;
  }
}

Stack Dump (full stderr)

mlir-opt: llvm/include/llvm/Support/Casting.h:560: decltype(auto) llvm::cast(const From&amp;) [with To = mlir::IntegerAttr; From = mlir::Attribute]: Assertion `isa&lt;To&gt;(Val) &amp;&amp; "cast&lt;Ty&gt;() argument of incompatible type!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0.	Program arguments: mlir-opt --allow-unregistered-dialect -canonicalize=test-convergence reproducer.mlir -o /dev/null
 #<!-- -->0 0x000055a432454699 llvm::sys::PrintStackTrace(llvm::raw_ostream&amp;, int) (mlir-opt+0x1fa0699)
 #<!-- -->1 0x000055a432450e9c llvm::sys::RunSignalHandlers() (mlir-opt+0x1f9ce9c)
 #<!-- -->2 0x000055a432451006 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #<!-- -->3 0x00007f799e3ee520 (libc.so.6+0x42520)
 #<!-- -->4 0x00007f799e4429bc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #<!-- -->5 0x00007f799e4429bc __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #<!-- -->6 0x00007f799e4429bc pthread_kill ./nptl/pthread_kill.c:89:10
 #<!-- -->7 0x00007f799e3ee476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #<!-- -->8 0x00007f799e3d47f3 abort ./stdlib/abort.c:81:7
 #<!-- -->9 0x00007f799e3d471b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#<!-- -->10 0x00007f799e3e5e96 (libc.so.6+0x39e96)
#<!-- -->11 0x000055a43a4b5d72 (mlir-opt+0xa001d72)
#<!-- -->12 0x000055a43a4fc645 mlir::affine::AffineDelinearizeIndexOp::fold(mlir::affine::AffineDelinearizeIndexOpGenericAdaptor&lt;llvm::ArrayRef&lt;mlir::Attribute&gt;&gt;, llvm::SmallVectorImpl&lt;mlir::OpFoldResult&gt;&amp;) (mlir-opt+0xa048645)
#<!-- -->13 0x000055a43a4fc89d mlir::RegisteredOperationName::Model&lt;mlir::affine::AffineDelinearizeIndexOp&gt;::foldHook(mlir::Operation*, llvm::ArrayRef&lt;mlir::Attribute&gt;, llvm::SmallVectorImpl&lt;mlir::OpFoldResult&gt;&amp;) (mlir-opt+0xa04889d)
#<!-- -->14 0x000055a43accae34 mlir::Operation::fold(llvm::ArrayRef&lt;mlir::Attribute&gt;, llvm::SmallVectorImpl&lt;mlir::OpFoldResult&gt;&amp;) (mlir-opt+0xa816e34)
#<!-- -->15 0x000055a43accb2db mlir::Operation::fold(llvm::SmallVectorImpl&lt;mlir::OpFoldResult&gt;&amp;) (mlir-opt+0xa8172db)
#<!-- -->16 0x000055a43a8b5421 (anonymous namespace)::GreedyPatternRewriteDriver::processWorklist() GreedyPatternRewriteDriver.cpp:0:0
#<!-- -->17 0x000055a43a8b9336 mlir::applyPatternsGreedily(mlir::Region&amp;, mlir::FrozenRewritePatternSet const&amp;, mlir::GreedyRewriteConfig, bool*) (mlir-opt+0xa405336)
#<!-- -->18 0x000055a43a803682 (anonymous namespace)::Canonicalizer::runOnOperation() Canonicalizer.cpp:0:0
#<!-- -->19 0x000055a43a953449 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (mlir-opt+0xa49f449)
#<!-- -->20 0x000055a43a9537b4 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&amp;, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (mlir-opt+0xa49f7b4)
#<!-- -->21 0x000055a43a9556f2 mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) (mlir-opt+0xa4a16f2)
#<!-- -->22 0x000055a43a9566c9 mlir::PassManager::run(mlir::Operation*) (mlir-opt+0xa4a26c9)
#<!-- -->23 0x000055a43251a9b3 performActions(llvm::raw_ostream&amp;, std::shared_ptr&lt;llvm::SourceMgr&gt; const&amp;, mlir::MLIRContext*, mlir::MlirOptMainConfig const&amp;) MlirOptMain.cpp:0:0
#<!-- -->24 0x000055a43251b2de processBuffer(llvm::raw_ostream&amp;, std::unique_ptr&lt;llvm::MemoryBuffer, std::default_delete&lt;llvm::MemoryBuffer&gt;&gt;, llvm::MemoryBufferRef, mlir::MlirOptMainConfig const&amp;, mlir::DialectRegistry&amp;, mlir::SourceMgrDiagnosticVerifierHandler*, llvm::ThreadPoolInterface*) MlirOptMain.cpp:0:0
#<!-- -->25 0x000055a43251b521 llvm::LogicalResult llvm::function_ref&lt;llvm::LogicalResult (std::unique_ptr&lt;llvm::MemoryBuffer, std::default_delete&lt;llvm::MemoryBuffer&gt;&gt;, llvm::MemoryBufferRef const&amp;, llvm::raw_ostream&amp;)&gt;::callback_fn&lt;mlir::MlirOptMain(llvm::raw_ostream&amp;, std::unique_ptr&lt;llvm::MemoryBuffer, std::default_delete&lt;llvm::MemoryBuffer&gt;&gt;, mlir::DialectRegistry&amp;, mlir::MlirOptMainConfig const&amp;)::'lambda'(std::unique_ptr&lt;llvm::MemoryBuffer, std::default_delete&lt;llvm::MemoryBuffer&gt;&gt;, llvm::MemoryBufferRef, llvm::raw_ostream&amp;)&gt;(long, std::unique_ptr&lt;llvm::MemoryBuffer, std::default_delete&lt;llvm::MemoryBuffer&gt;&gt;, llvm::MemoryBufferRef const&amp;, llvm::raw_ostream&amp;) MlirOptMain.cpp:0:0
#<!-- -->26 0x000055a43ad25a2d mlir::splitAndProcessBuffer(std::unique_ptr&lt;llvm::MemoryBuffer, std::default_delete&lt;llvm::MemoryBuffer&gt;&gt;, llvm::function_ref&lt;llvm::LogicalResult (std::unique_ptr&lt;llvm::MemoryBuffer, std::default_delete&lt;llvm::MemoryBuffer&gt;&gt;, llvm::MemoryBufferRef const&amp;, llvm::raw_ostream&amp;)&gt;, llvm::raw_ostream&amp;, llvm::StringRef, llvm::StringRef) (mlir-opt+0xa871a2d)
#<!-- -->27 0x000055a4325162da mlir::MlirOptMain(llvm::raw_ostream&amp;, std::unique_ptr&lt;llvm::MemoryBuffer, std::default_delete&lt;llvm::MemoryBuffer&gt;&gt;, mlir::DialectRegistry&amp;, mlir::MlirOptMainConfig const&amp;) (.part.0) MlirOptMain.cpp:0:0
#<!-- -->28 0x000055a43251baf8 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&amp;) (mlir-opt+0x2067af8)
#<!-- -->29 0x000055a43251bd54 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&amp;) (mlir-opt+0x2067d54)
#<!-- -->30 0x000055a4323c85cc main (mlir-opt+0x1f145cc)
#<!-- -->31 0x00007f799e3d5d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#<!-- -->32 0x00007f799e3d5e40 call_init ./csu/../csu/libc-start.c:128:20
#<!-- -->33 0x00007f799e3d5e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#<!-- -->34 0x000055a432433f35 _start (mlir-opt+0x1f7ff35)

I found another verifier-accepted reproducer for the same cast<IntegerAttr> assertion, this time using ub.poison as the linear index rather than a vector constant:

module {
  func.func @repro() -> index {
    %linear = ub.poison : index
    %a, %b = affine.delinearize_index %linear into (2) : index, index
    return %b : index
  }
}

mlir-opt reproducer.mlir -o /dev/null succeeds, but mlir-opt --canonicalize reproducer.mlir -o /dev/null aborts with cast<Ty>() argument of incompatible type! in AffineDelinearizeIndexOp::fold.

I reproduced this on an assertions-enabled LLVM 24.0.0git build at commit 982197fad060f461277020c0ca413d93a5f2a8a6. This appears to exercise the same unchecked cast<IntegerAttr> as the reported vector-constant case, with a different non-IntegerAttr fold value.

Kiritobl avatar Oct 29 '26 09:10 Kiritobl