Skip to content

Commit 4c3577b

Browse files
committed
Enable RegisterScavenging for X86
Only enable register scavenging if we will need it to handle huge frames.
1 parent 648f4d0 commit 4c3577b

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
@@ -1553,7 +1553,7 @@ void PEI::replaceFrameIndices(MachineBasicBlock *BB, MachineFunction &MF,
15531553
// If this instruction has a FrameIndex operand, we need to
15541554
// use that target machine register info object to eliminate
15551555
// it.
1556-
TRI.eliminateFrameIndex(MI, SPAdj, i);
1556+
TRI.eliminateFrameIndex(MI, SPAdj, i, RS);
15571557

15581558
// Reset the iterator if we were at the beginning of the BB.
15591559
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 !isInt<32>(MFI.estimateStackSize(MF));
187+
}
179188
};
180189

181190
} // End llvm namespace

0 commit comments

Comments
 (0)