[llvm] 4c28844 - [ProfileData] Use default member initialization (NFC) (#94817)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 7 18:18:35 PDT 2024
Author: Kazu Hirata
Date: 2024-06-07T18:18:31-07:00
New Revision: 4c28844e3b1c0fd71c55e5954d21c6455d93068a
URL: https://github.com/llvm/llvm-project/commit/4c28844e3b1c0fd71c55e5954d21c6455d93068a
DIFF: https://github.com/llvm/llvm-project/commit/4c28844e3b1c0fd71c55e5954d21c6455d93068a.diff
LOG: [ProfileData] Use default member initialization (NFC) (#94817)
While we are at it, this patch changes the type of ValueCounts to
std:array<double, ...> so that we can use std::array:fill.
Identified with modernize-use-default-member-init.
Added:
Modified:
llvm/include/llvm/ProfileData/InstrProf.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/ProfileData/InstrProf.h b/llvm/include/llvm/ProfileData/InstrProf.h
index 15b9eb688e27e..61bf9492acb8e 100644
--- a/llvm/include/llvm/ProfileData/InstrProf.h
+++ b/llvm/include/llvm/ProfileData/InstrProf.h
@@ -737,15 +737,14 @@ GlobalVariable *InstrProfSymtab::getGlobalVariable(uint64_t MD5Hash) {
// To store the sums of profile count values, or the percentage of
// the sums of the total count values.
struct CountSumOrPercent {
- uint64_t NumEntries;
- double CountSum;
- double ValueCounts[IPVK_Last - IPVK_First + 1];
- CountSumOrPercent() : NumEntries(0), CountSum(0.0f), ValueCounts() {}
+ uint64_t NumEntries = 0;
+ double CountSum = 0.0f;
+ std::array<double, IPVK_Last - IPVK_First + 1> ValueCounts = {};
+ CountSumOrPercent() = default;
void reset() {
NumEntries = 0;
CountSum = 0.0f;
- for (double &VC : ValueCounts)
- VC = 0.0f;
+ ValueCounts.fill(0.0f);
}
};
@@ -761,15 +760,13 @@ struct OverlapStats {
CountSumOrPercent Mismatch;
CountSumOrPercent Unique;
OverlapStatsLevel Level;
- const std::string *BaseFilename;
- const std::string *TestFilename;
+ const std::string *BaseFilename = nullptr;
+ const std::string *TestFilename = nullptr;
StringRef FuncName;
- uint64_t FuncHash;
- bool Valid;
+ uint64_t FuncHash = 0;
+ bool Valid = false;
- OverlapStats(OverlapStatsLevel L = ProgramLevel)
- : Level(L), BaseFilename(nullptr), TestFilename(nullptr), FuncHash(0),
- Valid(false) {}
+ OverlapStats(OverlapStatsLevel L = ProgramLevel) : Level(L) {}
void dump(raw_fd_ostream &OS) const;
More information about the llvm-commits
mailing list