From d4c646110a2d04ce958d373da18507d39aa13564 Mon Sep 17 00:00:00 2001 From: Cong Hou Date: Mon, 12 Oct 2015 18:14:15 +0000 Subject: [PATCH] Turn const/const& into value type for BlockFrequency in functions of this class. Also fix a naming issue. NFC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250074 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/BlockFrequency.h | 14 +++++++------- lib/Support/BlockFrequency.cpp | 14 ++++++-------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/include/llvm/Support/BlockFrequency.h b/include/llvm/Support/BlockFrequency.h index 25f1485a747..2dccfa26d89 100644 --- a/include/llvm/Support/BlockFrequency.h +++ b/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/lib/Support/BlockFrequency.cpp b/lib/Support/BlockFrequency.cpp index dbd790cec3a..e0430c199eb 100644 --- a/lib/Support/BlockFrequency.cpp +++ b/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) { -- 2.34.1