Skip to content

Commit 3d2fa29

Browse files
committed
In MachineScheduler instead of Subtarget.
1 parent 2bfad9b commit 3d2fa29

File tree

5 files changed

+18
-52
lines changed

5 files changed

+18
-52
lines changed

llvm/include/llvm/CodeGen/MachineScheduler.h

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -241,12 +241,6 @@ class MachineSchedStrategy {
241241
/// Tell the strategy that MBB is about to be processed.
242242
virtual void enterMBB(MachineBasicBlock *MBB) {};
243243

244-
virtual bool disableForRegionPreRA(MachineBasicBlock::iterator begin,
245-
MachineBasicBlock::iterator end,
246-
unsigned regioninstrs) const {
247-
return false;
248-
}
249-
250244
/// Tell the strategy that current MBB is done.
251245
virtual void leaveMBB() {};
252246

@@ -496,9 +490,7 @@ class ScheduleDAGMILive : public ScheduleDAGMI {
496490
bool disableForRegion(MachineBasicBlock *bb,
497491
MachineBasicBlock::iterator begin,
498492
MachineBasicBlock::iterator end,
499-
unsigned regioninstrs) const override {
500-
return SchedImpl->disableForRegionPreRA(begin, end, regioninstrs);
501-
}
493+
unsigned regioninstrs) const override;
502494

503495
/// Implement ScheduleDAGInstrs interface for scheduling a sequence of
504496
/// reorderable instructions.
@@ -1232,10 +1224,6 @@ class GenericScheduler : public GenericSchedulerBase {
12321224

12331225
void dumpPolicy() const override;
12341226

1235-
bool disableForRegionPreRA(MachineBasicBlock::iterator Begin,
1236-
MachineBasicBlock::iterator End,
1237-
unsigned NumRegionInstrs) const override;
1238-
12391227
bool shouldTrackPressure() const override {
12401228
return RegionPolicy.ShouldTrackPressure;
12411229
}

llvm/include/llvm/CodeGen/TargetSubtargetInfo.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include "llvm/ADT/ArrayRef.h"
1717
#include "llvm/ADT/SmallVector.h"
1818
#include "llvm/ADT/StringRef.h"
19-
#include "llvm/CodeGen/MachineBasicBlock.h"
2019
#include "llvm/CodeGen/MacroFusion.h"
2120
#include "llvm/CodeGen/PBQPRAConstraint.h"
2221
#include "llvm/CodeGen/SchedulerRegistry.h"
@@ -230,15 +229,6 @@ class TargetSubtargetInfo : public MCSubtargetInfo {
230229
virtual void overrideSchedPolicy(MachineSchedPolicy &Policy,
231230
unsigned NumRegionInstrs) const {}
232231

233-
/// Allow the subtarget to leave a region untouched. This has purposefully
234-
/// been left a bit untangled from other methods as this is hopefully
235-
/// just a temporary solution.
236-
virtual bool disableForRegionPreRA(MachineBasicBlock::iterator Begin,
237-
MachineBasicBlock::iterator End,
238-
unsigned NumRegionInstrs) const {
239-
return false;
240-
}
241-
242232
// Perform target-specific adjustments to the latency of a schedule
243233
// dependency.
244234
// If a pair of operands is associated with the schedule dependency, DefOpIdx

llvm/lib/CodeGen/MachineScheduler.cpp

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,6 +1253,23 @@ void ScheduleDAGMILive::enterRegion(MachineBasicBlock *bb,
12531253
"ShouldTrackLaneMasks requires ShouldTrackPressure");
12541254
}
12551255

1256+
// EXPERIMENTAL: It seems that GenericScheduler currently often increases
1257+
// spilling heavily with huge regions (like >350 instructions). This option
1258+
// makes any sched region bigger than its value have pre-ra scheduling
1259+
// skipped.
1260+
cl::opt<unsigned> NoSchedAbove("nosched-above", cl::init(~0U));
1261+
bool ScheduleDAGMILive::disableForRegion(MachineBasicBlock *bb,
1262+
MachineBasicBlock::iterator begin,
1263+
MachineBasicBlock::iterator end,
1264+
unsigned regioninstrs) const {
1265+
if (NumRegionInstrs > NoSchedAbove) {
1266+
LLVM_DEBUG(dbgs() << "Disabling pre-ra mischeduling of region with "
1267+
<< NumRegionInstrs << " instructions\n";);
1268+
return true;
1269+
}
1270+
return false;
1271+
}
1272+
12561273
// Setup the register pressure trackers for the top scheduled and bottom
12571274
// scheduled regions.
12581275
void ScheduleDAGMILive::initRegPressure() {
@@ -3335,13 +3352,6 @@ void GenericScheduler::dumpPolicy() const {
33353352
#endif
33363353
}
33373354

3338-
bool GenericScheduler::disableForRegionPreRA(MachineBasicBlock::iterator Begin,
3339-
MachineBasicBlock::iterator End,
3340-
unsigned NumRegionInstrs) const {
3341-
const MachineFunction &MF = *Begin->getMF();
3342-
return MF.getSubtarget().disableForRegionPreRA(Begin, End, NumRegionInstrs);
3343-
}
3344-
33453355
/// Set IsAcyclicLatencyLimited if the acyclic path is longer than the cyclic
33463356
/// critical path by more cycles than it takes to drain the instruction buffer.
33473357
/// We estimate an upper bounds on in-flight instructions as:

llvm/lib/Target/SystemZ/SystemZSubtarget.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -72,22 +72,6 @@ SystemZSubtarget::SystemZSubtarget(const Triple &TT, const std::string &CPU,
7272
InstrInfo(initializeSubtargetDependencies(CPU, TuneCPU, FS)),
7373
TLInfo(TM, *this), FrameLowering(SystemZFrameLowering::create(*this)) {}
7474

75-
76-
// EXPERIMENTAL
77-
cl::opt<unsigned> NoSchedAbove("nosched-above", cl::init(~0U));
78-
bool SystemZSubtarget::disableForRegionPreRA(MachineBasicBlock::iterator Begin,
79-
MachineBasicBlock::iterator End,
80-
unsigned NumRegionInstrs) const {
81-
// It seems that the generic scheduler currently can increase spilling heavily
82-
// with big / huge regions. Disable it until it is fixed.
83-
if (NumRegionInstrs > NoSchedAbove) {
84-
LLVM_DEBUG(dbgs() << "Disabling pre-ra mischeduling of region with "
85-
<< NumRegionInstrs << " instructions\n";);
86-
return true;
87-
}
88-
return false;
89-
}
90-
9175
bool SystemZSubtarget::enableSubRegLiveness() const {
9276
return UseSubRegLiveness;
9377
}

llvm/lib/Target/SystemZ/SystemZSubtarget.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,6 @@ class SystemZSubtarget : public SystemZGenSubtargetInfo {
8989
// "source" order scheduler.
9090
bool enableMachineScheduler() const override { return true; }
9191

92-
// Don't use pre-ra mischeduler for huge regions where it creates a lot of
93-
// spilling (temporary solution).
94-
bool disableForRegionPreRA(MachineBasicBlock::iterator Begin,
95-
MachineBasicBlock::iterator End,
96-
unsigned NumRegionInstrs) const override;
97-
9892
// This is important for reducing register pressure in vector code.
9993
bool useAA() const override { return true; }
10094

0 commit comments

Comments
 (0)