@@ -101,6 +101,16 @@ INITIALIZE_PASS_END(SILowerSGPRSpillsLegacy, DEBUG_TYPE,
101
101
102
102
char &llvm::SILowerSGPRSpillsLegacyID = SILowerSGPRSpillsLegacy::ID;
103
103
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
+
104
114
// / Insert spill code for the callee-saved registers used in the function.
105
115
static void insertCSRSaves (MachineBasicBlock &SaveBlock,
106
116
ArrayRef<CalleeSavedInfo> CSI, SlotIndexes *Indexes,
@@ -126,13 +136,7 @@ static void insertCSRSaves(MachineBasicBlock &SaveBlock,
126
136
// incoming register value, so don't kill at the spill point. This happens
127
137
// since we pass some special inputs (workgroup IDs) in the callee saved
128
138
// 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);
136
140
TII.storeRegToStackSlot (SaveBlock, I, Reg, !IsLiveIn, CS.getFrameIdx (),
137
141
RC, TRI, Register ());
138
142
0 commit comments