error: 'arith.extsi' op operation destroyed but still has uses
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 624
- Forks
- 170
- PR merge metrics
- No merged PRs in 30d
Description
I'm trying to use polygeist to convert C to MLIR with the following command:
```
clang -E aes.c -o aes-pre.c
cgeist aes-pre.c -S --function=* --raise-scf-to-affine -o aes.affine.mlir
```
And the following error occured:
```
loc("aes-pre.c":1476:14): error: 'arith.extsi' op operation destroyed but still has uses
LLVM ERROR: operation destroyed but still has uses
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: cgeist aes-pre.c --function=* --raise-scf-to-affine -o aes.affine.mlir -opaque-pointers=0
#0 0x0000555711080ee0 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/vic/soft/Polygeist/llvm-project/llvm/lib/Support/Unix/Signals.inc:569:22
#1 0x0000555711080f9b PrintStackTraceSignalHandler(void*) /home/vic/soft/Polygeist/llvm-project/llvm/lib/Support/Unix/Signals.inc:636:1
#2 0x000055571107eba6 llvm::sys::RunSignalHandlers() /home/vic/soft/Polygeist/llvm-project/llvm/lib/Support/Signals.cpp:104:20
#3 0x0000555711080818 SignalHandler(int) /home/vic/soft/Polygeist/llvm-project/llvm/lib/Support/Unix/Signals.inc:407:1
#4 0x00007fcacdeef420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#5 0x00007fcacd9da00b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
#6 0x00007fcacd9b9859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
#7 0x0000555710faab36 llvm::report_fatal_error(llvm::Twine const&, bool) /home/vic/soft/Polygeist/llvm-project/llvm/lib/Support/ErrorHandling.cpp:125:9
#8 0x0000555710faa919 llvm::report_fatal_error(llvm::StringRef, bool) /home/vic/soft/Polygeist/llvm-project/llvm/lib/Support/ErrorHandling.cpp:86:68
#9 0x0000555711762b7a mlir::Operation::~Operation() /home/vic/soft/Polygeist/llvm-project/mlir/lib/IR/Operation.cpp:152:7
#10 0x0000555711762d1c mlir::Operation::destroy() /home/vic/soft/Polygeist/llvm-project/mlir/lib/IR/Operation.cpp:171:7
#11 0x00005557117636a4 llvm::ilist_traits::deleteNode(mlir::Operation*) /home/vic/soft/Polygeist/llvm-project/mlir/lib/IR/Operation.cpp:372:1
#12 0x000055570f2434e1 llvm::iplist_impl, llvm::ilist_traits>::erase(llvm::ilist_iterator, false, false>) /home/vic/soft/Polygeist/build/../llvm-project/llvm/include/llvm/ADT/ilist.h:270:12
#13 0x000055570f23e59c llvm::iplist_impl, llvm::ilist_traits>::pop_back() /home/vic/soft/Polygeist/build/../llvm-project/llvm/include/llvm/ADT/ilist.h:322:3
#14 0x000055570f23c31b mlir::Block::clear() /home/vic/soft/Polygeist/build/../llvm-project/llvm/../mlir/include/mlir/IR/Block.h:41:5
#15 0x00005557115fd220 mlir::Block::~Block() /home/vic/soft/Polygeist/llvm-project/mlir/lib/IR/Block.cpp:22:28
#16 0x000055570f209c3e llvm::ilist_alloc_traits::deleteNode(mlir::Block*) /home/vic/soft/Polygeist/build/../llvm-project/llvm/include/llvm/ADT/ilist.h:42:39
#17 0x000055570f1f2539 llvm::iplist_impl, llvm::ilist_traits>::erase(llvm::ilist_iterator, false, false>) /home/vic/soft/Polygeist/build/../llvm-project/llvm/include/llvm/ADT/ilist.h:270:12
#18 0x000055570f1d4f98 llvm::iplist_impl, llvm::ilist_traits>::erase(llvm::ilist_iterator, false, false>, llvm::ilist_iterator, false, false>) /home/vic/soft/Polygeist/build/../llvm-project/llvm/include/llvm/ADT/ilist.h:306:13
#19 0x000055570f1acd1f llvm::iplist_impl, llvm::ilist_traits>::clear() /home/vic/soft/Polygeist/build/../llvm-project/llvm/include/llvm/ADT/ilist.h:310:41
#20 0x000055571178e422 llvm::iplist_impl, llvm::ilist_traits>::~iplist_impl() /home/vic/soft/Polygeist/llvm-project/llvm/include/llvm/ADT/ilist.h:211:29
#21 0x000055571178e1b4 llvm::iplist::~iplist() /home/vic/soft/Polygeist/llvm-project/llvm/include/llvm/ADT/ilist.h:391:7
#22 0x000055571178cb26 mlir::Region::~Region() /home/vic/soft/Polygeist/llvm-project/mlir/lib/IR/Region.cpp:20:1
#23 0x0000555711762cb5 mlir::Operation::~Operation() /home/vic/soft/Polygeist/llvm-project/mlir/lib/IR/Operation.cpp:160:3
#24 0x0000555711762d1c mlir::Operation::destroy() /home/vic/soft/Polygeist/llvm-project/mlir/lib/IR/Operation.cpp:171:7
#25 0x00005557117636a4 llvm::ilist_traits::deleteNode(mlir::Operation*) /home/vic/soft/Polygeist/llvm-project/mlir/lib/IR/Operation.cpp:372:1
#26 0x000055570f2434e1 llvm::iplist_impl, llvm::ilist_traits>::erase(llvm::ilist_iterator, false, false>) /home/vic/soft/Polygeist/build/../llvm-project/llvm/include/llvm/ADT/ilist.h:270:12
#27 0x000055571176c1db llvm::iplist_impl, llvm::ilist_traits>::erase(mlir::Operation*) /home/vic/soft/Polygeist/llvm-project/llvm/include/llvm/ADT/ilist.h:273:60
#28 0x0000555711763871 mlir::Operation::erase() /home/vic/soft/Polygeist/llvm-project/mlir/lib/IR/Operation.cpp:423:1
#29 0x00005557117876f6 mlir::RewriterBase::replaceOp(mlir::Operation*, mlir::ValueRange) /home/vic/soft/Polygeist/llvm-project/mlir/lib/IR/PatternMatch.cpp:255:1
#30 0x0000555711db97cf MoveWhileToFor::matchAndRewrite(mlir::scf::WhileOp, mlir::PatternRewriter&) const /home/vic/soft/Polygeist/lib/polygeist/Passes/CanonicalizeFor.cpp:976:20
#31 0x0000555711de97c6 mlir::detail::OpOrInterfaceRewritePatternBase::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&) const /home/vic/soft/Polygeist/build/../llvm-project/llvm/../mlir/include/mlir/IR/PatternMatch.h:330:3
#32 0x0000555714ae7213 mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref, llvm::function_ref, llvm::function_ref) /home/vic/soft/Polygeist/llvm-project/mlir/lib/Rewrite/PatternApplicator.cpp:201:53
#33 0x0000555714ab97f8 (anonymous namespace)::GreedyPatternRewriteDriver::simplify(llvm::MutableArrayRef) /home/vic/soft/Polygeist/llvm-project/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp:270:76
#34 0x0000555714aba4cc mlir::applyPatternsAndFoldGreedily(llvm::MutableArrayRef, mlir::FrozenRewritePatternSet const&, mlir::GreedyRewriteConfig) /home/vic/soft/Polygeist/llvm-project/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp:405:35
#35 0x0000555711cea8e5 mlir::applyPatternsAndFoldGreedily(mlir::Operation*, mlir::FrozenRewritePatternSet const&, mlir::GreedyRewriteConfig) /home/vic/soft/Polygeist/llvm-project/mlir/include/mlir/Transforms/GreedyPatternRewriteDriver.h:72:1
#36 0x0000555711db3a42 (anonymous namespace)::CanonicalizeFor::runOnOperation() /home/vic/soft/Polygeist/lib/polygeist/Passes/CanonicalizeFor.cpp:2242:76
#37 0x0000555714b8a85a mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) /home/vic/soft/Polygeist/llvm-project/mlir/lib/Pass/Pass.cpp:462:27
#38 0x0000555714b8ab35 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) /home/vic/soft/Polygeist/llvm-project/mlir/lib/Pass/Pass.cpp:525:15
#39 0x0000555714b8b8d8 mlir::detail::OpToOpPassAdaptor::runOnOperationImpl(bool) /home/vic/soft/Polygeist/llvm-project/mlir/lib/Pass/Pass.cpp:666:19
#40 0x0000555714b8b663 mlir::detail::OpToOpPassAdaptor::runOnOperation(bool) /home/vic/soft/Polygeist/llvm-project/mlir/lib/Pass/Pass.cpp:649:1
#41 0x0000555714b8a83b mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) /home/vic/soft/Polygeist/llvm-project/mlir/lib/Pass/Pass.cpp:459:28
#42 0x0000555714b8ab35 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) /home/vic/soft/Polygeist/llvm-project/mlir/lib/Pass/Pass.cpp:525:15
#43 0x0000555714b8c85e mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) /home/vic/soft/Polygeist/llvm-project/mlir/lib/Pass/Pass.cpp:829:71
#44 0x0000555714b8c6b4 mlir::PassManager::run(mlir::Operation*) /home/vic/soft/Polygeist/llvm-project/mlir/lib/Pass/Pass.cpp:808:76
#45 0x000055570f18e0ac main /home/vic/soft/Polygeist/tools/cgeist/driver.cc:609:21
#46 0x00007fcacd9bb083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#47 0x000055570f1601ee _start (/home/vic/soft/Polygeist/build/bin/cgeist+0x8b41ee)
```
Is there anything I should do to avoid this problem?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure with the cgeist command and aes-pre.c input described in the issue. Start at MoveWhileToFor::matchAndRewrite in lib/polygeist/Passes/CanonicalizeFor.cpp:976, then trace the CanonicalizeFor pass entry point at line 2242. Done means the conversion no longer destroys an arith.extsi operation while it still has uses and completes without this crash.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 28/100