| Index: lib/Target/X86/X86FrameLowering.cpp
|
| diff --git a/lib/Target/X86/X86FrameLowering.cpp b/lib/Target/X86/X86FrameLowering.cpp
|
| index 89485cb06c309a6608ec601f15f0c1ba72b10b7b..fd0f6532485468a429cce599fa8b4a7ed3d63af6 100644
|
| --- a/lib/Target/X86/X86FrameLowering.cpp
|
| +++ b/lib/Target/X86/X86FrameLowering.cpp
|
| @@ -372,14 +372,7 @@ void X86FrameLowering::emitCalleeSavedFrameMoves(MachineFunction &MF,
|
| /// getCompactUnwindRegNum - Get the compact unwind number for a given
|
| /// register. The number corresponds to the enum lists in
|
| /// compact_unwind_encoding.h.
|
| -static int getCompactUnwindRegNum(unsigned Reg, bool is64Bit) {
|
| - static const uint16_t CU32BitRegs[] = {
|
| - X86::EBX, X86::ECX, X86::EDX, X86::EDI, X86::ESI, X86::EBP, 0
|
| - };
|
| - static const uint16_t CU64BitRegs[] = {
|
| - X86::RBX, X86::R12, X86::R13, X86::R14, X86::R15, X86::RBP, 0
|
| - };
|
| - const uint16_t *CURegs = is64Bit ? CU64BitRegs : CU32BitRegs;
|
| +static int getCompactUnwindRegNum(const uint16_t *CURegs, unsigned Reg) {
|
| for (int Idx = 1; *CURegs; ++CURegs, ++Idx)
|
| if (*CURegs == Reg)
|
| return Idx;
|
| @@ -408,8 +401,16 @@ encodeCompactUnwindRegistersWithoutFrame(unsigned SavedRegs[CU_NUM_SAVED_REGS],
|
| // 4 3
|
| // 5 3
|
| //
|
| + static const uint16_t CU32BitRegs[] = {
|
| + X86::EBX, X86::ECX, X86::EDX, X86::EDI, X86::ESI, X86::EBP, 0
|
| + };
|
| + static const uint16_t CU64BitRegs[] = {
|
| + X86::RBX, X86::R12, X86::R13, X86::R14, X86::R15, X86::RBP, 0
|
| + };
|
| + const uint16_t *CURegs = (Is64Bit ? CU64BitRegs : CU32BitRegs);
|
| +
|
| for (unsigned i = 0; i != CU_NUM_SAVED_REGS; ++i) {
|
| - int CUReg = getCompactUnwindRegNum(SavedRegs[i], Is64Bit);
|
| + int CUReg = getCompactUnwindRegNum(CURegs, SavedRegs[i]);
|
| if (CUReg == -1) return ~0U;
|
| SavedRegs[i] = CUReg;
|
| }
|
| @@ -468,6 +469,14 @@ encodeCompactUnwindRegistersWithoutFrame(unsigned SavedRegs[CU_NUM_SAVED_REGS],
|
| static uint32_t
|
| encodeCompactUnwindRegistersWithFrame(unsigned SavedRegs[CU_NUM_SAVED_REGS],
|
| bool Is64Bit) {
|
| + static const uint16_t CU32BitRegs[] = {
|
| + X86::EBX, X86::ECX, X86::EDX, X86::EDI, X86::ESI, X86::EBP, 0
|
| + };
|
| + static const uint16_t CU64BitRegs[] = {
|
| + X86::RBX, X86::R12, X86::R13, X86::R14, X86::R15, X86::RBP, 0
|
| + };
|
| + const uint16_t *CURegs = (Is64Bit ? CU64BitRegs : CU32BitRegs);
|
| +
|
| // Encode the registers in the order they were saved, 3-bits per register. The
|
| // registers are numbered from 1 to CU_NUM_SAVED_REGS.
|
| uint32_t RegEnc = 0;
|
| @@ -475,7 +484,7 @@ encodeCompactUnwindRegistersWithFrame(unsigned SavedRegs[CU_NUM_SAVED_REGS],
|
| unsigned Reg = SavedRegs[I];
|
| if (Reg == 0) continue;
|
|
|
| - int CURegNum = getCompactUnwindRegNum(Reg, Is64Bit);
|
| + int CURegNum = getCompactUnwindRegNum(CURegs, Reg);
|
| if (CURegNum == -1) return ~0U;
|
|
|
| // Encode the 3-bit register number in order, skipping over 3-bits for each
|
| @@ -528,12 +537,6 @@ uint32_t X86FrameLowering::getCompactUnwindEncoding(MachineFunction &MF) const {
|
| // If there are too many saved registers, we cannot use compact encoding.
|
| if (SavedRegIdx >= CU_NUM_SAVED_REGS) return CU::UNWIND_MODE_DWARF;
|
|
|
| - unsigned Reg = MI.getOperand(0).getReg();
|
| - if (Reg == (Is64Bit ? X86::RAX : X86::EAX)) {
|
| - ExpectEnd = true;
|
| - continue;
|
| - }
|
| -
|
| SavedRegs[SavedRegIdx++] = MI.getOperand(0).getReg();
|
| StackAdjust += OffsetSize;
|
| InstrOffset += PushInstrSize;
|
|
|