[llvm-commits] [llvm] r162518 - /llvm/trunk/lib/Analysis/ProfileEstimatorPass.cpp

Richard Smith richard-llvm at metafoo.co.uk
Thu Aug 23 17:31:45 PDT 2012


Author: rsmith
Date: Thu Aug 23 19:31:45 2012
New Revision: 162518

URL: http://llvm.org/viewvc/llvm-project?rev=162518&view=rev
Log:
Fix floating-point divide by zero, in a case where the value was not going to be used anyway.

Modified:
    llvm/trunk/lib/Analysis/ProfileEstimatorPass.cpp

Modified: llvm/trunk/lib/Analysis/ProfileEstimatorPass.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ProfileEstimatorPass.cpp?rev=162518&r1=162517&r2=162518&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ProfileEstimatorPass.cpp (original)
+++ llvm/trunk/lib/Analysis/ProfileEstimatorPass.cpp Thu Aug 23 19:31:45 2012
@@ -286,7 +286,7 @@
     }
   }
 
-  double fraction = floor(BBWeight/Edges.size());
+  double fraction = Edges.size() ? floor(BBWeight/Edges.size()) : 0.0;
   // Finally we know what flow is still not leaving the block, distribute this
   // flow onto the empty edges.
   for (SmallVector<Edge, 8>::iterator ei = Edges.begin(), ee = Edges.end();





More information about the llvm-commits mailing list