[PowerPC] Constrain base register in PPCRegisterInfo::resolveFrameIndex
authorUlrich Weigand <ulrich.weigand@de.ibm.com>
Fri, 27 Jun 2014 13:04:12 +0000 (13:04 +0000)
committerUlrich Weigand <ulrich.weigand@de.ibm.com>
Fri, 27 Jun 2014 13:04:12 +0000 (13:04 +0000)
commit1edaab996f5390ab596167e527001dad4e2d3439
tree7c528ad387608552b13635382a0bd31639d2be5d
parent88897b7c050cbaf3c8b43f366d9aa574068fcf44
[PowerPC] Constrain base register in PPCRegisterInfo::resolveFrameIndex

I've run into a bug where current LLVM at -O0 (with fast-isel)
generated invalid code like:

        ld 0, 20936(1)                  # 8-byte Folded Reload
        stw 12, 10348(0)
        stw 12, 10344(0)

The underlying vreg had been introduced as base register by the
Local Stack Slot Allocation pass.  That register was constrained
to G8RC by PPCRegisterInfo::materializeFrameBaseRegister to match
the ADDI instruction used to set it, but it was *not* constrained
to G8RC_NOX0 to fit the *use* of the register in an address.

That should have happened in PPCRegisterInfo::resolveFrameIndex.
This patch adds an appropriate constrainRegClass call.

Reviewed by Hal Finkel.

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