Skip to content

Commit

Permalink
x86: check hasOpaqueSPAdjustment in canRealignStack
Browse files Browse the repository at this point in the history
Summary:
@rnk pointed out in [1] that x86's canRealignStack logic should match that in CantUseSP from hasBasePointer.

  [1]: http://reviews.llvm.org/D11160?id=29713#inline-89350

Reviewers: rnk

Subscribers: rnk, llvm-commits

Differential Revision: http://reviews.llvm.org/D11377

llvm-svn: 243772
  • Loading branch information
jfbastien committed Jul 31, 2015
1 parent 698e8cf commit e71e653
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions llvm/lib/Target/X86/X86RegisterInfo.cpp
Expand Up @@ -433,6 +433,10 @@ void X86RegisterInfo::adjustStackMapLiveOutMask(uint32_t *Mask) const {
// Stack Frame Processing methods
//===----------------------------------------------------------------------===//

static bool CantUseSP(const MachineFrameInfo *MFI) {
return MFI->hasVarSizedObjects() || MFI->hasOpaqueSPAdjustment();
}

bool X86RegisterInfo::hasBasePointer(const MachineFunction &MF) const {
const MachineFrameInfo *MFI = MF.getFrameInfo();

Expand All @@ -445,9 +449,7 @@ bool X86RegisterInfo::hasBasePointer(const MachineFunction &MF) const {
// reference locals while also adjusting the stack pointer. When we can't
// use both the SP and the FP, we need a separate base pointer register.
bool CantUseFP = needsStackRealignment(MF);
bool CantUseSP =
MFI->hasVarSizedObjects() || MFI->hasOpaqueSPAdjustment();
return CantUseFP && CantUseSP;
return CantUseFP && CantUseSP(MFI);
}

bool X86RegisterInfo::canRealignStack(const MachineFunction &MF) const {
Expand All @@ -464,7 +466,7 @@ bool X86RegisterInfo::canRealignStack(const MachineFunction &MF) const {

// If a base pointer is necessary. Check that it isn't too late to reserve
// it.
if (MFI->hasVarSizedObjects())
if (CantUseSP(MFI))
return MRI->canReserveReg(BasePtr);
return true;
}
Expand Down

0 comments on commit e71e653

Please sign in to comment.