<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/116358>116358</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[MLIR]``-test-func-erase-arg` triggers Assertion Failure `!NodePtr->isKnownSentinel()'
</td>
</tr>
<tr>
<th>Labels</th>
<td>
mlir
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
xisang0
</td>
</tr>
</table>
<pre>
Test on commit: https://github.com/llvm/llvm-project/commit/6548b6354d1d990e1c98736f5e7c3de876bedc8e
steps to reproduce:
```
mlir-opt test.mlir --test-func-erase-arg
```
test case:
```
module {
llvm.func @malloc(i64) -> !llvm.ptr
}
```
crash trace:
```
mlir-opt: /home/workdir/llvm-project-19/llvm/include/llvm/ADT/ilist_iterator.h:168: reference llvm::ilist_iterator<llvm::ilist_detail::node_options<mlir::Block, true, false, void, false, void>, false, false>::operator*() const [OptionsT = llvm::ilist_detail::node_options<mlir::Block, true, false, void, false, void>, IsReverse = false, IsConst = false]: Assertion `!NodePtr->isKnownSentinel()' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: ./mlir-opt /home/workdir/test.mlir --test-func-erase-arg
#0 0x00006323c2d643b8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (./mlir-opt+0x10723b8)
#1 0x00006323c2d61ede llvm::sys::RunSignalHandlers() (./mlir-opt+0x106fede)
#2 0x00006323c2d64dc8 SignalHandler(int) Signals.cpp:0:0
#3 0x00007337c4053520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007337c40a79fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x00007337c4053476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x00007337c40397f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x00007337c403971b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#8 0x00007337c404ae96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#9 0x00006323c8156294 (./mlir-opt+0x6464294)
#10 0x00006323c5eba304 (anonymous namespace)::TestFuncEraseArg::runOnOperation() TestFunc.cpp:0:0
#11 0x00006323c5fe06df mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (./mlir-opt+0x42ee6df)
#12 0x00006323c5fe0ec2 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (./mlir-opt+0x42eeec2)
#13 0x00006323c5fe366e mlir::PassManager::run(mlir::Operation*) (./mlir-opt+0x42f166e)
#14 0x00006323c5fdc192 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#15 0x00006323c5fdbdfb llvm::LogicalResult llvm::function_ref<llvm::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&)::$_0>(long, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) MlirOptMain.cpp:0:0
#16 0x00006323c6085ae5 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::raw_ostream&)>, llvm::raw_ostream&, llvm::StringRef, llvm::StringRef) (./mlir-opt+0x4393ae5)
#17 0x00006323c5fd6ff2 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (./mlir-opt+0x42e4ff2)
#18 0x00006323c5fd72a3 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (./mlir-opt+0x42e52a3)
#19 0x00006323c5fd74b2 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (./mlir-opt+0x42e54b2)
#20 0x00006323c2d435d7 main (./mlir-opt+0x10515d7)
#21 0x00007337c403ad90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#22 0x00007337c403ae40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#23 0x00006323c2d43145 _start (./mlir-opt+0x1051145)
Aborted (core dumped)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzcWF1z4yoS_TX4hbJLAglJD35wPlw7tZNNKsm7C0FLZoPBC2gm-fdbSI5jOXZmfGvvbu2dmpQlPk6f03RDC-69ag3AHOVXKL-Z8C6srZu_Ks9Nm0xqK9_mz-ADtgYLu9mogOgCr0PYekQXiCwRWbYqrLt6JuwGkaXWP95_pltn_wkiILLcTSVLlmdlzWieyVRWVQKpqMqCsiaHQlAJZcFqkKIElNygZOEDbD0OFjvYOis7AdFo34VYsvvfv260clO7DTiAD7P4hqfT-DxtOiOm4LiHKXftyclxHBbcn0e3stOAUXE1vGMc9c0iNEZZsuFaW4FIqViGSIWniN5iRNJ-0Da4HWZxcxJcOO7XODj-a3XR94gs13YDiCx_WvcilTvy9jStPpZBGaE7CR8Ni5vn2KyVDysVwPFg3WyN6CJlZUR30IADI6BXGPnQxXg0otfHXRICV3poMVbCym6DssYjeh2ZDx1X2ooXRK5xcB3E34Zr3z_8sEp-bqC3o7bhgd4OYHa7I0MWiJTR58IaHzDKr-4H288Y0ZtPIv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