From 23f34f1c22db8df6e767a29365d668ac9ede112c Mon Sep 17 00:00:00 2001 From: Jakub Staszak Date: Fri, 22 Jul 2011 02:24:57 +0000 Subject: [PATCH] Allow getBlockFreq to return 0. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135742 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/BlockFrequency.h | 8 ++++---- include/llvm/Analysis/BlockFrequencyImpl.h | 7 +++---- include/llvm/CodeGen/MachineBlockFrequency.h | 8 ++++---- lib/Analysis/BlockFrequency.cpp | 8 ++++---- lib/CodeGen/MachineBlockFrequency.cpp | 8 ++++---- 5 files changed, 19 insertions(+), 20 deletions(-) diff --git a/include/llvm/Analysis/BlockFrequency.h b/include/llvm/Analysis/BlockFrequency.h index c4b1e087a0b..a7ec65ec55f 100644 --- a/include/llvm/Analysis/BlockFrequency.h +++ b/include/llvm/Analysis/BlockFrequency.h @@ -40,11 +40,11 @@ public: bool runOnFunction(Function &F); - /// getblockFreq - Return block frequency. Never return 0, value must be - /// positive. Please note that initial frequency is equal to 1024. It means + /// getblockFreq - Return block frequency. Return 0 if we don't have the + /// information. Please note that initial frequency is equal to 1024. It means /// that we should not rely on the value itself, but only on the comparison to - /// the other block frequencies. We do this to avoid using of the floating - /// points. + /// the other block frequencies. We do this to avoid using of floating points. + /// uint32_t getBlockFreq(BasicBlock *BB); }; diff --git a/include/llvm/Analysis/BlockFrequencyImpl.h b/include/llvm/Analysis/BlockFrequencyImpl.h index 6580fd1e4a9..5a22b519f15 100644 --- a/include/llvm/Analysis/BlockFrequencyImpl.h +++ b/include/llvm/Analysis/BlockFrequencyImpl.h @@ -314,13 +314,12 @@ class BlockFrequencyImpl { } public: - /// getBlockFreq - Return block frequency. Never return 0, value must be - /// positive. + /// getBlockFreq - Return block frequency. Return 0 if we don't have it. uint32_t getBlockFreq(BlockT *BB) const { typename DenseMap::const_iterator I = Freqs.find(BB); if (I != Freqs.end()) - return I->second ? I->second : 1; - return 1; + return I->second; + return 0; } void print(raw_ostream &OS) const { diff --git a/include/llvm/CodeGen/MachineBlockFrequency.h b/include/llvm/CodeGen/MachineBlockFrequency.h index 25bf1f08dc6..7b438677407 100644 --- a/include/llvm/CodeGen/MachineBlockFrequency.h +++ b/include/llvm/CodeGen/MachineBlockFrequency.h @@ -40,11 +40,11 @@ public: bool runOnMachineFunction(MachineFunction &F); - /// getblockFreq - Return block frequency. Never return 0, value must be - /// positive. Please note that initial frequency is equal to 1024. It means + /// getblockFreq - Return block frequency. Return 0 if we don't have the + /// information. Please note that initial frequency is equal to 1024. It means /// that we should not rely on the value itself, but only on the comparison to - /// the other block frequencies. We do this to avoid using of the floating - /// points. + /// the other block frequencies. We do this to avoid using of floating points. + /// uint32_t getBlockFreq(MachineBasicBlock *MBB); }; diff --git a/lib/Analysis/BlockFrequency.cpp b/lib/Analysis/BlockFrequency.cpp index 4b86d1db1f0..49b69d11975 100644 --- a/lib/Analysis/BlockFrequency.cpp +++ b/lib/Analysis/BlockFrequency.cpp @@ -49,10 +49,10 @@ bool BlockFrequency::runOnFunction(Function &F) { return false; } -/// getblockFreq - Return block frequency. Never return 0, value must be -/// positive. Please note that initial frequency is equal to 1024. It means that -/// we should not rely on the value itself, but only on the comparison to the -/// other block frequencies. We do this to avoid using of floating points. +/// getblockFreq - Return block frequency. Return 0 if we don't have the +/// information. Please note that initial frequency is equal to 1024. It means +/// that we should not rely on the value itself, but only on the comparison to +/// the other block frequencies. We do this to avoid using of floating points. /// uint32_t BlockFrequency::getBlockFreq(BasicBlock *BB) { return BFI->getBlockFreq(BB); diff --git a/lib/CodeGen/MachineBlockFrequency.cpp b/lib/CodeGen/MachineBlockFrequency.cpp index 0a77bdd38a2..f3ee5388e59 100644 --- a/lib/CodeGen/MachineBlockFrequency.cpp +++ b/lib/CodeGen/MachineBlockFrequency.cpp @@ -50,10 +50,10 @@ bool MachineBlockFrequency::runOnMachineFunction(MachineFunction &F) { return false; } -/// getblockFreq - Return block frequency. Never return 0, value must be -/// positive. Please note that initial frequency is equal to 1024. It means that -/// we should not rely on the value itself, but only on the comparison to the -/// other block frequencies. We do this to avoid using of floating points. +/// getblockFreq - Return block frequency. Return 0 if we don't have the +/// information. Please note that initial frequency is equal to 1024. It means +/// that we should not rely on the value itself, but only on the comparison to +/// the other block frequencies. We do this to avoid using of floating points. /// uint32_t MachineBlockFrequency::getBlockFreq(MachineBasicBlock *MBB) { return MBFI->getBlockFreq(MBB); -- 2.34.1