[llvm-commits] [PATCH] Delete the CompileUnits that DwarfDebug allocates

Jeffrey Yasskin jyasskin at google.com
Sat Mar 6 19:07:40 PST 2010


On Sat, Mar 6, 2010 at 3:20 PM, Jeffrey Yasskin <jyasskin at google.com> wrote:
> On Sat, Mar 6, 2010 at 1:51 AM, Jeffrey Yasskin <jyasskin at google.com> wrote:
>> DwarfDebug new's CompileUnits in beginModule() but never deleted them.
>> This patch deletes them in endModule(), but I don't know enough about
>> how DwarfDebug is used to know for sure that's right. Please
>> double-check it.
>
> Here's a new patch which also destroys the DbgScopes. I'm still
> working on testing it against the FrontendC* set. It passes the rest
> of check-lit.
> This should enable my MDNode deletion patch to go in, but I haven't
> tested that again either.

Compiling the FrontendC* tests with clang, I've confirmed that this
second patch fails the same number of tests as fail at head, and that
it gives the MDNode deletion patch the same property. It's possible
that it still affects some of the tests that pass with llvm-gcc and
fail with clang; I hope to use the buildbots to check for that.


The remaining leaks will be:

==88969== 16 bytes in 1 blocks are definitely lost in loss record 15 of 158
==88969==    at 0x1911AD3: operator new(unsigned long) (vg_replace_malloc.c:220)
==88969==    by 0x22E107: createX86MCInstPrinter(llvm::Target const&,
unsigned int, llvm::MCAsmInfo const&, llvm::raw_ostream&)
(X86AsmPrinter.cpp:640)
==88969==    by 0x45D7A3: llvm::Target::createMCInstPrinter(unsigned
int, llvm::MCAsmInfo const&, llvm::raw_ostream&) const
(TargetRegistry.h:257)
==88969==    by 0x45C023:
llvm::LLVMTargetMachine::addPassesToEmitFile(llvm::PassManagerBase&,
llvm::formatted_raw_ostream&, llvm::TargetMachine::CodeGenFileType,
llvm::CodeGenOpt::Level, bool) (LLVMTargetMachine.cpp:136)
==88969==    by 0x2E78: main (llc.cpp:359)
==88969==
==88969== 22 bytes in 1 blocks are possibly lost in loss record 47 of 158
==88969==    at 0x1911AD3: operator new(unsigned long) (vg_replace_malloc.c:220)
==88969==    by 0x1B66A69: std::string::_Rep::_S_create(unsigned long,
unsigned long, std::allocator<char> const&) (in
/opt/local/lib/gcc44/libstdc++.6.dylib)
==88969==    by 0x1B67753: char* std::string::_S_construct<char
const*>(char const*, char const*, std::allocator<char> const&,
std::forward_iterator_tag) (in /opt/local/lib/gcc44/libstdc++.6.dylib)
==88969==    by 0x1B67985: std::basic_string<char,
std::char_traits<char>, std::allocator<char> >::basic_string(char
const*, unsigned long, std::allocator<char> const&) (in
/opt/local/lib/gcc44/libstdc++.6.dylib)
==88969==    by 0xE678D: llvm::StringRef::str() const (ADT/StringRef.h:148)
==88969==    by 0xE215E: llvm::StringRef::operator std::string() const
(ADT/StringRef.h:164)
==88969==    by 0x7ACEB7: llvm::sys::Path::Path(llvm::StringRef)
(Unix/Path.inc:82)
==88969==    by 0x1FF8: GetOutputStream(char const*, char const*) (llc.cpp:137)
==88969==    by 0x2A18: main (llc.cpp:293)
==88969==
==88969== 32 bytes in 2 blocks are definitely lost in loss record 131 of 158
==88969==    at 0x1911AD3: operator new(unsigned long) (vg_replace_malloc.c:220)
==88969==    by 0x1B66A69: std::string::_Rep::_S_create(unsigned long,
unsigned long, std::allocator<char> const&) (in
/opt/local/lib/gcc44/libstdc++.6.dylib)
==88969==    by 0x1B67753: char* std::string::_S_construct<char
const*>(char const*, char const*, std::allocator<char> const&,
std::forward_iterator_tag) (in /opt/local/lib/gcc44/libstdc++.6.dylib)
==88969==    by 0x1B67985: std::basic_string<char,
std::char_traits<char>, std::allocator<char> >::basic_string(char
const*, unsigned long, std::allocator<char> const&) (in
/opt/local/lib/gcc44/libstdc++.6.dylib)
==88969==    by 0xE678D: llvm::StringRef::str() const (ADT/StringRef.h:148)
==88969==    by 0xE215E: llvm::StringRef::operator std::string() const
(ADT/StringRef.h:164)
==88969==    by 0x67844D: llvm::MCSymbol::MCSymbol(llvm::StringRef,
bool) (MCSymbol.h:60)
==88969==    by 0x678204:
llvm::MCContext::GetOrCreateSymbol(llvm::StringRef) (MCContext.cpp:39)
==88969==    by 0x22B8E9:
llvm::X86AsmPrinter::GetGlobalValueSymbol(llvm::GlobalValue const*)
const (X86AsmPrinter.cpp:59)
==88969==    by 0x40DAA2:
llvm::DwarfDebug::constructGlobalVariableDIE(llvm::MDNode*)
(DwarfDebug.cpp:1742)
==88969==    by 0x40DF50: llvm::DwarfDebug::beginModule(llvm::Module*,
llvm::MachineModuleInfo*) (DwarfDebug.cpp:1825)
==88969==    by 0x42D136:
llvm::DwarfWriter::BeginModule(llvm::Module*,
llvm::MachineModuleInfo*, llvm::raw_ostream&, llvm::AsmPrinter*,
llvm::MCAsmInfo const*) (DwarfWriter.cpp:46)
==88969==
==88969== 38 bytes in 2 blocks are definitely lost in loss record 136 of 158
==88969==    at 0x1911AD3: operator new(unsigned long) (vg_replace_malloc.c:220)
==88969==    by 0x1B66A69: std::string::_Rep::_S_create(unsigned long,
unsigned long, std::allocator<char> const&) (in
/opt/local/lib/gcc44/libstdc++.6.dylib)
==88969==    by 0x1B67753: char* std::string::_S_construct<char
const*>(char const*, char const*, std::allocator<char> const&,
std::forward_iterator_tag) (in /opt/local/lib/gcc44/libstdc++.6.dylib)
==88969==    by 0x1B67985: std::basic_string<char,
std::char_traits<char>, std::allocator<char> >::basic_string(char
const*, unsigned long, std::allocator<char> const&) (in
/opt/local/lib/gcc44/libstdc++.6.dylib)
==88969==    by 0xE678D: llvm::StringRef::str() const (ADT/StringRef.h:148)
==88969==    by 0xE215E: llvm::StringRef::operator std::string() const
(ADT/StringRef.h:164)
==88969==    by 0x67844D: llvm::MCSymbol::MCSymbol(llvm::StringRef,
bool) (MCSymbol.h:60)
==88969==    by 0x678204:
llvm::MCContext::GetOrCreateSymbol(llvm::StringRef) (MCContext.cpp:39)
==88969==    by 0x47C97D:
llvm::MachineBasicBlock::getSymbol(llvm::MCContext&) const
(MachineBasicBlock.cpp:50)
==88969==    by 0x23240E:
llvm::X86MCInstLower::Lower(llvm::MachineInstr const*, llvm::MCInst&)
const (X86MCInstLower.cpp:236)
==88969==    by 0x2333FE:
llvm::X86AsmPrinter::EmitInstruction(llvm::MachineInstr const*)
(X86MCInstLower.cpp:423)
==88969==    by 0x3FC558: llvm::AsmPrinter::EmitFunctionBody()
(AsmPrinter.cpp:427)
==88969==
==88969== 64 bytes in 4 blocks are definitely lost in loss record 143 of 158
==88969==    at 0x1911AD3: operator new(unsigned long) (vg_replace_malloc.c:220)
==88969==    by 0x4049AC: llvm::DIE::addSiblingOffset() (DIE.cpp:118)
==88969==    by 0x40FCB1:
llvm::DwarfDebug::computeSizeAndOffset(llvm::DIE*, unsigned int, bool)
(DwarfDebug.cpp:2310)
==88969==    by 0x40FE5C:
llvm::DwarfDebug::computeSizeAndOffset(llvm::DIE*, unsigned int, bool)
(DwarfDebug.cpp:2339)
==88969==    by 0x40FEE1: llvm::DwarfDebug::computeSizeAndOffsets()
(DwarfDebug.cpp:2359)
==88969==    by 0x40E530: llvm::DwarfDebug::endModule() (DwarfDebug.cpp:1912)
==88969==    by 0x42D15F: llvm::DwarfWriter::EndModule() (DwarfWriter.cpp:53)
==88969==    by 0x3FC7FA:
llvm::AsmPrinter::doFinalization(llvm::Module&) (AsmPrinter.cpp:467)
==88969==    by 0x72CA92:
llvm::FPPassManager::doFinalization(llvm::Module&)
(PassManager.cpp:1389)
==88969==    by 0x72C37C:
llvm::FunctionPassManagerImpl::doFinalization(llvm::Module&)
(PassManager.cpp:1266)
==88969==    by 0x72C2A9: llvm::FunctionPassManager::doFinalization()
(PassManager.cpp:1244)
==88969==    by 0x3063: main (llc.cpp:382)
==88969==
==88969== 72 bytes in 4 blocks are definitely lost in loss record 144 of 158
==88969==    at 0x1911AD3: operator new(unsigned long) (vg_replace_malloc.c:220)
==88969==    by 0x1B66A69: std::string::_Rep::_S_create(unsigned long,
unsigned long, std::allocator<char> const&) (in
/opt/local/lib/gcc44/libstdc++.6.dylib)
==88969==    by 0x1B67753: char* std::string::_S_construct<char
const*>(char const*, char const*, std::allocator<char> const&,
std::forward_iterator_tag) (in /opt/local/lib/gcc44/libstdc++.6.dylib)
==88969==    by 0x1B67985: std::basic_string<char,
std::char_traits<char>, std::allocator<char> >::basic_string(char
const*, unsigned long, std::allocator<char> const&) (in
/opt/local/lib/gcc44/libstdc++.6.dylib)
==88969==    by 0xE678D: llvm::StringRef::str() const (ADT/StringRef.h:148)
==88969==    by 0xE215E: llvm::StringRef::operator std::string() const
(ADT/StringRef.h:164)
==88969==    by 0x67844D: llvm::MCSymbol::MCSymbol(llvm::StringRef,
bool) (MCSymbol.h:60)
==88969==    by 0x678204:
llvm::MCContext::GetOrCreateSymbol(llvm::StringRef) (MCContext.cpp:39)
==88969==    by 0x22B8E9:
llvm::X86AsmPrinter::GetGlobalValueSymbol(llvm::GlobalValue const*)
const (X86AsmPrinter.cpp:59)
==88969==    by 0x3FCE30:
llvm::AsmPrinter::SetupMachineFunction(llvm::MachineFunction&)
(AsmPrinter.cpp:542)
==88969==    by 0x22B9E1:
llvm::X86AsmPrinter::runOnMachineFunction(llvm::MachineFunction&)
(X86AsmPrinter.cpp:79)
==88969==    by 0x48E5CE:
llvm::MachineFunctionPass::runOnFunction(llvm::Function&)
(MachineFunctionPass.cpp:27)
==88969==
==88969== LEAK SUMMARY:
==88969==    definitely lost: 222 bytes in 13 blocks
==88969==    indirectly lost: 0 bytes in 0 blocks
==88969==      possibly lost: 22 bytes in 1 blocks
==88969==    still reachable: 10,042 bytes in 150 blocks
==88969==         suppressed: 380 bytes in 9 blocks
==88969== Reachable blocks (those to which a pointer was found) are not shown.
==88969== To see them, rerun with: --leak-check=full --show-reachable=yes
==88969==
==88969== For counts of detected and suppressed errors, rerun with: -v
==88969== ERROR SUMMARY: 6 errors from 6 contexts (suppressed: 0 from 0)



More information about the llvm-commits mailing list