Allow getBlockFreq to return 0.
authorJakub Staszak <jstaszak@apple.com>
Fri, 22 Jul 2011 02:24:57 +0000 (02:24 +0000)
committerJakub Staszak <jstaszak@apple.com>
Fri, 22 Jul 2011 02:24:57 +0000 (02:24 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135742 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Analysis/BlockFrequency.h
include/llvm/Analysis/BlockFrequencyImpl.h
include/llvm/CodeGen/MachineBlockFrequency.h
lib/Analysis/BlockFrequency.cpp
lib/CodeGen/MachineBlockFrequency.cpp

index c4b1e087a0b16c5508e59caac8e109d3a6a8e0be..a7ec65ec55f1b4e9c0666f3dc648fb8692733a4a 100644 (file)
@@ -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);
 };
 
index 6580fd1e4a9c6ea3467daa7aa2a2605d51d0e974..5a22b519f15cd2cc38b60f37f93ab27963226edb 100644 (file)
@@ -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<BlockT *, uint32_t>::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 {
index 25bf1f08dc6406d36d68b324790e81117810599f..7b4386774076a649c120b0a1cf9d437e30f8d61b 100644 (file)
@@ -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);
 };
 
index 4b86d1db1f04d49a5e4b4e417d506f7e302b7e0a..49b69d1197536823fa18119948324c266f1364c6 100644 (file)
@@ -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);
index 0a77bdd38a20c97edbfcb3d1915f1761d4363479..f3ee5388e59acc8c2a64e6820202ce520c77d229 100644 (file)
@@ -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);