[llvm] [MISched] Add a hook to override PostRA scheduling policy (PR #115455)

Jon Roelofs via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 9 08:25:29 PST 2024


================
@@ -3897,6 +3897,12 @@ void PostGenericScheduler::initialize(ScheduleDAGMI *Dag) {
 void PostGenericScheduler::initPolicy(MachineBasicBlock::iterator Begin,
                                       MachineBasicBlock::iterator End,
                                       unsigned NumRegionInstrs) {
+  const MachineFunction &MF = *Begin->getMF();
+
+  // Allow the subtarget to override default policy.
+  MF.getSubtarget().overridePostRASchedPolicy(RegionPolicy, NumRegionInstrs);
+
+  // After subtarget overrides, apply command line options.
   if (PostRADirection == MISchedPostRASched::TopDown) {
     RegionPolicy.OnlyTopDown = true;
     RegionPolicy.OnlyBottomUp = false;
----------------
jroelofs wrote:

This always overrides what the subtarget wanted for these two members because `PostRADirection` defaults to `TopDown`. Maybe add a `getNumOccurrences()` check, or make the direction enum have an explicit default entry?

https://github.com/llvm/llvm-project/pull/115455


More information about the llvm-commits mailing list