How to help to locate the bug in my pass which causes the following passes crash?

I get crashed when I execute some passes after my pass. The stacktrace is

 #0 0x00005609959ec674 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/lqw/escape-analysis/llvm-project/llvm/lib/Support/Unix/Signals.inc:565:22
 #1 0x00005609959ec72f PrintStackTraceSignalHandler(void*) /home/lqw/escape-analysis/llvm-project/llvm/lib/Support/Unix/Signals.inc:632:1
 #2 0x00005609959ea39a llvm::sys::RunSignalHandlers() /home/lqw/escape-analysis/llvm-project/llvm/lib/Support/Signals.cpp:97:20
 #3 0x00005609959ebfcb SignalHandler(int) /home/lqw/escape-analysis/llvm-project/llvm/lib/Support/Unix/Signals.inc:407:1
 #4 0x00007f4414769520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #5 0x00005609931e9d18 llvm::BasicBlock::getParent() const /home/lqw/escape-analysis/llvm-project/llvm/include/llvm/IR/BasicBlock.h:107:46
 #6 0x0000560996db0c3f analyzeGlobalAux(llvm::Value const*, llvm::GlobalStatus&, llvm::SmallPtrSetImpl<llvm::Value const*>&) /home/lqw/escape-analysis/llvm-project/llvm/lib/Transforms/Utils/GlobalStatus.cpp:82:54
 #7 0x0000560996db12d0 llvm::GlobalStatus::analyzeGlobal(llvm::Value const*, llvm::GlobalStatus&) /home/lqw/escape-analysis/llvm-project/llvm/lib/Transforms/Utils/GlobalStatus.cpp:188:26
 #8 0x0000560995e6e6a9 processGlobal(llvm::GlobalValue&, llvm::function_ref<llvm::TargetTransformInfo& (llvm::Function&)>, llvm::function_ref<llvm::TargetLibraryInfo& (llvm::Function&)>, llvm::function_ref<llvm::DominatorTree& (llvm::Function&)>) /home/lqw/escape-analysis/llvm-project/llvm/lib/Transforms/IPO/GlobalOpt.cpp:1605:3
 #9 0x0000560995e7055d OptimizeGlobalVars(llvm::Module&, llvm::function_ref<llvm::TargetTransformInfo& (llvm::Function&)>, llvm::function_ref<llvm::TargetLibraryInfo& (llvm::Function&)>, llvm::function_ref<llvm::DominatorTree& (llvm::Function&)>, llvm::SmallPtrSetImpl<llvm::Comdat const*>&) /home/lqw/escape-analysis/llvm-project/llvm/lib/Transforms/IPO/GlobalOpt.cpp:2025:29
#10 0x0000560995e7217d optimizeGlobalsInModule(llvm::Module&, llvm::DataLayout const&, llvm::function_ref<llvm::TargetLibraryInfo& (llvm::Function&)>, llvm::function_ref<llvm::TargetTransformInfo& (llvm::Function&)>, llvm::function_ref<llvm::BlockFrequencyInfo& (llvm::Function&)>, llvm::function_ref<llvm::DominatorTree& (llvm::Function&)>) /home/lqw/escape-analysis/llvm-project/llvm/lib/Transforms/IPO/GlobalOpt.cpp:2422:38
#11 0x0000560995e726dd (anonymous namespace)::GlobalOptLegacyPass::runOnModule(llvm::Module&) /home/lqw/escape-analysis/llvm-project/llvm/lib/Transforms/IPO/GlobalOpt.cpp:2494:35
#12 0x0000560995675da3 (anonymous namespace)::MPPassManager::runOnModule(llvm::Module&) /home/lqw/escape-analysis/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1549:20
#13 0x0000560995670d4a llvm::legacy::PassManagerImpl::run(llvm::Module&) /home/lqw/escape-analysis/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:539:13
#14 0x0000560995676673 llvm::legacy::PassManager::run(llvm::Module&) /home/lqw/escape-analysis/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1677:1
#15 0x0000560992e417af (not shown for privacy)
...

What can I do to help to locate the bug?

can legacy::PassManager print pass names in the pipeline when call run. The version of LLVM is 15.0.0.

llvm::verifyFunction and llvm::verifyModule solved my question.