diff --git a/llvm/include/llvm/Support/BlockFrequency.h b/llvm/include/llvm/Support/BlockFrequency.h index 25f1485a7471..2dccfa26d892 100644 --- a/llvm/include/llvm/Support/BlockFrequency.h +++ b/llvm/include/llvm/Support/BlockFrequency.h @@ -38,7 +38,7 @@ public: /// \brief Multiplies with a branch probability. The computation will never /// overflow. BlockFrequency &operator*=(BranchProbability Prob); - const BlockFrequency operator*(BranchProbability Prob) const; + BlockFrequency operator*(BranchProbability Prob) const; /// \brief Divide by a non-zero branch probability using saturating /// arithmetic. @@ -46,25 +46,25 @@ public: BlockFrequency operator/(BranchProbability Prob) const; /// \brief Adds another block frequency using saturating arithmetic. - BlockFrequency &operator+=(const BlockFrequency &Freq); - const BlockFrequency operator+(const BlockFrequency &Freq) const; + BlockFrequency &operator+=(BlockFrequency Freq); + BlockFrequency operator+(BlockFrequency Freq) const; /// \brief Shift block frequency to the right by count digits saturating to 1. BlockFrequency &operator>>=(const unsigned count); - bool operator<(const BlockFrequency &RHS) const { + bool operator<(BlockFrequency RHS) const { return Frequency < RHS.Frequency; } - bool operator<=(const BlockFrequency &RHS) const { + bool operator<=(BlockFrequency RHS) const { return Frequency <= RHS.Frequency; } - bool operator>(const BlockFrequency &RHS) const { + bool operator>(BlockFrequency RHS) const { return Frequency > RHS.Frequency; } - bool operator>=(const BlockFrequency &RHS) const { + bool operator>=(BlockFrequency RHS) const { return Frequency >= RHS.Frequency; } }; diff --git a/llvm/lib/Support/BlockFrequency.cpp b/llvm/lib/Support/BlockFrequency.cpp index dbd790cec3a8..e0430c199eb8 100644 --- a/llvm/lib/Support/BlockFrequency.cpp +++ b/llvm/lib/Support/BlockFrequency.cpp @@ -22,8 +22,7 @@ BlockFrequency &BlockFrequency::operator*=(BranchProbability Prob) { return *this; } -const BlockFrequency -BlockFrequency::operator*(BranchProbability Prob) const { +BlockFrequency BlockFrequency::operator*(BranchProbability Prob) const { BlockFrequency Freq(Frequency); Freq *= Prob; return Freq; @@ -40,7 +39,7 @@ BlockFrequency BlockFrequency::operator/(BranchProbability Prob) const { return Freq; } -BlockFrequency &BlockFrequency::operator+=(const BlockFrequency &Freq) { +BlockFrequency &BlockFrequency::operator+=(BlockFrequency Freq) { uint64_t Before = Freq.Frequency; Frequency += Freq.Frequency; @@ -51,11 +50,10 @@ BlockFrequency &BlockFrequency::operator+=(const BlockFrequency &Freq) { return *this; } -const BlockFrequency -BlockFrequency::operator+(const BlockFrequency &Prob) const { - BlockFrequency Freq(Frequency); - Freq += Prob; - return Freq; +BlockFrequency BlockFrequency::operator+(BlockFrequency Freq) const { + BlockFrequency NewFreq(Frequency); + NewFreq += Freq; + return NewFreq; } BlockFrequency &BlockFrequency::operator>>=(const unsigned count) {