From 5b2c4978ce56455689c515c9d74cc1d92871f3bb Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Tue, 6 Dec 2011 19:16:17 +0000 Subject: [PATCH] Check the correct value for small stack sizes. Also modify some comments. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145954 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/X86FrameLowering.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/Target/X86/X86FrameLowering.cpp b/lib/Target/X86/X86FrameLowering.cpp index 09aa114f1b6..fe3754587f5 100644 --- a/lib/Target/X86/X86FrameLowering.cpp +++ b/lib/Target/X86/X86FrameLowering.cpp @@ -554,17 +554,17 @@ uint32_t X86FrameLowering::getCompactUnwindEncoding(MachineFunction &MF) const { // Get the encoding of the saved registers when we have a frame pointer. uint32_t RegEnc = encodeCompactUnwindRegistersWithFrame(SavedRegs, Is64Bit); - if (RegEnc == ~0U) - return 0; + if (RegEnc == ~0U) return 0; CompactUnwindEncoding |= 0x01000000; CompactUnwindEncoding |= (CFAOffset & 0xFF) << 16; CompactUnwindEncoding |= RegEnc & 0x7FFF; } else { - unsigned FullOffset = CFAOffset + StackAdjust; - if ((FullOffset & 0xFF) == FullOffset) { - // Frameless stack. + if ((CFAOffset & 0xFF) == CFAOffset) { + // Frameless stack with a small stack size. CompactUnwindEncoding |= 0x02000000; + + // Encode the stack size. CompactUnwindEncoding |= (CFAOffset & 0xFF) << 16; } else { if ((CFAOffset & 0x7) != CFAOffset) @@ -582,6 +582,7 @@ uint32_t X86FrameLowering::getCompactUnwindEncoding(MachineFunction &MF) const { CompactUnwindEncoding |= (CFAOffset & 0x7) << 13; } + // Encode the number of registers saved. CompactUnwindEncoding |= ((6 - SavedRegIdx) & 0x7) << 10; // Get the encoding of the saved registers when we don't have a frame @@ -590,6 +591,8 @@ uint32_t X86FrameLowering::getCompactUnwindEncoding(MachineFunction &MF) const { 6 - SavedRegIdx, Is64Bit); if (RegEnc == ~0U) return 0; + + // Encode the register encoding. CompactUnwindEncoding |= RegEnc & 0x3FF; }