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

--remove-dead-values pass crashes on any complex enough CIR code #1149

Open
keryell opened this issue Nov 20, 2024 · 1 comment
Open

--remove-dead-values pass crashes on any complex enough CIR code #1149

keryell opened this issue Nov 20, 2024 · 1 comment

Comments

@keryell
Copy link
Contributor

keryell commented Nov 20, 2024

For example with the ClangIR of the day bae7bd9 on https://github.com/llvm/clangir/blob/main/clang/test/CIR/Lowering/ThroughMLIR/scope.cir
This is an old story that CIR is not yet a clean dialect to survive to some usual code analyses and code transformations.

PATH=$LLVM_DIR/build/bin:$PATH $LLVM_DIR/build/bin/cir-opt --remove-dead-values clang/test/CIR/Lowering/ThroughMLIR/scope.cir
cir-opt: /home/rkeryell/Xilinx/Projects/LLVM/worktrees/clangir/llvm/../mlir/include/mlir/IR/Operation.h:983: detail::OperandStorage &mlir::Operation::getOperandStorage(): Assertion `hasOperandStorage && "expected operation to have operand storage"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /home/rkeryell/Xilinx/Projects/LLVM/worktrees/clangir/build/bin/cir-opt --remove-dead-values /home/rkeryell/Xilinx/Projects/LLVM/worktrees/clangir/clang/test/CIR/Lowering/ThroughMLIR/scope.cir
 #0 0x00005f0c58b5708d llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/rkeryell/Xilinx/Projects/LLVM/worktrees/clangir/llvm/lib/Support/Unix/Signals.inc:723:11
 #1 0x00005f0c58b5754b PrintStackTraceSignalHandler(void*) /home/rkeryell/Xilinx/Projects/LLVM/worktrees/clangir/llvm/lib/Support/Unix/Signals.inc:798:1
 #2 0x00005f0c58b556ef llvm::sys::RunSignalHandlers() /home/rkeryell/Xilinx/Projects/LLVM/worktrees/clangir/llvm/lib/Support/Signals.cpp:105:5
 #3 0x00005f0c58b57c0e SignalHandler(int) /home/rkeryell/Xilinx/Projects/LLVM/worktrees/clangir/llvm/lib/Support/Unix/Signals.inc:413:1
 #4 0x0000726998445250 (/lib/x86_64-linux-gnu/libc.so.6+0x45250)
 #5 0x00007269984a3f1c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #6 0x00007269984a3f1c __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #7 0x00007269984a3f1c pthread_kill ./nptl/pthread_kill.c:89:10
 #8 0x000072699844519e raise ./signal/../sysdeps/posix/raise.c:27:6
 #9 0x0000726998428902 abort ./stdlib/abort.c:81:7
#10 0x000072699842881e _nl_load_domain ./intl/loadmsgcat.c:1177:9
#11 0x000072699843b7c7 (/lib/x86_64-linux-gnu/libc.so.6+0x3b7c7)
#12 0x00005f0c56d75d5b mlir::Operation::getOperandStorage() /home/rkeryell/Xilinx/Projects/LLVM/worktrees/clangir/llvm/../mlir/include/mlir/IR/Operation.h:0:5
#13 0x00005f0c588fa779 mlir::Operation::eraseOperands(llvm::BitVector const&) /home/rkeryell/Xilinx/Projects/LLVM/worktrees/clangir/mlir/include/mlir/IR/Operation.h:362:5
#14 0x00005f0c588f586b (anonymous namespace)::cleanRegionBranchOp(mlir::RegionBranchOpInterface, mlir::dataflow::RunLivenessAnalysis&) /home/rkeryell/Xilinx/Projects/LLVM/worktrees/clangir/mlir/lib/Transforms/RemoveDeadValues.cpp:544:25
#15 0x00005f0c588f4d6d (anonymous namespace)::RemoveDeadValues::runOnOperation()::$_1::operator()(mlir::Operation*) const /home/rkeryell/Xilinx/Projects/LLVM/worktrees/clangir/mlir/lib/Transforms/RemoveDeadValues.cpp:599:5
#16 0x00005f0c588f4cad void llvm::function_ref<void (mlir::Operation*)>::callback_fn<(anonymous namespace)::RemoveDeadValues::runOnOperation()::$_1>(long, mlir::Operation*) /home/rkeryell/Xilinx/Projects/LLVM/worktrees/clangir/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:5
#17 0x00005f0c5798baa1 llvm::function_ref<void (mlir::Operation*)>::operator()(mlir::Operation*) const /home/rkeryell/Xilinx/Projects/LLVM/worktrees/clangir/llvm/include/llvm/ADT/STLFunctionalExtras.h:68:5
#18 0x00005f0c5798ba6d void mlir::detail::walk<mlir::ForwardIterator>(mlir::Operation*, llvm::function_ref<void (mlir::Operation*)>, mlir::WalkOrder) /home/rkeryell/Xilinx/Projects/LLVM/worktrees/clangir/mlir/include/mlir/IR/Visitors.h:187:1
#19 0x00005f0c5798ba29 void mlir::detail::walk<mlir::ForwardIterator>(mlir::Operation*, llvm::function_ref<void (mlir::Operation*)>, mlir::WalkOrder) /home/rkeryell/Xilinx/Projects/LLVM/worktrees/clangir/mlir/include/mlir/IR/Visitors.h:179:27
#20 0x00005f0c5798ba29 void mlir::detail::walk<mlir::ForwardIterator>(mlir::Operation*, llvm::function_ref<void (mlir::Operation*)>, mlir::WalkOrder) /home/rkeryell/Xilinx/Projects/LLVM/worktrees/clangir/mlir/include/mlir/IR/Visitors.h:179:27
#21 0x00005f0c588f4c52 std::enable_if<llvm::is_one_of<mlir::Operation*, mlir::Operation*, mlir::Region*, mlir::Block*>::value, void>::type mlir::detail::walk<(mlir::WalkOrder)1, mlir::ForwardIterator, (anonymous namespace)::RemoveDeadValues::runOnOperation()::$_1, mlir::Operation*, void>(mlir::Operation*, (anonymous namespace)::RemoveDeadValues::runOnOperation()::$_1&&) /home/rkeryell/Xilinx/Projects/LLVM/worktrees/clangir/mlir/include/mlir/IR/Visitors.h:312:3
#22 0x00005f0c588f4a5d std::enable_if<llvm::function_traits<std::decay<(anonymous namespace)::RemoveDeadValues::runOnOperation()::$_1>::type>::num_args == 1, void>::type mlir::Operation::walk<(mlir::WalkOrder)1, mlir::ForwardIterator, (anonymous namespace)::RemoveDeadValues::runOnOperation()::$_1, void>((anonymous namespace)::RemoveDeadValues::runOnOperation()::$_1&&) /home/rkeryell/Xilinx/Projects/LLVM/worktrees/clangir/mlir/include/mlir/IR/Operation.h:794:5
#23 0x00005f0c588f48f9 (anonymous namespace)::RemoveDeadValues::runOnOperation() /home/rkeryell/Xilinx/Projects/LLVM/worktrees/clangir/mlir/lib/Transforms/RemoveDeadValues.cpp:609:1
#24 0x00005f0c58856994 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int)::$_1::operator()() const /home/rkeryell/Xilinx/Projects/LLVM/worktrees/clangir/mlir/lib/Pass/Pass.cpp:0:17
#25 0x00005f0c58856935 void llvm::function_ref<void ()>::callback_fn<mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int)::$_1>(long) /home/rkeryell/Xilinx/Projects/LLVM/worktrees/clangir/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:5
#26 0x00005f0c585ad539 llvm::function_ref<void ()>::operator()() const /home/rkeryell/Xilinx/Projects/LLVM/worktrees/clangir/llvm/include/llvm/ADT/STLFunctionalExtras.h:68:5
#27 0x00005f0c5885957b void mlir::MLIRContext::executeAction<mlir::PassExecutionAction, mlir::Pass&>(llvm::function_ref<void ()>, llvm::ArrayRef<mlir::IRUnit>, mlir::Pass&) /home/rkeryell/Xilinx/Projects/LLVM/worktrees/clangir/mlir/include/mlir/IR/MLIRContext.h:281:3
#28 0x00005f0c58852457 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) /home/rkeryell/Xilinx/Projects/LLVM/worktrees/clangir/mlir/lib/Pass/Pass.cpp:532:17
#29 0x00005f0c58852977 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) /home/rkeryell/Xilinx/Projects/LLVM/worktrees/clangir/mlir/lib/Pass/Pass.cpp:592:16
#30 0x00005f0c588543b8 mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) /home/rkeryell/Xilinx/Projects/LLVM/worktrees/clangir/mlir/lib/Pass/Pass.cpp:905:10
#31 0x00005f0c588542f3 mlir::PassManager::run(mlir::Operation*) /home/rkeryell/Xilinx/Projects/LLVM/worktrees/clangir/mlir/lib/Pass/Pass.cpp:885:60
#32 0x00005f0c587c6abd performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) /home/rkeryell/Xilinx/Projects/LLVM/worktrees/clangir/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:412:17
#33 0x00005f0c587c6722 processBuffer(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, llvm::ThreadPoolInterface*) /home/rkeryell/Xilinx/Projects/LLVM/worktrees/clangir/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:477:12
#34 0x00005f0c587c651c mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&)::$_0::operator()(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) const /home/rkeryell/Xilinx/Projects/LLVM/worktrees/clangir/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:560:12
#35 0x00005f0c587c64b6 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&) /home/rkeryell/Xilinx/Projects/LLVM/worktrees/clangir/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:12
#36 0x00005f0c59cb3cc2 llvm::function_ref<llvm::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>::operator()(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) const /home/rkeryell/Xilinx/Projects/LLVM/worktrees/clangir/llvm/include/llvm/ADT/STLFunctionalExtras.h:68:12
#37 0x00005f0c59cb32d5 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) /home/rkeryell/Xilinx/Projects/LLVM/worktrees/clangir/mlir/lib/Support/ToolUtilities.cpp:27:12
#38 0x00005f0c587c2d43 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) /home/rkeryell/Xilinx/Projects/LLVM/worktrees/clangir/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:563:10
#39 0x00005f0c587c30e5 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) /home/rkeryell/Xilinx/Projects/LLVM/worktrees/clangir/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:604:14
#40 0x00005f0c587c32b8 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) /home/rkeryell/Xilinx/Projects/LLVM/worktrees/clangir/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:620:10
#41 0x00005f0c56d7363c main /home/rkeryell/Xilinx/Projects/LLVM/worktrees/clangir/clang/tools/cir-opt/cir-opt.cpp:82:17
#42 0x000072699842a3b8 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#43 0x000072699842a47b call_init ./csu/../csu/libc-start.c:128:20
#44 0x000072699842a47b __libc_start_main ./csu/../csu/libc-start.c:347:5
#45 0x00005f0c56d73355 _start (/home/rkeryell/Xilinx/Projects/LLVM/worktrees/clangir/build/bin/cir-opt+0x1f20355)
[1]    56000 IOT instruction (core dumped)  PATH=$LLVM_DIR/build/bin:$PATH $LLVM_DIR/build/bin/cir-opt  
@bcardosolopes
Copy link
Member

Great to see you playing with the MLIR passes and how CIR behave with them. So far we have only tried a few, improvements and enablement of more of these would be great

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants