[llvm] [NFC][LiveStacks] Use vectors instead of map and unordred_map (PR #165477)
Qinkun Bao via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 8 08:12:13 PST 2026
qinkunbao wrote:
Hi, I think this PR has a memory leakage. Could you take a look?
```
Direct leak of 528 byte(s) in 2 object(s) allocated from:
#0 0x5f9f8d40a6dc in realloc /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:81:3
#1 0x5f9f94cdffb3 in safe_realloc /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/Support/MemAlloc.h:53:18
#2 0x5f9f94cdffb3 in llvm::SmallVectorBase<unsigned int>::grow_pod(void*, unsigned long, unsigned long) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/SmallVector.cpp:159:15
#3 0x5f9f92b00d26 in grow_pod /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/ADT/SmallVector.h:140:11
#4 0x5f9f92b00d26 in grow /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/ADT/SmallVector.h:528:41
#5 0x5f9f92b00d26 in reserveForParamAndGetAddressImpl<llvm::SmallVectorTemplateBase<llvm::LiveRange::Segment, true> > /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/ADT/SmallVector.h:249:11
#6 0x5f9f92b00d26 in reserveForParamAndGetAddress /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/ADT/SmallVector.h:533:12
#7 0x5f9f92b00d26 in push_back /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/ADT/SmallVector.h:565:23
#8 0x5f9f92b00d26 in llvm::LiveRangeUpdater::add(llvm::LiveRange::Segment) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/CodeGen/LiveInterval.cpp:1272:18
#9 0x5f9f92b0174b in add /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/CodeGen/LiveInterval.h:976:7
#10 0x5f9f92b0174b in llvm::LiveRange::MergeSegmentsInAsValue(llvm::LiveRange const&, llvm::VNInfo*) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/CodeGen/LiveInterval.cpp:717:13
#11 0x5f9f93236c92 in (anonymous namespace)::InlineSpiller::spillAll() /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/CodeGen/InlineSpiller.cpp:1295:15
#12 0x5f9f93234141 in (anonymous namespace)::InlineSpiller::spill(llvm::LiveRangeEdit&, llvm::AllocationOrder*) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/CodeGen/InlineSpiller.cpp:1353:5
#13 0x5f9f932b6ee4 in llvm::RAGreedy::selectOrSplitImpl(llvm::LiveInterval const&, llvm::SmallVectorImpl<llvm::Register>&, llvm::SmallSet<llvm::Register, 16u, std::__1::less<llvm::Register>>&, llvm::SmallVector<std::__1::pair<llvm::LiveInterval const*, llvm::MCRegister>, 8u>&, unsigned int) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/CodeGen/RegAllocGreedy.cpp:2727:13
#14 0x5f9f932b7ba6 in llvm::RAGreedy::selectOrSplit(llvm::LiveInterval const&, llvm::SmallVectorImpl<llvm::Register>&) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/CodeGen/RegAllocGreedy.cpp:2329:7
#15 0x5f9f93220bf6 in llvm::RegAllocBase::allocatePhysRegs() /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/CodeGen/RegAllocBase.cpp:115:35
#16 0x5f9f9328f2d1 in llvm::RAGreedy::run(llvm::MachineFunction&) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/CodeGen/RegAllocGreedy.cpp:2984:3
#17 0x5f9f932c4700 in (anonymous namespace)::RAGreedyLegacy::runOnMachineFunction(llvm::MachineFunction&) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/CodeGen/RegAllocGreedy.cpp:292:15
#18 0x5f9f92cfc2f4 in llvm::MachineFunctionPass::runOnFunction(llvm::Function&) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/CodeGen/MachineFunctionPass.cpp:112:10
#19 0x5f9f93cc49c4 in llvm::FPPassManager::runOnFunction(llvm::Function&) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1398:27
#20 0x5f9f93cda971 in llvm::FPPassManager::runOnModule(llvm::Module&) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1444:16
#21 0x5f9f93cc63b7 in runOnModule /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1513:27
#22 0x5f9f93cc63b7 in llvm::legacy::PassManagerImpl::run(llvm::Module&) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:531:44
#23 0x5f9f9603a95d in RunCodegenPipeline /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1277:19
#24 0x5f9f9603a95d in emitAssembly /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1301:3
#25 0x5f9f9603a95d in clang::emitBackendOutput(clang::CompilerInstance&, clang::CodeGenOptions&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::__1::unique_ptr<llvm::raw_pwrite_stream, std::__1::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1473:13
#26 0x5f9f9606506e in clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:310:3
#27 0x5f9f9a4b55ae in clang::ParseAST(clang::Sema&, bool, bool) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Parse/ParseAST.cpp:183:13
#28 0x5f9f96071a01 in clang::CodeGenAction::ExecuteAction() /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:1107:30
#29 0x5f9f96ca67c5 in clang::FrontendAction::Execute() /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1322:3
#30 0x5f9f96b8cd4f in clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:1007:33
#31 0x5f9f96f35f5c in clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:310:25
#32 0x5f9f8d45ab5c in cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/tools/driver/cc1_main.cpp:304:15
#33 0x5f9f8d452bbc in ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/tools/driver/driver.cpp:226:12
#34 0x5f9f8d458ced in operator() /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/tools/driver/driver.cpp:376:12
#35 0x5f9f8d458ced in int llvm::function_ref<int (llvm::SmallVectorImpl<char const*>&)>::callback_fn<clang_main(int, char**, llvm::ToolContext const&)::$_0>(long, llvm::SmallVectorImpl<char const*>&) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:46:12
#36 0x5f9f967c9486 in operator() /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:69:12
#37 0x5f9f967c9486 in operator() /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Driver/Job.cpp:442:34
#38 0x5f9f967c9486 in void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::__1::optional<llvm::StringRef>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>*, bool*) const::$_0>(long) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:46:12
#39 0x5f9f94c59333 in operator() /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:69:12
#40 0x5f9f94c59333 in llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:426:3
#41 0x5f9f967c6eeb in clang::driver::CC1Command::Execute(llvm::ArrayRef<std::__1::optional<llvm::StringRef>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>*, bool*) const /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Driver/Job.cpp:442:12
#42 0x5f9f96725d41 in clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Driver/Compilation.cpp:196:15
#43 0x5f9f96726414 in clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*>>&, bool) const /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Driver/Compilation.cpp:246:19
```
https://github.com/llvm/llvm-project/pull/165477
More information about the llvm-commits
mailing list