[PowerPC] Fix invalid displacement created by LocalStackAlloc
authorUlrich Weigand <ulrich.weigand@de.ibm.com>
Fri, 11 Jul 2014 17:19:31 +0000 (17:19 +0000)
committerUlrich Weigand <ulrich.weigand@de.ibm.com>
Fri, 11 Jul 2014 17:19:31 +0000 (17:19 +0000)
commitedb27188b433292536bb79543cdc39337cb52d25
treed9ac106d1d5e373465f0b7935bebdf010b1eea65
parent438e1f2ad88740f14771215c807d59b5fcc92112
[PowerPC] Fix invalid displacement created by LocalStackAlloc

This commit fixes a bug in PPCRegisterInfo::isFrameOffsetLegal that
could result in the LocalStackAlloc pass creating an MI instruction
out-of-range displacement:
        %vreg17<def> = LD 33184, %vreg31; mem:LD8[%g](align=32)
        %G8RC:%vreg17 G8RC_and_G8RC_NOX0:%vreg31
(In final assembler output the top bits are stripped off, resulting
in a negative offset loading from below the stack pointer.)

Common code expects the isFrameOffsetLegal routine to verify whether
adding a given offset to the offset already present in the instruction
results in a valid displacement.  However, on PowerPC the routine
did not take the already present instruction offset into account.

This commit fixes isFrameOffsetLegal to add the instruction offset,
and updates a local caller (needsFrameBaseReg) to no longer add the
instruction offset itself before calling isFrameOffsetLegal.

Reviewed by Hal Finkel.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212832 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/PowerPC/PPCRegisterInfo.cpp
test/CodeGen/PowerPC/resolvefi-disp.ll [new file with mode: 0644]