[PATCH] D33220: [PartialInlining] Replace delete with unique_ptr in computeCallsiteToProfCountMap

Vitaly Buka via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 26 22:32:24 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL304064: [PartialInlining] Replace delete with unique_ptr in… (authored by vitalybuka).

Changed prior to commit:
  https://reviews.llvm.org/D33220?vs=99079&id=100526#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33220

Files:
  llvm/trunk/lib/Transforms/IPO/PartialInlining.cpp


Index: llvm/trunk/lib/Transforms/IPO/PartialInlining.cpp
===================================================================
--- llvm/trunk/lib/Transforms/IPO/PartialInlining.cpp
+++ llvm/trunk/lib/Transforms/IPO/PartialInlining.cpp
@@ -558,17 +558,17 @@
   std::vector<User *> Users(DuplicateFunction->user_begin(),
                             DuplicateFunction->user_end());
   Function *CurrentCaller = nullptr;
+  std::unique_ptr<BlockFrequencyInfo> TempBFI;
   BlockFrequencyInfo *CurrentCallerBFI = nullptr;
 
   auto ComputeCurrBFI = [&,this](Function *Caller) {
       // For the old pass manager:
       if (!GetBFI) {
-        if (CurrentCallerBFI)
-          delete CurrentCallerBFI;
         DominatorTree DT(*Caller);
         LoopInfo LI(DT);
         BranchProbabilityInfo BPI(*Caller, LI);
-        CurrentCallerBFI = new BlockFrequencyInfo(*Caller, BPI, LI);
+        TempBFI.reset(new BlockFrequencyInfo(*Caller, BPI, LI));
+        CurrentCallerBFI = TempBFI.get();
       } else {
         // New pass manager:
         CurrentCallerBFI = &(*GetBFI)(*Caller);
@@ -591,10 +591,6 @@
     else
       CallSiteToProfCountMap[User] = 0;
   }
-  if (!GetBFI) {
-    if (CurrentCallerBFI)
-      delete CurrentCallerBFI;
-  }
 }
 
 Function *PartialInlinerImpl::unswitchFunction(Function *F) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33220.100526.patch
Type: text/x-patch
Size: 1308 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170527/63788f8e/attachment.bin>


More information about the llvm-commits mailing list