@@ -150,10 +150,10 @@ float VirtRegAuxInfo::weightCalcHelper(LiveInterval &LI, SlotIndex *Start,
150
150
MachineLoop *Loop = nullptr ;
151
151
bool IsExiting = false ;
152
152
float TotalWeight = 0 ;
153
- unsigned NumInstr = 0 ; // Number of instructions using li
153
+ unsigned NumInstr = 0 ; // Number of instructions using LI
154
154
SmallPtrSet<MachineInstr *, 8 > Visited;
155
155
156
- std::pair<unsigned , unsigned > TargetHint = MRI.getRegAllocationHint (LI.reg ());
156
+ std::pair<Register, Register > TargetHint = MRI.getRegAllocationHint (LI.reg ());
157
157
158
158
if (LI.isSpillable () && VRM) {
159
159
Register Reg = LI.reg ();
@@ -192,22 +192,21 @@ float VirtRegAuxInfo::weightCalcHelper(LiveInterval &LI, SlotIndex *Start,
192
192
193
193
// CopyHint is a sortable hint derived from a COPY instruction.
194
194
struct CopyHint {
195
- unsigned Reg;
196
- float Weight;
197
- bool IsPhys;
198
- CopyHint (unsigned R, float W, bool P) :
199
- Reg (R), Weight(W), IsPhys(P) {}
200
- bool operator <(const CopyHint &rhs) const {
195
+ const Register Reg;
196
+ const float Weight;
197
+ CopyHint (Register R, float W) : Reg(R), Weight(W) {}
198
+ bool operator <(const CopyHint &Rhs) const {
201
199
// Always prefer any physreg hint.
202
- if (IsPhys != rhs. IsPhys )
203
- return (IsPhys && !rhs. IsPhys );
204
- if (Weight != rhs .Weight )
205
- return (Weight > rhs .Weight );
206
- return Reg < rhs .Reg ; // Tie-breaker.
200
+ if (Reg. isPhysical () != Rhs. Reg . isPhysical () )
201
+ return Reg. isPhysical ( );
202
+ if (Weight != Rhs .Weight )
203
+ return (Weight > Rhs .Weight );
204
+ return Reg. id () < Rhs .Reg . id () ; // Tie-breaker.
207
205
}
208
206
};
209
- std::set<CopyHint> CopyHints;
210
207
208
+ std::set<CopyHint> CopyHints;
209
+ DenseMap<unsigned , float > Hint;
211
210
for (MachineRegisterInfo::reg_instr_nodbg_iterator
212
211
I = MRI.reg_instr_nodbg_begin (LI.reg ()),
213
212
E = MRI.reg_instr_nodbg_end ();
@@ -250,28 +249,25 @@ float VirtRegAuxInfo::weightCalcHelper(LiveInterval &LI, SlotIndex *Start,
250
249
// Get allocation hints from copies.
251
250
if (!MI->isCopy ())
252
251
continue ;
253
- Register hint = copyHint (MI, LI.reg (), TRI, MRI);
254
- if (!hint )
252
+ Register HintReg = copyHint (MI, LI.reg (), TRI, MRI);
253
+ if (!HintReg )
255
254
continue ;
256
255
// Force hweight onto the stack so that x86 doesn't add hidden precision,
257
256
// making the comparison incorrectly pass (i.e., 1 > 1 == true??).
258
257
//
259
258
// FIXME: we probably shouldn't use floats at all.
260
- volatile float HWeight = Hint[hint] += Weight;
261
- if (Register::isVirtualRegister (hint) || MRI.isAllocatable (hint))
262
- CopyHints.insert (
263
- CopyHint (hint, HWeight, Register::isPhysicalRegister (hint)));
259
+ volatile float HWeight = Hint[HintReg] += Weight;
260
+ if (HintReg.isVirtual () || MRI.isAllocatable (HintReg))
261
+ CopyHints.insert (CopyHint (HintReg, HWeight));
264
262
}
265
263
266
- Hint.clear ();
267
-
268
264
// Pass all the sorted copy hints to mri.
269
265
if (ShouldUpdateLI && CopyHints.size ()) {
270
266
// Remove a generic hint if previously added by target.
271
267
if (TargetHint.first == 0 && TargetHint.second )
272
268
MRI.clearSimpleHint (LI.reg ());
273
269
274
- std::set<unsigned > HintedRegs;
270
+ std::set<Register > HintedRegs;
275
271
for (auto &Hint : CopyHints) {
276
272
if (!HintedRegs.insert (Hint.Reg ).second ||
277
273
(TargetHint.first != 0 && Hint.Reg == TargetHint.second ))
0 commit comments