@@ -101,6 +101,16 @@ INITIALIZE_PASS_END(SILowerSGPRSpillsLegacy, DEBUG_TYPE,
101101
102102char &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.
105115static 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