Skip to content

Commit ba24da9

Browse files
JonPssonJonPsson1
authored andcommitted
-sched-print-pressures
-schedfile -sched-show-ints -regalloc-stats
1 parent 35f4cdb commit ba24da9

File tree

9 files changed

+538
-3
lines changed

9 files changed

+538
-3
lines changed

llvm/include/llvm/CodeGen/MachineScheduler.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,24 @@ class ScheduleDAGMI : public ScheduleDAGInstrs {
411411
/// ScheduleDAGMILive is an implementation of ScheduleDAGInstrs that schedules
412412
/// machine instructions while updating LiveIntervals and tracking regpressure.
413413
class ScheduleDAGMILive : public ScheduleDAGMI {
414+
415+
// Count register overlaps before and after scheduling in order to print
416+
// the difference once per region along with its region ID. Enabled with
417+
// -sched-print-pressures.
418+
struct RegOverlaps {
419+
int GPR;
420+
int FP;
421+
int GPRMax;
422+
int FPMax;
423+
RegOverlaps() : GPR(0), FP(0), GPRMax(0), FPMax(0) {}
424+
};
425+
void countRegOverlaps(RegOverlaps &RO, MachineBasicBlock::iterator FirstItr,
426+
MachineBasicBlock::iterator EndItr) const;
427+
428+
// Show liveness visually of registers before and after scheduling. Enabled
429+
// with -sched-show-ints and -misched-only-block=NUM.
430+
void showIntervals(std::string Msg, std::string I, MachineBasicBlock *MBB) const;
431+
414432
protected:
415433
RegisterClassInfo *RegClassInfo;
416434

@@ -1197,8 +1215,10 @@ class GenericSchedulerBase : public MachineSchedStrategy {
11971215
const TargetSchedModel *SchedModel = nullptr;
11981216
const TargetRegisterInfo *TRI = nullptr;
11991217

1218+
public:
12001219
MachineSchedPolicy RegionPolicy;
12011220

1221+
protected:
12021222
SchedRemainder Rem;
12031223

12041224
GenericSchedulerBase(const MachineSchedContext *C) : Context(C) {}

llvm/include/llvm/CodeGen/ScheduleDAGInstrs.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,9 @@ namespace llvm {
396396

397397
/// Returns true if the def register in \p MO has no uses.
398398
bool deadDefHasNoUse(const MachineOperand &MO);
399+
400+
public:
401+
unsigned CurrRegionIdx;
399402
};
400403

401404
/// Creates a new SUnit and return a ptr to it.

llvm/include/llvm/CodeGen/SlotIndexes.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,11 @@ class raw_ostream;
9696
return lie.getPointer();
9797
}
9898

99+
public:
99100
unsigned getIndex() const {
100101
return listEntry()->getIndex() | getSlot();
101102
}
103+
private:
102104

103105
/// Returns the slot for this SlotIndex.
104106
Slot getSlot() const {

llvm/include/llvm/CodeGen/TargetRegisterInfo.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "llvm/Support/Printable.h"
3030
#include <cassert>
3131
#include <cstdint>
32+
#include <set>
3233

3334
namespace llvm {
3435

@@ -955,6 +956,20 @@ class TargetRegisterInfo : public MCRegisterInfo {
955956
/// Returns a -1 terminated array of pressure set IDs.
956957
virtual const int *getRegUnitPressureSets(unsigned RegUnit) const = 0;
957958

959+
/// EXPERIMENTAL: return true if Reg belongs to a prio (FP) register class.
960+
/// Add some target specific methods to increase precision in counting of
961+
/// live FP/GPR regs.
962+
private:
963+
mutable std::set<unsigned> PrioRegClasses;
964+
void initializePrioRegClasses() const;
965+
public:
966+
bool isPrioRC(unsigned RegClassID) const;
967+
bool isPrioVirtReg(Register Reg, const MachineRegisterInfo *MRI) const;
968+
virtual unsigned getRCCountFactor(unsigned RegClassID) const { return 1; }
969+
virtual bool isGPRLoRC(unsigned RegClassID) const { return false; }
970+
virtual bool isGPRHiRC(unsigned RegClassID) const { return false; }
971+
virtual bool isGPRLoHiRC(unsigned RegClassID) const { return false; }
972+
958973
/// Get the scale factor of spill weight for this register class.
959974
virtual float getSpillWeightScaleFactor(const TargetRegisterClass *RC) const;
960975

0 commit comments

Comments
 (0)