[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)
commitea147a9d4331af26cb0c5ec558dd93e2f44cedaf
tree04170cb5efcba814cb793ddfcf3937164ccff600
parenteac5062cc0fef587581d3242bd22f3da3dbfaf58
[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.

llvm-svn: 212832
llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp
llvm/test/CodeGen/PowerPC/resolvefi-disp.ll [new file with mode: 0644]