Index: include/llvm/Target/TargetSubtargetInfo.h =================================================================== --- include/llvm/Target/TargetSubtargetInfo.h +++ include/llvm/Target/TargetSubtargetInfo.h @@ -135,6 +135,14 @@ /// which is the preferred way to influence this. virtual bool enablePostRAScheduler() const; + /// True if subtarget inserts the final scheduling pass on its own + /// instead of returning true in enablePostRAScheduler(). + /// + /// Branch relaxation, which must happen after block placement, can + /// on some targets (e.g. SystemZ) expose additional post-RA + /// scheduling opportunities. + virtual bool targetSchedulesPostRAScheduling() const { return false;}; + /// \brief True if the subtarget should run the atomic expansion pass. virtual bool enableAtomicExpand() const; Index: lib/CodeGen/MachineScheduler.cpp =================================================================== --- lib/CodeGen/MachineScheduler.cpp +++ lib/CodeGen/MachineScheduler.cpp @@ -352,7 +352,8 @@ if (skipOptnoneFunction(*mf.getFunction())) return false; - if (!mf.getSubtarget().enablePostRAScheduler()) { + if (!mf.getSubtarget().enablePostRAScheduler() && + !mf.getSubtarget().targetSchedulesPostRAScheduling()) { DEBUG(dbgs() << "Subtarget disables post-MI-sched.\n"); return false; }