Skip to content

Commit 8c699c9

Browse files
committed
mi-sched: Reuse an invalid HazardRecognizer to save compile time.
llvm-svn: 189989
1 parent 310190e commit 8c699c9

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

llvm/lib/CodeGen/MachineScheduler.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1469,13 +1469,16 @@ class ConvergingScheduler : public MachineSchedStrategy {
14691469

14701470
void reset() {
14711471
// A new HazardRec is created for each DAG and owned by SchedBoundary.
1472-
delete HazardRec;
1473-
1472+
// Detroying and reconstructing it is very expensive though. So keep
1473+
// invalid, placeholder HazardRecs.
1474+
if (HazardRec && HazardRec->isEnabled()) {
1475+
delete HazardRec;
1476+
HazardRec = 0;
1477+
}
14741478
Available.clear();
14751479
Pending.clear();
14761480
CheckPending = false;
14771481
NextSUs.clear();
1478-
HazardRec = 0;
14791482
CurrCycle = 0;
14801483
CurrMOps = 0;
14811484
MinReadyCycle = UINT_MAX;
@@ -1681,9 +1684,14 @@ void ConvergingScheduler::initialize(ScheduleDAGMI *dag) {
16811684
// are disabled, then these HazardRecs will be disabled.
16821685
const InstrItineraryData *Itin = SchedModel->getInstrItineraries();
16831686
const TargetMachine &TM = DAG->MF.getTarget();
1684-
Top.HazardRec = TM.getInstrInfo()->CreateTargetMIHazardRecognizer(Itin, DAG);
1685-
Bot.HazardRec = TM.getInstrInfo()->CreateTargetMIHazardRecognizer(Itin, DAG);
1686-
1687+
if (!Top.HazardRec) {
1688+
Top.HazardRec =
1689+
TM.getInstrInfo()->CreateTargetMIHazardRecognizer(Itin, DAG);
1690+
}
1691+
if (!Bot.HazardRec) {
1692+
Bot.HazardRec =
1693+
TM.getInstrInfo()->CreateTargetMIHazardRecognizer(Itin, DAG);
1694+
}
16871695
assert((!ForceTopDown || !ForceBottomUp) &&
16881696
"-misched-topdown incompatible with -misched-bottomup");
16891697
}

0 commit comments

Comments
 (0)