[llvm-commits] [PATCH] PostDominators: avoid memory leak

Bill Wendling isanbard at gmail.com
Sat May 3 13:21:50 PDT 2008


On May 3, 2008, at 8:56 AM, Török Edwin wrote:

> Hi,
>
> The DT  member of PostDominatorTree is never freed, and valgrind  
> reports
> a leak.
> No other optimization passess leak, and I like to see as few errors as
> possible from valgrind, hence this patch.
> It is only a matter of adding a simple destructor.
>
> Can I commit?
>
Looks good to me. Please commit.

-bw

> ==17137== 7,040 (152 direct, 6,888 indirect) bytes in 1 blocks are
> definitely lost in loss record 29 of 34
> ==17137==    at 0x4A07809: operator new(unsigned long)
> (vg_replace_malloc.c:230)
> ==17137==    by 0x9497DE: llvm::PostDominatorTree::PostDominatorTree()
> (PostDominators.h:29)
> ==17137==    by 0x94981B: llvm::Pass*
> llvm::callDefaultCtor<llvm::PostDominatorTree>() (PassSupport.h:165)
> ==17137==    by 0xA0BBD9: llvm::PassInfo::createPass() const
> (PassSupport.h:101)
> ==17137==    by 0xA069BD:
> llvm::PMTopLevelManager::schedulePass(llvm::Pass*) (PassManager.cpp: 
> 444)
> ==17137==    by 0xA115A5: llvm::PassManagerImpl::add(llvm::Pass*)
> (PassManager.cpp:274)
> ==17137==    by 0xA06A9E: llvm::PassManager::add(llvm::Pass*)
> (PassManager.cpp:1347)
> ==17137==    by 0x7224C6: (anonymous
> namespace)::addPass(llvm::PassManager&, llvm::Pass*) (opt.cpp:236)
> ==17137==    by 0x722818: (anonymous
> namespace)::AddStandardCompilePasses(llvm::PassManager&) (opt.cpp:299)
> ==17137==    by 0x7234B6: main (opt.cpp:387)
>
> --Edwin
> Index: include/llvm/Analysis/PostDominators.h
> ===================================================================
> --- include/llvm/Analysis/PostDominators.h	(revision 50604)
> +++ include/llvm/Analysis/PostDominators.h	(working copy)
> @@ -29,6 +29,8 @@
>     DT = new DominatorTreeBase<BasicBlock>(true);
>   }
>
> +  ~PostDominatorTree();
> +
>   virtual bool runOnFunction(Function &F);
>
>   virtual void getAnalysisUsage(AnalysisUsage &AU) const {
> Index: lib/Analysis/PostDominators.cpp
> ===================================================================
> --- lib/Analysis/PostDominators.cpp	(revision 50604)
> +++ lib/Analysis/PostDominators.cpp	(working copy)
> @@ -37,6 +37,11 @@
>   return false;
> }
>
> +PostDominatorTree::~PostDominatorTree()
> +{
> +  delete DT;
> +}
> +
> // 
> = 
> = 
> = 
> ----------------------------------------------------------------------= 
> ==//
> //  PostDominanceFrontier Implementation
> // 
> = 
> = 
> = 
> ----------------------------------------------------------------------= 
> ==//
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits





More information about the llvm-commits mailing list