The compact encoding of the registers are 3-bits each. Make sure we shift the
authorBill Wendling <isanbard@gmail.com>
Tue, 6 Dec 2011 01:26:14 +0000 (01:26 +0000)
committerBill Wendling <isanbard@gmail.com>
Tue, 6 Dec 2011 01:26:14 +0000 (01:26 +0000)
value over that much.

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

lib/Target/X86/X86FrameLowering.cpp

index 27b762af69f07006e0da256ac7780a3e025245fc..038ca7f34d03293aba23e09e6788f8fafb40a59b 100644 (file)
@@ -385,12 +385,14 @@ static uint32_t encodeCompactUnwindRegistersWithoutFrame(unsigned SavedRegs[6],
   };
   const unsigned *CURegs = (Is64Bit ? CU64BitRegs : CU32BitRegs);
 
-  uint32_t RenumRegs[6];
   for (unsigned i = 6 - RegCount; i < 6; ++i) {
     int CUReg = getCompactUnwindRegNum(CURegs, SavedRegs[i]);
     if (CUReg == -1) return ~0U;
     SavedRegs[i] = CUReg;
+  }
 
+  uint32_t RenumRegs[6];
+  for (unsigned i = 6 - RegCount; i < 6; ++i) {
     unsigned Countless = 0;
     for (unsigned j = 6 - RegCount; j < i; ++j)
       if (SavedRegs[j] < SavedRegs[i])
@@ -454,7 +456,7 @@ static uint32_t encodeCompactUnwindRegistersWithFrame(unsigned SavedRegs[6],
     int CURegNum = getCompactUnwindRegNum(CURegs, Reg);
     if (CURegNum == -1)
       return ~0U;
-    RegEnc |= (CURegNum & 0x7) << (5 - I);
+    RegEnc |= (CURegNum & 0x7) << ((5 - I) * 3);
   }
 
   assert((RegEnc & 0x7FFF) == RegEnc && "Invalid compact register encoding!");