[llvm] r230233 - Fix incorrect immediate size for AddrModeT2_i8s4 in rewriteT2FrameIndex.

Bob Wilson bob.wilson at apple.com
Mon Feb 23 08:57:19 PST 2015


Author: bwilson
Date: Mon Feb 23 10:57:19 2015
New Revision: 230233

URL: http://llvm.org/viewvc/llvm-project?rev=230233&view=rev
Log:
Fix incorrect immediate size for AddrModeT2_i8s4 in rewriteT2FrameIndex.

The natural way to handle this addressing mode would be to say that it has
8 bits and gets scaled by 4, but since the MC layer is expecting the scaling
to be already reflected in the immediate value, we have been setting the
Scale to 1. That's fine, but then NumBits needs to be adjusted to reflect
the effective increase in the range of the immediate. That adjustment was
missing.

The consequence is that the register scavenger can fail.
The estimateRSStackSizeLimit() function in ARMFrameLowering.cpp correctly
assumes that the AddrModeT2_i8s4 address mode can handle scaled offsets up to
1020. Under just the right circumstances, we fail to reserve space for the
scavenger because it thinks that nothing will be needed. However, the overly
pessimistic behavior in rewriteT2FrameIndex causes some frame indexes to be
out of range and require scavenged registers, and so the scavenger asserts.

Unfortunately I have not been able to come up with a testcase for this. I
can only reproduce it on an internal branch where the frame layout and
register allocation is slightly different than trunk. We really need a
way to serialize MachineInstr-level IR to write reasonable tests for things
like this.

rdar://problem/19909005

Modified:
    llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp

Modified: llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp?rev=230233&r1=230232&r2=230233&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp (original)
+++ llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp Mon Feb 23 10:57:19 2015
@@ -574,7 +574,7 @@ bool llvm::rewriteT2FrameIndex(MachineIn
       }
     } else if (AddrMode == ARMII::AddrModeT2_i8s4) {
       Offset += MI.getOperand(FrameRegIdx + 1).getImm() * 4;
-      NumBits = 8;
+      NumBits = 10; // 8 bits scaled by 4
       // MCInst operand has already scaled value.
       Scale = 1;
       if (Offset < 0) {





More information about the llvm-commits mailing list