Converting SpillPlacement's BlockFrequency threshold to a ManagedStatic to avoid...
authorChris Bieneman <beanz@apple.com>
Fri, 19 Sep 2014 22:46:28 +0000 (22:46 +0000)
committerChris Bieneman <beanz@apple.com>
Fri, 19 Sep 2014 22:46:28 +0000 (22:46 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218163 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SpillPlacement.cpp

index 24e94d11f88881b78b3c8211ef95a8c2b59d89d1..daaecf1f1b2d75c71fb5f27010c573f7f4ddfd68 100644 (file)
@@ -37,6 +37,7 @@
 #include "llvm/CodeGen/Passes.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/Format.h"
+#include "llvm/Support/ManagedStatic.h"
 
 using namespace llvm;
 
@@ -61,12 +62,12 @@ void SpillPlacement::getAnalysisUsage(AnalysisUsage &AU) const {
 }
 
 namespace {
-static BlockFrequency Threshold;
+static ManagedStatic<BlockFrequency> Threshold;
 }
 
 /// Decision threshold. A node gets the output value 0 if the weighted sum of
 /// its inputs falls in the open interval (-Threshold;Threshold).
-static BlockFrequency getThreshold() { return Threshold; }
+static BlockFrequency getThreshold() { return *Threshold; }
 
 /// \brief Set the threshold for a given entry frequency.
 ///
@@ -78,7 +79,7 @@ static void setThreshold(const BlockFrequency &Entry) {
   // it.  Divide by 2^13, rounding as appropriate.
   uint64_t Freq = Entry.getFrequency();
   uint64_t Scaled = (Freq >> 13) + bool(Freq & (1 << 12));
-  Threshold = std::max(UINT64_C(1), Scaled);
+  *Threshold = std::max(UINT64_C(1), Scaled);
 }
 
 /// Node - Each edge bundle corresponds to a Hopfield node.