@@ -57,15 +57,29 @@ void SystemZPreRASchedStrategy::initializePrioRegClasses(
57
57
}
58
58
}
59
59
60
- void SystemZPreRASchedStrategy::VRegSet::dump (std::string Msg) {
61
- dbgs () << Msg.c_str ();
60
+ void SystemZPreRASchedStrategy::VRegSet::insert (Register Reg) {
61
+ assert (Reg.isVirtual ());
62
+ Regs.insert (Reg);
63
+ }
64
+
65
+ void SystemZPreRASchedStrategy::VRegSet::erase (Register Reg) {
66
+ assert (Reg.isVirtual ());
67
+ Regs.erase (Reg);
68
+ }
69
+
70
+ bool SystemZPreRASchedStrategy::VRegSet::count (Register Reg) const {
71
+ assert (Reg.isVirtual ());
72
+ return Regs.count (Reg);
73
+ }
74
+
75
+ void SystemZPreRASchedStrategy::VRegSet::dump () const {
62
76
bool First = true ;
63
- for (auto R : * this ) {
77
+ for (auto R : Regs ) {
64
78
if (!First)
65
79
dbgs () << " , " ;
66
80
else
67
81
First = false ;
68
- dbgs () << " % " << R. virtRegIndex ( );
82
+ dbgs () << printReg (R );
69
83
}
70
84
dbgs () << " \n " ;
71
85
}
@@ -109,8 +123,8 @@ void SystemZPreRASchedStrategy::initializeStoresGroup() {
109
123
return ;
110
124
if (IsStore)
111
125
StoresGroup.insert (SU);
112
- }
113
- else if (IsStore && !StoresGroup. empty () && SU->getDepth () == CurrMaxDepth) {
126
+ } else if (IsStore && !StoresGroup. empty () &&
127
+ SU->getDepth () == CurrMaxDepth) {
114
128
// The group members should all have the same opcode.
115
129
if ((*StoresGroup.begin ())->getInstr ()->getOpcode () != MI->getOpcode ()) {
116
130
StoresGroup.clear ();
@@ -142,9 +156,8 @@ static int biasPhysRegExtra(const SUnit *SU) {
142
156
return 0 ;
143
157
}
144
158
145
- int SystemZPreRASchedStrategy::
146
- computeSULivenessScore (SchedCandidate &C, ScheduleDAGMILive *DAG,
147
- SchedBoundary *Zone) const {
159
+ int SystemZPreRASchedStrategy::computeSULivenessScore (
160
+ SchedCandidate &C, ScheduleDAGMILive *DAG, SchedBoundary *Zone) const {
148
161
// Not all data deps are modelled around the SUnit - some data edges near
149
162
// boundaries are missing: Look directly at the MI operands instead.
150
163
const SUnit *SU = C.SU ;
@@ -246,22 +259,24 @@ bool SystemZPreRASchedStrategy::tryCandidate(SchedCandidate &Cand,
246
259
return TryCand.Reason != NoCand;
247
260
248
261
// Don't extend the scheduled latency.
249
- if (ShouldReduceLatency && TryCand.SU ->getHeight () != Cand.SU ->getHeight () &&
262
+ if (ShouldReduceLatency &&
263
+ TryCand.SU ->getHeight () != Cand.SU ->getHeight () &&
250
264
(std::max (TryCand.SU ->getHeight (), Cand.SU ->getHeight ()) >
251
265
Zone->getScheduledLatency ())) {
252
- unsigned HigherSUDepth = TryCand.SU ->getHeight () < Cand.SU ->getHeight () ?
253
- Cand.SU ->getDepth () : TryCand.SU ->getDepth ();
266
+ unsigned HigherSUDepth = TryCand.SU ->getHeight () < Cand.SU ->getHeight ()
267
+ ? Cand.SU ->getDepth ()
268
+ : TryCand.SU ->getDepth ();
254
269
if (HigherSUDepth != getRemLat (Zone) &&
255
- tryLess (TryCand.SU ->getHeight (), Cand.SU ->getHeight (),
256
- TryCand, Cand, GenericSchedulerBase::BotHeightReduce)) {
270
+ tryLess (TryCand.SU ->getHeight (), Cand.SU ->getHeight (), TryCand, Cand,
271
+ GenericSchedulerBase::BotHeightReduce)) {
257
272
return TryCand.Reason != NoCand;
258
273
}
259
274
}
260
275
}
261
276
262
277
// Weak edges are for clustering and other constraints.
263
- if (tryLess (TryCand.SU ->WeakSuccsLeft , Cand.SU ->WeakSuccsLeft ,
264
- TryCand, Cand, Weak))
278
+ if (tryLess (TryCand.SU ->WeakSuccsLeft , Cand.SU ->WeakSuccsLeft , TryCand, Cand,
279
+ Weak))
265
280
return TryCand.Reason != NoCand;
266
281
267
282
// Fall through to original instruction order.
@@ -361,17 +376,22 @@ void SystemZPreRASchedStrategy::initialize(ScheduleDAGMI *dag) {
361
376
LLVM_DEBUG (if (ShouldReduceLatency) dbgs () << " Latency scheduling enabled.\n " ;
362
377
else dbgs () << " Latency scheduling disabled.\n " ;);
363
378
364
- // Find the registers that are live at the bottom, before scheduling .
379
+ // Find the registers used in the region that are live out .
365
380
LiveRegs.clear ();
366
- for (unsigned I = 0 , E = DAG->MRI .getNumVirtRegs (); I != E; ++I) {
367
- Register VirtReg = Register::index2VirtReg (I);
368
- const LiveInterval &LI = DAG->getLIS ()->getInterval (VirtReg);
369
- LiveQueryResult LRQ = LI.Query (
370
- DAG->getLIS ()->getInstructionIndex (*DAG->SUnits .back ().getInstr ()));
371
- if (LRQ.valueOut ())
372
- LiveRegs.insert (VirtReg);
381
+ std::set<Register> Visited;
382
+ for (unsigned Idx = 0 , End = DAG->SUnits .size (); Idx != End; ++Idx) {
383
+ const MachineInstr *MI = DAG->SUnits [Idx].getInstr ();
384
+ for (auto &MO : MI->explicit_operands ())
385
+ if (MO.isReg () && MO.getReg ().isVirtual () &&
386
+ Visited.insert (MO.getReg ()).second ) {
387
+ const LiveInterval &LI = DAG->getLIS ()->getInterval (MO.getReg ());
388
+ LiveQueryResult LRQ = LI.Query (
389
+ DAG->getLIS ()->getInstructionIndex (*DAG->SUnits .back ().getInstr ()));
390
+ if (LRQ.valueOut ())
391
+ LiveRegs.insert (MO.getReg ());
392
+ }
373
393
}
374
- LLVM_DEBUG (LiveRegs. dump ( " Live out at bottom: " ););
394
+ LLVM_DEBUG (dbgs () << " Live out at bottom: " ; LiveRegs. dump ( ););
375
395
376
396
// If MI uses the register it defines, record it one time here.
377
397
IsRedefining = std::vector<bool >(DAG->SUnits .size (), false );
@@ -395,7 +415,7 @@ void SystemZPreRASchedStrategy::schedNode(SUnit *SU, bool IsTopNode) {
395
415
if (TinyRegion)
396
416
return ;
397
417
398
- LLVM_DEBUG (LiveRegs. dump ( " Live regs was: " ););
418
+ LLVM_DEBUG (dbgs () << " Live regs was: " ; LiveRegs. dump ( ););
399
419
400
420
if (!FirstStoreInGroupScheduled && StoresGroup.count (SU))
401
421
FirstStoreInGroupScheduled = true ;
0 commit comments