From: Fedor Sergeev Date: Thu, 4 Oct 2018 12:49:57 +0000 (+0000) Subject: [PassTimingInfo] cleanup on TimingData's Timer handling X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=eb20c30743af2c034ec80f8c136b869e9db109ae;p=platform%2Fupstream%2Fllvm.git [PassTimingInfo] cleanup on TimingData's Timer handling Replacing Timer* with unique_ptr in a pass-to-timer map. That allows to get rid of unpretty raw deletes in PassTimingInfo destructor. Strictly cleanup, not intended to change any visible behavior. llvm-svn: 343772 --- diff --git a/llvm/lib/IR/PassTimingInfo.cpp b/llvm/lib/IR/PassTimingInfo.cpp index 9e63025..895cbc1 100644 --- a/llvm/lib/IR/PassTimingInfo.cpp +++ b/llvm/lib/IR/PassTimingInfo.cpp @@ -28,6 +28,7 @@ #include "llvm/Support/Mutex.h" #include "llvm/Support/Timer.h" #include "llvm/Support/raw_ostream.h" +#include #include using namespace llvm; @@ -56,7 +57,7 @@ public: private: StringMap PassIDCountMap; ///< Map that counts instances of passes - DenseMap TimingData; ///< timers for pass instances + DenseMap> TimingData; ///< timers for pass instances TimerGroup TG; public: @@ -93,8 +94,7 @@ PassTimingInfo::PassTimingInfo() PassTimingInfo::~PassTimingInfo() { // Deleting the timers accumulates their info into the TG member. // Then TG member is (implicitly) deleted, actually printing the report. - for (auto &I : TimingData) - delete I.getSecond(); + TimingData.clear(); } void PassTimingInfo::init() { @@ -126,16 +126,16 @@ Timer *PassTimingInfo::getPassTimer(Pass *P, PassInstanceID Pass) { init(); sys::SmartScopedLock Lock(*TimingInfoMutex); - Timer *&T = TimingData[Pass]; + std::unique_ptr &T = TimingData[Pass]; if (!T) { StringRef PassName = P->getPassName(); StringRef PassArgument; if (const PassInfo *PI = Pass::lookupPassInfo(P->getPassID())) PassArgument = PI->getPassArgument(); - T = newPassTimer(PassArgument.empty() ? PassName : PassArgument, PassName); + T.reset(newPassTimer(PassArgument.empty() ? PassName : PassArgument, PassName)); } - return T; + return T.get(); } PassTimingInfo *PassTimingInfo::TheTimeInfo;