[llvm] r206856 - blockfreq: Implement clear() explicitly
Duncan P. N. Exon Smith
dexonsmith at apple.com
Mon Apr 21 20:31:34 PDT 2014
Author: dexonsmith
Date: Mon Apr 21 22:31:34 2014
New Revision: 206856
URL: http://llvm.org/viewvc/llvm-project?rev=206856&view=rev
Log:
blockfreq: Implement clear() explicitly
This was implicitly with copy assignment before, which fails to actually
clear `std::vector<>`'s heap storage. Move assignment would work, but
since MSVC can't imply those anyway, explicitly `clear()`-ing members
makes more sense.
Modified:
llvm/trunk/lib/Analysis/BlockFrequencyInfoImpl.cpp
Modified: llvm/trunk/lib/Analysis/BlockFrequencyInfoImpl.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BlockFrequencyInfoImpl.cpp?rev=206856&r1=206855&r2=206856&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/BlockFrequencyInfoImpl.cpp (original)
+++ llvm/trunk/lib/Analysis/BlockFrequencyInfoImpl.cpp Mon Apr 21 22:31:34 2014
@@ -598,7 +598,11 @@ void Distribution::normalize() {
}
void BlockFrequencyInfoImplBase::clear() {
- *this = BlockFrequencyInfoImplBase();
+ // Swap with a default-constructed std::vector, since std::vector<>::clear()
+ // does not actually clear heap storage.
+ std::vector<FrequencyData>().swap(Freqs);
+ std::vector<WorkingData>().swap(Working);
+ std::vector<LoopData>().swap(PackagedLoops);
}
/// \brief Clear all memory not needed downstream.
More information about the llvm-commits
mailing list