Replacing HUGE_VALF with llvm::huge_valf in order to work around a warning triggered...
authorAaron Ballman <aaron@aaronballman.com>
Wed, 13 Nov 2013 00:15:44 +0000 (00:15 +0000)
committerAaron Ballman <aaron@aaronballman.com>
Wed, 13 Nov 2013 00:15:44 +0000 (00:15 +0000)
Patch reviewed by Reid Kleckner and Jim Grosbach.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194533 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/LiveInterval.h
include/llvm/Support/MathExtras.h
lib/CodeGen/LiveIntervalAnalysis.cpp
lib/CodeGen/RegAllocGreedy.cpp
lib/CodeGen/Spiller.cpp

index 1b30bf5937e331063027dfb8e7c3325d35b79dcc..3a9fef6fbd78176b9aac3a4d868590fad2e364a5 100644 (file)
@@ -541,12 +541,12 @@ namespace llvm {
 
     /// isSpillable - Can this interval be spilled?
     bool isSpillable() const {
 
     /// isSpillable - Can this interval be spilled?
     bool isSpillable() const {
-      return weight != HUGE_VALF;
+      return weight != llvm::huge_valf;
     }
 
     /// markNotSpillable - Mark interval as not spillable
     void markNotSpillable() {
     }
 
     /// markNotSpillable - Mark interval as not spillable
     void markNotSpillable() {
-      weight = HUGE_VALF;
+      weight = llvm::huge_valf;
     }
 
     bool operator<(const LiveInterval& other) const {
     }
 
     bool operator<(const LiveInterval& other) const {
index 00c6ad70d4350fb87c5e64975f85b04b70e88863..17cf4751a01f43f472ddafd73178074fa9092484 100644 (file)
@@ -21,7 +21,8 @@
 #include <cstring>
 
 #ifdef _MSC_VER
 #include <cstring>
 
 #ifdef _MSC_VER
-# include <intrin.h>
+#include <intrin.h>
+#include <limits>
 #endif
 
 namespace llvm {
 #endif
 
 namespace llvm {
@@ -603,6 +604,17 @@ inline int64_t SignExtend64(uint64_t X, unsigned B) {
   return int64_t(X << (64 - B)) >> (64 - B);
 }
 
   return int64_t(X << (64 - B)) >> (64 - B);
 }
 
+#if defined(_MSC_VER)
+  // Visual Studio defines the HUGE_VAL class of macros using purposeful
+  // constant arithmetic overflow, which it then warns on when encountered.
+  const float huge_valf = std::numeric_limits<float>::infinity();
+  const double huge_vald = std::numeric_limits<double>::infinity();
+  const long double huge_vall = std::numeric_limits<long double>::infinity();
+#else
+  const float huge_valf = HUGE_VALF;
+  const double huge_vald = HUGE_VALD;
+  const long double huge_vall = HUGE_VALL;
+#endif
 } // End llvm namespace
 
 #endif
 } // End llvm namespace
 
 #endif
index 7a3b30511620665c3b8f80fc13af9bb55eb7e92a..e1c3217a775e5e974e94bf0d565fcab53f1a5a14 100644 (file)
@@ -170,7 +170,8 @@ void LiveIntervals::dumpInstrs() const {
 #endif
 
 LiveInterval* LiveIntervals::createInterval(unsigned reg) {
 #endif
 
 LiveInterval* LiveIntervals::createInterval(unsigned reg) {
-  float Weight = TargetRegisterInfo::isPhysicalRegister(reg) ? HUGE_VALF : 0.0F;
+  float Weight = TargetRegisterInfo::isPhysicalRegister(reg) ?
+                  llvm::huge_valf : 0.0F;
   return new LiveInterval(reg, Weight);
 }
 
   return new LiveInterval(reg, Weight);
 }
 
index 95b30a4823be55e96ce16fbc56f2465530d140c1..c08d955540602dd5c723d26db07fdf247d5f5fe1 100644 (file)
@@ -1477,7 +1477,7 @@ void RAGreedy::calcGapWeights(unsigned PhysReg,
         break;
 
       for (; Gap != NumGaps; ++Gap) {
         break;
 
       for (; Gap != NumGaps; ++Gap) {
-        GapWeight[Gap] = HUGE_VALF;
+        GapWeight[Gap] = llvm::huge_valf;
         if (Uses[Gap+1].getBaseIndex() >= I->end)
           break;
       }
         if (Uses[Gap+1].getBaseIndex() >= I->end)
           break;
       }
@@ -1583,7 +1583,7 @@ unsigned RAGreedy::tryLocalSplit(LiveInterval &VirtReg, AllocationOrder &Order,
     // Remove any gaps with regmask clobbers.
     if (Matrix->checkRegMaskInterference(VirtReg, PhysReg))
       for (unsigned i = 0, e = RegMaskGaps.size(); i != e; ++i)
     // Remove any gaps with regmask clobbers.
     if (Matrix->checkRegMaskInterference(VirtReg, PhysReg))
       for (unsigned i = 0, e = RegMaskGaps.size(); i != e; ++i)
-        GapWeight[RegMaskGaps[i]] = HUGE_VALF;
+        GapWeight[RegMaskGaps[i]] = llvm::huge_valf;
 
     // Try to find the best sequence of gaps to close.
     // The new spill weight must be larger than any gap interference.
 
     // Try to find the best sequence of gaps to close.
     // The new spill weight must be larger than any gap interference.
@@ -1618,7 +1618,7 @@ unsigned RAGreedy::tryLocalSplit(LiveInterval &VirtReg, AllocationOrder &Order,
       // Legally, without causing looping?
       bool Legal = !ProgressRequired || NewGaps < NumGaps;
 
       // Legally, without causing looping?
       bool Legal = !ProgressRequired || NewGaps < NumGaps;
 
-      if (Legal && MaxGap < HUGE_VALF) {
+      if (Legal && MaxGap < llvm::huge_valf) {
         // Estimate the new spill weight. Each instruction reads or writes the
         // register. Conservatively assume there are no read-modify-write
         // instructions.
         // Estimate the new spill weight. Each instruction reads or writes the
         // register. Conservatively assume there are no read-modify-write
         // instructions.
index d72c596a8426bae2e7a707186b393bdb75ba0266..d5b3a4a940074cfbd4840885aa1b6fb6cfe64b5a 100644 (file)
@@ -77,7 +77,7 @@ protected:
 
     DEBUG(dbgs() << "Spilling everywhere " << *li << "\n");
 
 
     DEBUG(dbgs() << "Spilling everywhere " << *li << "\n");
 
-    assert(li->weight != HUGE_VALF &&
+    assert(li->weight != llvm::huge_valf &&
            "Attempting to spill already spilled value.");
 
     assert(!TargetRegisterInfo::isStackSlot(li->reg) &&
            "Attempting to spill already spilled value.");
 
     assert(!TargetRegisterInfo::isStackSlot(li->reg) &&