diff options
author | Justin Bogner <mail@justinbogner.com> | 2014-04-23 18:50:16 +0000 |
---|---|---|
committer | Justin Bogner <mail@justinbogner.com> | 2014-04-23 18:50:16 +0000 |
commit | 08a4d0b36fd21d98364c6a8ca6bff98a22af43ab (patch) | |
tree | 33cca859c3d45abe45d67f75b7d107e8f3c99338 /lib/ProfileData | |
parent | 94a9772abc771682d38e32bb18703de53a7fd5d9 (diff) | |
download | llvm-08a4d0b36fd21d98364c6a8ca6bff98a22af43ab.tar.gz llvm-08a4d0b36fd21d98364c6a8ca6bff98a22af43ab.tar.bz2 llvm-08a4d0b36fd21d98364c6a8ca6bff98a22af43ab.tar.xz |
ProfileData: Avoid unnecessary copies of CounterData
We're currently copying CounterData from InstrProfWriter into the
OnDiskHashTable, even though we don't need to, and then carelessly
leaking those copies. A const pointer is much better here.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207009 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ProfileData')
-rw-r--r-- | lib/ProfileData/InstrProfWriter.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/ProfileData/InstrProfWriter.cpp b/lib/ProfileData/InstrProfWriter.cpp index 83d03d6a28..83c41d93bb 100644 --- a/lib/ProfileData/InstrProfWriter.cpp +++ b/lib/ProfileData/InstrProfWriter.cpp @@ -27,8 +27,8 @@ public: typedef StringRef key_type; typedef StringRef key_type_ref; - typedef InstrProfWriter::CounterData data_type; - typedef const InstrProfWriter::CounterData &data_type_ref; + typedef const InstrProfWriter::CounterData *const data_type; + typedef const InstrProfWriter::CounterData *const data_type_ref; typedef uint64_t hash_value_type; typedef uint64_t offset_type; @@ -45,7 +45,7 @@ public: offset_type N = K.size(); LE.write<offset_type>(N); - offset_type M = (1 + V.Counts.size()) * sizeof(uint64_t); + offset_type M = (1 + V->Counts.size()) * sizeof(uint64_t); LE.write<offset_type>(M); return std::make_pair(N, M); @@ -59,8 +59,8 @@ public: offset_type) { using namespace llvm::support; endian::Writer<little> LE(Out); - LE.write<uint64_t>(V.Hash); - for (uint64_t I : V.Counts) + LE.write<uint64_t>(V->Hash); + for (uint64_t I : V->Counts) LE.write<uint64_t>(I); } }; @@ -100,7 +100,7 @@ void InstrProfWriter::write(raw_fd_ostream &OS) { // Populate the hash table generator. for (const auto &I : FunctionData) { - Generator.insert(I.getKey(), I.getValue()); + Generator.insert(I.getKey(), &I.getValue()); if (I.getValue().Counts[0] > MaxFunctionCount) MaxFunctionCount = I.getValue().Counts[0]; } |