Skip to content

Commit 8afd17f

Browse files
committed
Enable RegisterScavenging for X86
Only enable register scavenging if we will need it to handle huge frames.
1 parent c444548 commit 8afd17f

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

llvm/lib/CodeGen/PrologEpilogInserter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1545,7 +1545,7 @@ void PEI::replaceFrameIndices(MachineBasicBlock *BB, MachineFunction &MF,
15451545
// If this instruction has a FrameIndex operand, we need to
15461546
// use that target machine register info object to eliminate
15471547
// it.
1548-
TRI.eliminateFrameIndex(MI, SPAdj, i);
1548+
TRI.eliminateFrameIndex(MI, SPAdj, i, RS);
15491549

15501550
// Reset the iterator if we were at the beginning of the BB.
15511551
if (AtBeginning) {

llvm/lib/Target/X86/X86RegisterInfo.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#ifndef LLVM_LIB_TARGET_X86_X86REGISTERINFO_H
1414
#define LLVM_LIB_TARGET_X86_X86REGISTERINFO_H
1515

16+
#include "llvm/CodeGen/MachineFrameInfo.h"
17+
#include "llvm/CodeGen/MachineFunction.h"
1618
#include "llvm/CodeGen/TargetRegisterInfo.h"
1719

1820
#define GET_REGINFO_HEADER
@@ -176,6 +178,13 @@ class X86RegisterInfo final : public X86GenRegisterInfo {
176178
SmallVectorImpl<MCPhysReg> &Hints,
177179
const MachineFunction &MF, const VirtRegMap *VRM,
178180
const LiveRegMatrix *Matrix) const override;
181+
182+
bool requiresRegisterScavenging(const MachineFunction &MF) const override {
183+
const MachineFrameInfo &MFI = MF.getFrameInfo();
184+
185+
// We need to register scavenge if the frame is very large.
186+
return Is64Bit && !isInt<32>(MFI.estimateStackSize(MF));
187+
}
179188
};
180189

181190
} // End llvm namespace

0 commit comments

Comments
 (0)