LLVM  5.0.0
GCNIterativeScheduler.cpp
Go to the documentation of this file.
1 //===--------------------- GCNIterativeScheduler.cpp - --------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 /// \file
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "GCNIterativeScheduler.h"
15 #include "GCNSchedStrategy.h"
16 #include "SIMachineFunctionInfo.h"
17 
18 using namespace llvm;
19 
20 #define DEBUG_TYPE "machine-scheduler"
21 
22 namespace llvm {
23  std::vector<const SUnit*> makeMinRegSchedule(ArrayRef<const SUnit*> TopRoots,
24  const ScheduleDAG &DAG);
25 }
26 
27 // shim accessors for different order containers
29  return MI;
30 }
31 static inline MachineInstr *getMachineInstr(const SUnit *SU) {
32  return SU->getInstr();
33 }
34 static inline MachineInstr *getMachineInstr(const SUnit &SU) {
35  return SU.getInstr();
36 }
37 
38 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
40 static void printRegion(raw_ostream &OS,
43  const LiveIntervals *LIS,
44  unsigned MaxInstNum =
46  auto BB = Begin->getParent();
47  OS << BB->getParent()->getName() << ":BB#" << BB->getNumber()
48  << ' ' << BB->getName() << ":\n";
49  auto I = Begin;
50  MaxInstNum = std::max(MaxInstNum, 1u);
51  for (; I != End && MaxInstNum; ++I, --MaxInstNum) {
52  if (!I->isDebugValue() && LIS)
53  OS << LIS->getInstructionIndex(*I);
54  OS << '\t' << *I;
55  }
56  if (I != End) {
57  OS << "\t...\n";
58  I = std::prev(End);
59  if (!I->isDebugValue() && LIS)
60  OS << LIS->getInstructionIndex(*I);
61  OS << '\t' << *I;
62  }
63  if (End != BB->end()) { // print boundary inst if present
64  OS << "----\n";
65  if (LIS) OS << LIS->getInstructionIndex(*End) << '\t';
66  OS << *End;
67  }
68 }
69 
74  const LiveIntervals *LIS) {
75  const auto BB = Begin->getParent();
76  const auto &MRI = BB->getParent()->getRegInfo();
77 
78  const auto LiveIns = getLiveRegsBefore(*Begin, *LIS);
79  OS << "LIn RP: ";
80  getRegPressure(MRI, LiveIns).print(OS);
81 
82  const auto BottomMI = End == BB->end() ? std::prev(End) : End;
83  const auto LiveOuts = getLiveRegsAfter(*BottomMI, *LIS);
84  OS << "LOt RP: ";
85  getRegPressure(MRI, LiveOuts).print(OS);
86 }
87 
90  const auto &ST = MF.getSubtarget<SISubtarget>();
91  for (const auto R : Regions) {
92  OS << "Region to schedule ";
93  printRegion(OS, R->Begin, R->End, LIS, 1);
94  printLivenessInfo(OS, R->Begin, R->End, LIS);
95  OS << "Max RP: ";
96  R->MaxPressure.print(OS, &ST);
97  }
98 }
99 
102  const Region *R,
103  const GCNRegPressure &RP) const {
104  OS << "\nAfter scheduling ";
105  printRegion(OS, R->Begin, R->End, LIS);
106  printSchedRP(OS, R->MaxPressure, RP);
107  OS << '\n';
108 }
109 
112  const GCNRegPressure &Before,
113  const GCNRegPressure &After) const {
114  const auto &ST = MF.getSubtarget<SISubtarget>();
115  OS << "RP before: ";
116  Before.print(OS, &ST);
117  OS << "RP after: ";
118  After.print(OS, &ST);
119 }
120 
121 #endif
122 
123 // DAG builder helper
126  SmallVector<SUnit*, 8> TopRoots;
127 public:
129  : Sch(_Sch) {
130  auto BB = R.Begin->getParent();
131  Sch.BaseClass::startBlock(BB);
132  Sch.BaseClass::enterRegion(BB, R.Begin, R.End, R.NumRegionInstrs);
133 
134  Sch.buildSchedGraph(Sch.AA, nullptr, nullptr, nullptr,
135  /*TrackLaneMask*/true);
136  Sch.Topo.InitDAGTopologicalSorting();
137 
138  SmallVector<SUnit*, 8> BotRoots;
139  Sch.findRootsAndBiasEdges(TopRoots, BotRoots);
140  }
142  Sch.BaseClass::exitRegion();
143  Sch.BaseClass::finishBlock();
144  }
146  return TopRoots;
147  }
148 };
149 
152  Region &Rgn;
153  std::unique_ptr<MachineSchedStrategy> SaveSchedImpl;
154  GCNRegPressure SaveMaxRP;
155 public:
157  MachineSchedStrategy &OverrideStrategy,
158  GCNIterativeScheduler &_Sch)
159  : Sch(_Sch)
160  , Rgn(R)
161  , SaveSchedImpl(std::move(_Sch.SchedImpl))
162  , SaveMaxRP(R.MaxPressure) {
163  Sch.SchedImpl.reset(&OverrideStrategy);
164  auto BB = R.Begin->getParent();
165  Sch.BaseClass::startBlock(BB);
166  Sch.BaseClass::enterRegion(BB, R.Begin, R.End, R.NumRegionInstrs);
167  }
169  Sch.BaseClass::exitRegion();
170  Sch.BaseClass::finishBlock();
171  Sch.SchedImpl.release();
172  Sch.SchedImpl = std::move(SaveSchedImpl);
173  }
174  void schedule() {
175  assert(Sch.RegionBegin == Rgn.Begin && Sch.RegionEnd == Rgn.End);
176  DEBUG(dbgs() << "\nScheduling ";
177  printRegion(dbgs(), Rgn.Begin, Rgn.End, Sch.LIS, 2));
178  Sch.BaseClass::schedule();
179 
180  // Unfortunatelly placeDebugValues incorrectly modifies RegionEnd, restore
181  Sch.RegionEnd = Rgn.End;
182  //assert(Rgn.End == Sch.RegionEnd);
183  Rgn.Begin = Sch.RegionBegin;
184  Rgn.MaxPressure.clear();
185  }
186  void restoreOrder() {
187  assert(Sch.RegionBegin == Rgn.Begin && Sch.RegionEnd == Rgn.End);
188  // DAG SUnits are stored using original region's order
189  // so just use SUnits as the restoring schedule
190  Sch.scheduleRegion(Rgn, Sch.SUnits, SaveMaxRP);
191  }
192 };
193 
194 namespace {
195 // just a stub to make base class happy
196 class SchedStrategyStub : public MachineSchedStrategy {
197 public:
198  bool shouldTrackPressure() const override { return false; }
199  bool shouldTrackLaneMasks() const override { return false; }
200  void initialize(ScheduleDAGMI *DAG) override {}
201  SUnit *pickNode(bool &IsTopNode) override { return nullptr; }
202  void schedNode(SUnit *SU, bool IsTopNode) override {}
203  void releaseTopNode(SUnit *SU) override {}
204  void releaseBottomNode(SUnit *SU) override {}
205 };
206 } // namespace
207 
209  StrategyKind S)
210  : BaseClass(C, llvm::make_unique<SchedStrategyStub>())
211  , Context(C)
212  , Strategy(S)
213  , UPTracker(*LIS) {
214 }
215 
216 // returns max pressure for a region
220  const {
221  // For the purpose of pressure tracking bottom inst of the region should
222  // be also processed. End is either BB end, BB terminator inst or sched
223  // boundary inst.
224  auto const BBEnd = Begin->getParent()->end();
225  auto const BottomMI = End == BBEnd ? std::prev(End) : End;
226 
227  // scheduleRegions walks bottom to top, so its likely we just get next
228  // instruction to track
229  auto AfterBottomMI = std::next(BottomMI);
230  if (AfterBottomMI == BBEnd ||
231  &*AfterBottomMI != UPTracker.getLastTrackedMI()) {
232  UPTracker.reset(*BottomMI);
233  } else {
235  }
236 
237  for (auto I = BottomMI; I != Begin; --I)
238  UPTracker.recede(*I);
239 
240  UPTracker.recede(*Begin);
241 
243  (dbgs() << "Tracked region ",
244  printRegion(dbgs(), Begin, End, LIS), false));
245  return UPTracker.moveMaxPressure();
246 }
247 
248 // returns max pressure for a tentative schedule
249 template <typename Range> GCNRegPressure
251  Range &&Schedule) const {
252  auto const BBEnd = R.Begin->getParent()->end();
254  if (R.End != BBEnd) {
255  // R.End points to the boundary instruction but the
256  // schedule doesn't include it
257  RPTracker.reset(*R.End);
258  RPTracker.recede(*R.End);
259  } else {
260  // R.End doesn't point to the boundary instruction
261  RPTracker.reset(*std::prev(BBEnd));
262  }
263  for (auto I = Schedule.end(), B = Schedule.begin(); I != B;) {
264  RPTracker.recede(*getMachineInstr(*--I));
265  }
266  return RPTracker.moveMaxPressure();
267 }
268 
272  unsigned NumRegionInstrs) {
273  BaseClass::enterRegion(BB, Begin, End, NumRegionInstrs);
274  if (NumRegionInstrs > 2) {
275  Regions.push_back(
276  new (Alloc.Allocate())
277  Region { Begin, End, NumRegionInstrs,
278  getRegionPressure(Begin, End), nullptr });
279  }
280 }
281 
282 void GCNIterativeScheduler::schedule() { // overriden
283  // do nothing
284  DEBUG(
286  if (!Regions.empty() && Regions.back()->Begin == RegionBegin) {
287  dbgs() << "Max RP: ";
288  Regions.back()->MaxPressure.print(dbgs(), &MF.getSubtarget<SISubtarget>());
289  }
290  dbgs() << '\n';
291  );
292 }
293 
295  if (Regions.empty())
296  return;
297  switch (Strategy) {
298  case SCHEDULE_MINREGONLY: scheduleMinReg(); break;
299  case SCHEDULE_MINREGFORCED: scheduleMinReg(true); break;
301  }
302 }
303 
304 // Detach schedule from SUnits and interleave it with debug values.
305 // Returned schedule becomes independent of DAG state.
306 std::vector<MachineInstr*>
308  std::vector<MachineInstr*> Res;
309  Res.reserve(Schedule.size() * 2);
310 
311  if (FirstDbgValue)
312  Res.push_back(FirstDbgValue);
313 
314  const auto DbgB = DbgValues.begin(), DbgE = DbgValues.end();
315  for (auto SU : Schedule) {
316  Res.push_back(SU->getInstr());
317  const auto &D = std::find_if(DbgB, DbgE, [SU](decltype(*DbgB) &P) {
318  return P.second == SU->getInstr();
319  });
320  if (D != DbgE)
321  Res.push_back(D->first);
322  }
323  return Res;
324 }
325 
327  ScheduleRef Schedule,
328  const GCNRegPressure &MaxRP) {
329  R.BestSchedule.reset(
330  new TentativeSchedule{ detachSchedule(Schedule), MaxRP });
331 }
332 
334  assert(R.BestSchedule.get() && "No schedule specified");
335  scheduleRegion(R, R.BestSchedule->Schedule, R.BestSchedule->MaxPressure);
336  R.BestSchedule.reset();
337 }
338 
339 // minimal required region scheduler, works for ranges of SUnits*,
340 // SUnits or MachineIntrs*
341 template <typename Range>
343  const GCNRegPressure &MaxRP) {
344  assert(RegionBegin == R.Begin && RegionEnd == R.End);
345  assert(LIS != nullptr);
346 #ifndef NDEBUG
347  const auto SchedMaxRP = getSchedulePressure(R, Schedule);
348 #endif
349  auto BB = R.Begin->getParent();
350  auto Top = R.Begin;
351  for (const auto &I : Schedule) {
352  auto MI = getMachineInstr(I);
353  if (MI != &*Top) {
354  BB->remove(MI);
355  BB->insert(Top, MI);
356  if (!MI->isDebugValue())
357  LIS->handleMove(*MI, true);
358  }
359  if (!MI->isDebugValue()) {
360  // Reset read - undef flags and update them later.
361  for (auto &Op : MI->operands())
362  if (Op.isReg() && Op.isDef())
363  Op.setIsUndef(false);
364 
365  RegisterOperands RegOpers;
366  RegOpers.collect(*MI, *TRI, MRI, /*ShouldTrackLaneMasks*/true,
367  /*IgnoreDead*/false);
368  // Adjust liveness and add missing dead+read-undef flags.
369  auto SlotIdx = LIS->getInstructionIndex(*MI).getRegSlot();
370  RegOpers.adjustLaneLiveness(*LIS, MRI, SlotIdx, MI);
371  }
372  Top = std::next(MI->getIterator());
373  }
374  RegionBegin = getMachineInstr(Schedule.front());
375 
376  // Schedule consisting of MachineInstr* is considered 'detached'
377  // and already interleaved with debug values
378  if (!std::is_same<decltype(*Schedule.begin()), MachineInstr*>::value) {
380  // Unfortunatelly placeDebugValues incorrectly modifies RegionEnd, restore
381  //assert(R.End == RegionEnd);
382  RegionEnd = R.End;
383  }
384 
385  R.Begin = RegionBegin;
386  R.MaxPressure = MaxRP;
387 
388 #ifndef NDEBUG
389  const auto RegionMaxRP = getRegionPressure(R);
390  const auto &ST = MF.getSubtarget<SISubtarget>();
391 #endif
392  assert((SchedMaxRP == RegionMaxRP && (MaxRP.empty() || SchedMaxRP == MaxRP))
393  || (dbgs() << "Max RP mismatch!!!\n"
394  "RP for schedule (calculated): ",
395  SchedMaxRP.print(dbgs(), &ST),
396  dbgs() << "RP for schedule (reported): ",
397  MaxRP.print(dbgs(), &ST),
398  dbgs() << "RP after scheduling: ",
399  RegionMaxRP.print(dbgs(), &ST),
400  false));
401 }
402 
403 // Sort recorded regions by pressure - highest at the front
405  const auto &ST = MF.getSubtarget<SISubtarget>();
406  std::sort(Regions.begin(), Regions.end(),
407  [&ST, TargetOcc](const Region *R1, const Region *R2) {
408  return R2->MaxPressure.less(ST, R1->MaxPressure, TargetOcc);
409  });
410 }
411 
412 ///////////////////////////////////////////////////////////////////////////////
413 // Legacy MaxOccupancy Strategy
414 
415 // Tries to increase occupancy applying minreg scheduler for a sequence of
416 // most demanding regions. Obtained schedules are saved as BestSchedule for a
417 // region.
418 // TargetOcc is the best achievable occupancy for a kernel.
419 // Returns better occupancy on success or current occupancy on fail.
420 // BestSchedules aren't deleted on fail.
421 unsigned GCNIterativeScheduler::tryMaximizeOccupancy(unsigned TargetOcc) {
422  // TODO: assert Regions are sorted descending by pressure
423  const auto &ST = MF.getSubtarget<SISubtarget>();
424  const auto Occ = Regions.front()->MaxPressure.getOccupancy(ST);
425  DEBUG(dbgs() << "Trying to to improve occupancy, target = " << TargetOcc
426  << ", current = " << Occ << '\n');
427 
428  auto NewOcc = TargetOcc;
429  for (auto R : Regions) {
430  if (R->MaxPressure.getOccupancy(ST) >= NewOcc)
431  break;
432 
433  DEBUG(printRegion(dbgs(), R->Begin, R->End, LIS, 3);
434  printLivenessInfo(dbgs(), R->Begin, R->End, LIS));
435 
436  BuildDAG DAG(*R, *this);
437  const auto MinSchedule = makeMinRegSchedule(DAG.getTopRoots(), *this);
438  const auto MaxRP = getSchedulePressure(*R, MinSchedule);
439  DEBUG(dbgs() << "Occupancy improvement attempt:\n";
440  printSchedRP(dbgs(), R->MaxPressure, MaxRP));
441 
442  NewOcc = std::min(NewOcc, MaxRP.getOccupancy(ST));
443  if (NewOcc <= Occ)
444  break;
445 
446  setBestSchedule(*R, MinSchedule, MaxRP);
447  }
448  DEBUG(dbgs() << "New occupancy = " << NewOcc
449  << ", prev occupancy = " << Occ << '\n');
450  return std::max(NewOcc, Occ);
451 }
452 
454  bool TryMaximizeOccupancy) {
455  const auto &ST = MF.getSubtarget<SISubtarget>();
456  auto TgtOcc = ST.getOccupancyWithLocalMemSize(MF);
457 
458  sortRegionsByPressure(TgtOcc);
459  auto Occ = Regions.front()->MaxPressure.getOccupancy(ST);
460 
461  if (TryMaximizeOccupancy && Occ < TgtOcc)
462  Occ = tryMaximizeOccupancy(TgtOcc);
463 
464  // This is really weird but for some magic scheduling regions twice
465  // gives performance improvement
466  const int NumPasses = Occ < TgtOcc ? 2 : 1;
467 
468  TgtOcc = std::min(Occ, TgtOcc);
469  DEBUG(dbgs() << "Scheduling using default scheduler, "
470  "target occupancy = " << TgtOcc << '\n');
472 
473  for (int I = 0; I < NumPasses; ++I) {
474  // running first pass with TargetOccupancy = 0 mimics previous scheduling
475  // approach and is a performance magic
476  LStrgy.setTargetOccupancy(I == 0 ? 0 : TgtOcc);
477  for (auto R : Regions) {
478  OverrideLegacyStrategy Ovr(*R, LStrgy, *this);
479 
480  Ovr.schedule();
481  const auto RP = getRegionPressure(*R);
482  DEBUG(printSchedRP(dbgs(), R->MaxPressure, RP));
483 
484  if (RP.getOccupancy(ST) < TgtOcc) {
485  DEBUG(dbgs() << "Didn't fit into target occupancy O" << TgtOcc);
486  if (R->BestSchedule.get() &&
487  R->BestSchedule->MaxPressure.getOccupancy(ST) >= TgtOcc) {
488  DEBUG(dbgs() << ", scheduling minimal register\n");
489  scheduleBest(*R);
490  } else {
491  DEBUG(dbgs() << ", restoring\n");
492  Ovr.restoreOrder();
493  assert(R->MaxPressure.getOccupancy(ST) >= TgtOcc);
494  }
495  }
496  }
497  }
498 }
499 
500 ///////////////////////////////////////////////////////////////////////////////
501 // Minimal Register Strategy
502 
504  const auto &ST = MF.getSubtarget<SISubtarget>();
505  const auto TgtOcc = ST.getOccupancyWithLocalMemSize(MF);
506  sortRegionsByPressure(TgtOcc);
507 
508  auto MaxPressure = Regions.front()->MaxPressure;
509  for (auto R : Regions) {
510  if (!force && R->MaxPressure.less(ST, MaxPressure, TgtOcc))
511  break;
512 
513  BuildDAG DAG(*R, *this);
514  const auto MinSchedule = makeMinRegSchedule(DAG.getTopRoots(), *this);
515 
516  const auto RP = getSchedulePressure(*R, MinSchedule);
517  DEBUG(if (R->MaxPressure.less(ST, RP, TgtOcc)) {
518  dbgs() << "\nWarning: Pressure becomes worse after minreg!";
519  printSchedRP(dbgs(), R->MaxPressure, RP);
520  });
521 
522  if (!force && MaxPressure.less(ST, RP, TgtOcc))
523  break;
524 
525  scheduleRegion(*R, MinSchedule, RP);
526  DEBUG(printSchedResult(dbgs(), R, RP));
527 
528  MaxPressure = RP;
529  }
530 }
unsigned tryMaximizeOccupancy(unsigned TargetOcc=std::numeric_limits< unsigned >::max())
void enterRegion(MachineBasicBlock *BB, MachineBasicBlock::iterator Begin, MachineBasicBlock::iterator End, unsigned RegionInstrs) override
Implement the ScheduleDAGInstrs interface for handling the next scheduling region.
bool empty() const
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
LLVMContext & Context
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds...
Definition: Compiler.h:449
This is a minimal scheduler strategy.
void sortRegionsByPressure(unsigned TargetOcc)
decltype(MaxPressure) moveMaxPressure()
SpecificBumpPtrAllocator< Region > Alloc
Maximum length of the test input libFuzzer tries to guess a good value based on the corpus and reports it always prefer smaller inputs during the corpus shuffle When libFuzzer itself reports a bug this exit code will be used If indicates the maximal total time in seconds to run the fuzzer minimizes the provided crash input Use with tries to cleanse the provided crash input to make it contain fewer original bytes Use with exact_artifact_path to specify the output Experimental Use value profile to guide fuzzing Number of jobs to run If min(jobs, NumberOfCpuCores()/2)\" is used.") FUZZER_FLAG_INT(reload
MachineInstr * getInstr() const
Returns the representative MachineInstr for this SUnit.
Definition: ScheduleDAG.h:378
std::vector< MachineInstr * > detachSchedule(ScheduleRef Schedule) const
void printRegions(raw_ostream &OS) const
GCNRegPressure getRegionPressure(MachineBasicBlock::iterator Begin, MachineBasicBlock::iterator End) const
std::vector< Region * > Regions
SlotIndex getInstructionIndex(const MachineInstr &Instr) const
Returns the base index of the given instruction.
#define R2(n)
unsigned NumRegionInstrs
Instructions in this region (distance(RegionBegin, RegionEnd)).
ScheduleDAGMI is an implementation of ScheduleDAGInstrs that simply schedules machine instructions ac...
std::unique_ptr< MachineSchedStrategy > SchedImpl
ScheduleDAGMILive is an implementation of ScheduleDAGInstrs that schedules machine instructions while...
MachineFunction & MF
Machine function.
Definition: ScheduleDAG.h:570
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineBasicBlock::iterator RegionEnd
The end of the range to be scheduled.
void finalizeSchedule() override
Allow targets to perform final scheduling actions at the level of the whole MachineFunction.
DbgValueVector DbgValues
Remember instruction that precedes DBG_VALUE.
void printSchedResult(raw_ostream &OS, const Region *R, const GCNRegPressure &RP) const
void scheduleLegacyMaxOccupancy(bool TryMaximizeOccupancy=true)
MachineBasicBlock::iterator RegionBegin
The beginning of the range to be scheduled.
static LLVM_DUMP_METHOD void printLivenessInfo(raw_ostream &OS, MachineBasicBlock::iterator Begin, MachineBasicBlock::iterator End, const LiveIntervals *LIS)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:33
GCNRPTracker::LiveRegSet getLiveRegsBefore(const MachineInstr &MI, const LiveIntervals &LIS)
void collect(const MachineInstr &MI, const TargetRegisterInfo &TRI, const MachineRegisterInfo &MRI, bool TrackLaneMasks, bool IgnoreDead)
Analyze the given instruction MI and fill in the Uses, Defs and DeadDefs list based on the MachineOpe...
static MachineInstr * getMachineInstr(MachineInstr *MI)
List of registers defined and used by a machine instruction.
instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
void print(raw_ostream &OS, const SISubtarget *ST=nullptr) const
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:149
void reset(const MachineInstr &MI, const LiveRegSet *LiveRegs=nullptr)
#define P(N)
void setBestSchedule(Region &R, ScheduleRef Schedule, const GCNRegPressure &MaxRP=GCNRegPressure())
unsigned const MachineRegisterInfo * MRI
std::enable_if<!std::is_array< T >::value, std::unique_ptr< T > >::type make_unique(Args &&...args)
Constructs a new T() with the given args and returns a unique_ptr<T> which owns the object...
Definition: STLExtras.h:943
GCNRegPressure getSchedulePressure(const Region &R, Range &&Schedule) const
const MachineInstr * getLastTrackedMI() const
std::vector< const SUnit * > makeMinRegSchedule(ArrayRef< const SUnit * > TopRoots, const ScheduleDAG &DAG)
static const unsigned End
GCNRPTracker::LiveRegSet getLiveRegsAfter(const MachineInstr &MI, const LiveIntervals &LIS)
void adjustLaneLiveness(const LiveIntervals &LIS, const MachineRegisterInfo &MRI, SlotIndex Pos, MachineInstr *AddFlagsMI=nullptr)
Use liveness information to find out which uses/defs are partially undefined/dead and adjust the Regi...
ArrayRef< const SUnit * > getTopRoots() const
#define B
Definition: LargeTest.cpp:24
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:861
OverrideLegacyStrategy(Region &R, MachineSchedStrategy &OverrideStrategy, GCNIterativeScheduler &_Sch)
void enterRegion(MachineBasicBlock *bb, MachineBasicBlock::iterator begin, MachineBasicBlock::iterator end, unsigned regioninstrs) override
Implement the ScheduleDAGInstrs interface for handling the next scheduling region.
void schedule() override
Implement ScheduleDAGInstrs interface for scheduling a sequence of reorderable instructions.
MachineInstr * remove(MachineInstr *I)
Remove the unbundled instruction from the instruction list without deleting it.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:132
static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, ArrayRef< StringRef > StandardNames)
initialize - Initialize the set of available library functions based on the specified target triple...
const MachineBasicBlock::iterator End
static LLVM_DUMP_METHOD void printRegion(raw_ostream &OS, MachineBasicBlock::iterator Begin, MachineBasicBlock::iterator End, const LiveIntervals *LIS, unsigned MaxInstNum=std::numeric_limits< unsigned >::max())
GCNRegPressure getRegPressure(const MachineRegisterInfo &MRI, Range &&LiveRegs)
Representation of each machine instruction.
Definition: MachineInstr.h:59
BuildDAG(const Region &R, GCNIterativeScheduler &_Sch)
const TargetRegisterInfo * TRI
Target processor register info.
Definition: ScheduleDAG.h:569
#define C
Definition: LargeTest.cpp:25
GCNIterativeScheduler(MachineSchedContext *C, StrategyKind S)
MachineSchedContext provides enough context from the MachineScheduler pass for the target to instanti...
MachineSchedStrategy - Interface to the scheduling algorithm used by ScheduleDAGMI.
#define I(x, y, z)
Definition: MD5.cpp:58
void placeDebugValues()
Reinsert debug_values recorded in ScheduleDAGInstrs::DbgValues.
void scheduleRegion(Region &R, Range &&Schedule, const GCNRegPressure &MaxRP=GCNRegPressure())
SlotIndex getRegSlot(bool EC=false) const
Returns the register use/def slot in the current instruction for a normal or early-clobber def...
Definition: SlotIndexes.h:255
void printSchedRP(raw_ostream &OS, const GCNRegPressure &Before, const GCNRegPressure &After) const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void scheduleMinReg(bool force=false)
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:44
#define DEBUG(X)
Definition: Debug.h:118
MachineBasicBlock * BB
The block in which to insert instructions.
IRTranslator LLVM IR MI
void sort(Policy policy, RandomAccessIterator Start, RandomAccessIterator End, const Comparator &Comp=Comparator())
Definition: Parallel.h:201
MachineRegisterInfo & MRI
Virtual/real register map.
Definition: ScheduleDAG.h:571
auto find_if(R &&Range, UnaryPredicate P) -> decltype(std::begin(Range))
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly...
Definition: STLExtras.h:846
void recede(const MachineInstr &MI)
RegPressureTracker RPTracker
#define D
Definition: LargeTest.cpp:26
std::unique_ptr< TentativeSchedule > BestSchedule
void handleMove(MachineInstr &MI, bool UpdateFlags=false)
Call this method to notify LiveIntervals that instruction MI has been moved within a basic block...
Scheduling unit. This is a node in the scheduling DAG.
Definition: ScheduleDAG.h:247