Skip to content

Commit

Permalink
Simplify enablePostRAScheduler and test enablePostRAScheduler() early
Browse files Browse the repository at this point in the history
  • Loading branch information
MaskRay committed Dec 29, 2024
1 parent 1557eed commit 66dd7e6
Showing 1 changed file with 12 additions and 27 deletions.
39 changes: 12 additions & 27 deletions llvm/lib/CodeGen/PostRASchedulerList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,6 @@ namespace {
}

bool runOnMachineFunction(MachineFunction &Fn) override;

private:
bool enablePostRAScheduler(
const TargetSubtargetInfo &ST, CodeGenOptLevel OptLevel,
TargetSubtargetInfo::AntiDepBreakMode &Mode,
TargetSubtargetInfo::RegClassVector &CriticalPathRCs) const;
};
char PostRAScheduler::ID = 0;

Expand Down Expand Up @@ -259,13 +253,8 @@ LLVM_DUMP_METHOD void SchedulePostRATDList::dumpSchedule() const {
}
#endif

bool PostRAScheduler::enablePostRAScheduler(
const TargetSubtargetInfo &ST, CodeGenOptLevel OptLevel,
TargetSubtargetInfo::AntiDepBreakMode &Mode,
TargetSubtargetInfo::RegClassVector &CriticalPathRCs) const {
Mode = ST.getAntiDepBreakMode();
ST.getCriticalPathRCs(CriticalPathRCs);

static bool enablePostRAScheduler(const TargetSubtargetInfo &ST,
CodeGenOptLevel OptLevel) {
// Check for explicit enable/disable of post-ra scheduling.
if (EnablePostRAScheduler.getPosition() > 0)
return EnablePostRAScheduler;
Expand All @@ -278,31 +267,27 @@ bool PostRAScheduler::runOnMachineFunction(MachineFunction &Fn) {
if (skipFunction(Fn.getFunction()))
return false;

TII = Fn.getSubtarget().getInstrInfo();
MachineLoopInfo &MLI = getAnalysis<MachineLoopInfoWrapperPass>().getLI();
AliasAnalysis *AA = &getAnalysis<AAResultsWrapperPass>().getAAResults();
const auto &Subtarget = Fn.getSubtarget();
TargetPassConfig *PassConfig = &getAnalysis<TargetPassConfig>();

RegClassInfo.runOnMachineFunction(Fn);

TargetSubtargetInfo::AntiDepBreakMode AntiDepMode =
TargetSubtargetInfo::ANTIDEP_NONE;
SmallVector<const TargetRegisterClass*, 4> CriticalPathRCs;

// Check that post-RA scheduling is enabled for this target.
// This may upgrade the AntiDepMode.
if (!enablePostRAScheduler(Fn.getSubtarget(), PassConfig->getOptLevel(),
AntiDepMode, CriticalPathRCs))
if (!enablePostRAScheduler(Subtarget, PassConfig->getOptLevel()))
return false;

// Check for antidep breaking override...
TII = Subtarget.getInstrInfo();
MachineLoopInfo &MLI = getAnalysis<MachineLoopInfoWrapperPass>().getLI();
AliasAnalysis *AA = &getAnalysis<AAResultsWrapperPass>().getAAResults();
TargetSubtargetInfo::AntiDepBreakMode AntiDepMode =
Subtarget.getAntiDepBreakMode();
if (EnableAntiDepBreaking.getPosition() > 0) {
AntiDepMode = (EnableAntiDepBreaking == "all")
? TargetSubtargetInfo::ANTIDEP_ALL
: ((EnableAntiDepBreaking == "critical")
? TargetSubtargetInfo::ANTIDEP_CRITICAL
: TargetSubtargetInfo::ANTIDEP_NONE);
}
SmallVector<const TargetRegisterClass *, 4> CriticalPathRCs;
Subtarget.getCriticalPathRCs(CriticalPathRCs);
RegClassInfo.runOnMachineFunction(Fn);

LLVM_DEBUG(dbgs() << "PostRAScheduler\n");

Expand Down

0 comments on commit 66dd7e6

Please sign in to comment.