GBE: fix the overflow bug in register spilling.
authorZhigang Gong <zhigang.gong@intel.com>
Wed, 19 Feb 2014 08:36:33 +0000 (16:36 +0800)
committerZhigang Gong <zhigang.gong@intel.com>
Mon, 24 Feb 2014 06:55:02 +0000 (14:55 +0800)
Change to use int32 to represent the maxID.

Signed-off-by: Zhigang Gong <zhigang.gong@intel.com>
Reviewed-by: "Song, Ruiling" <ruiling.song@intel.com>
backend/src/backend/gen_reg_allocation.cpp

index 726b78c..8243f19 100644 (file)
@@ -53,19 +53,16 @@ namespace gbe
   };
 
   typedef struct GenRegIntervalKey {
-    GenRegIntervalKey(uint16_t reg, uint16_t maxID) {
-      if (maxID == INT_MAX)
-        maxID = 0xFFFF;
-      GBE_ASSERT(reg <= 0xFFFF && maxID <= 0xFFFF);
-      key = (maxID << 16) | reg;
+    GenRegIntervalKey(uint16_t reg, int32_t maxID) {
+      key = ((uint64_t)maxID << 16) | reg;
     }
     const ir::Register getReg() const {
       return (ir::Register)(key & 0xFFFF);
     }
-    const uint16_t getMaxID() const {
+    const int32_t getMaxID() const {
       return key >> 16;
     }
-    uint32_t key;
+    uint64_t key;
   } GenRegIntervalKey;
 
   struct spillCmp {