Skip to content

Commit 7901d5d

Browse files
committed
Moved isLiveIn check logic to a utility function
1 parent 0268630 commit 7901d5d

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

llvm/lib/Target/AMDGPU/SILowerSGPRSpills.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,16 @@ INITIALIZE_PASS_END(SILowerSGPRSpillsLegacy, DEBUG_TYPE,
101101

102102
char &llvm::SILowerSGPRSpillsLegacyID = SILowerSGPRSpillsLegacy::ID;
103103

104+
static bool isLiveInIntoMBB(MCRegister Reg, MachineBasicBlock &MBB,
105+
const TargetRegisterInfo *TRI) {
106+
for (MCRegAliasIterator R(Reg, TRI, true); R.isValid(); ++R) {
107+
if (MBB.isLiveIn(*R)) {
108+
return true;
109+
}
110+
}
111+
return false;
112+
}
113+
104114
/// Insert spill code for the callee-saved registers used in the function.
105115
static void insertCSRSaves(MachineBasicBlock &SaveBlock,
106116
ArrayRef<CalleeSavedInfo> CSI, SlotIndexes *Indexes,
@@ -126,13 +136,7 @@ static void insertCSRSaves(MachineBasicBlock &SaveBlock,
126136
// incoming register value, so don't kill at the spill point. This happens
127137
// since we pass some special inputs (workgroup IDs) in the callee saved
128138
// range.
129-
bool IsLiveIn = false;
130-
for (MCRegAliasIterator R(Reg, TRI, true); R.isValid(); ++R) {
131-
if (SaveBlock.isLiveIn(*R)) {
132-
IsLiveIn = true;
133-
break;
134-
}
135-
}
139+
bool IsLiveIn = isLiveInIntoMBB(Reg, SaveBlock, TRI);
136140
TII.storeRegToStackSlot(SaveBlock, I, Reg, !IsLiveIn, CS.getFrameIdx(),
137141
RC, TRI, Register());
138142

0 commit comments

Comments
 (0)