Index: llvm/include/llvm/CodeGen/ModuloSchedule.h =================================================================== --- llvm/include/llvm/CodeGen/ModuloSchedule.h +++ llvm/include/llvm/CodeGen/ModuloSchedule.h @@ -277,6 +277,19 @@ /// A reimplementation of ModuloScheduleExpander. It works by generating a /// standalone kernel loop and peeling out the prologs and epilogs. class PeelingModuloScheduleExpander { +public: + PeelingModuloScheduleExpander(MachineFunction &MF, ModuloSchedule &S, + LiveIntervals *LIS) + : Schedule(S), MF(MF), ST(MF.getSubtarget()), MRI(MF.getRegInfo()), + TII(ST.getInstrInfo()), LIS(LIS) {} + + virtual void expand(); + + /// Runs ModuloScheduleExpander and treats it as a golden input to validate + /// aspects of the code generated by PeelingModuloScheduleExpander. + void validateAgainstModuloScheduleExpander(); + +protected: ModuloSchedule &Schedule; MachineFunction &MF; const TargetSubtargetInfo &ST; @@ -311,24 +324,10 @@ /// Illegal phis that need to be deleted once we re-link stages. SmallVector IllegalPhisToDelete; -public: - PeelingModuloScheduleExpander(MachineFunction &MF, ModuloSchedule &S, - LiveIntervals *LIS) - : Schedule(S), MF(MF), ST(MF.getSubtarget()), MRI(MF.getRegInfo()), - TII(ST.getInstrInfo()), LIS(LIS) {} - - void expand(); - - /// Runs ModuloScheduleExpander and treats it as a golden input to validate - /// aspects of the code generated by PeelingModuloScheduleExpander. - void validateAgainstModuloScheduleExpander(); - -protected: /// Converts BB from the original loop body to the rewritten, pipelined /// steady-state. void rewriteKernel(); -private: /// Peels one iteration of the rewritten kernel (BB) in the specified /// direction. MachineBasicBlock *peelKernel(LoopPeelDirection LPD); @@ -364,7 +363,7 @@ /// coming from a peeled out prologue. Register getPhiCanonicalReg(MachineInstr* CanonicalPhi, MachineInstr* Phi); /// Target loop info before kernel peeling. - std::unique_ptr Info; + std::unique_ptr LoopInfo; }; /// Expander that simply annotates each scheduled instruction with a post-instr Index: llvm/lib/CodeGen/ModuloSchedule.cpp =================================================================== --- llvm/lib/CodeGen/ModuloSchedule.cpp +++ llvm/lib/CodeGen/ModuloSchedule.cpp @@ -1947,7 +1947,7 @@ SmallVector Cond; TII->removeBranch(*Prolog); Optional StaticallyGreater = - Info->createTripCountGreaterCondition(TC, *Prolog, Cond); + LoopInfo->createTripCountGreaterCondition(TC, *Prolog, Cond); if (!StaticallyGreater.hasValue()) { LLVM_DEBUG(dbgs() << "Dynamic: TC > " << TC << "\n"); // Dynamically branch based on Cond. @@ -1975,10 +1975,10 @@ } if (!KernelDisposed) { - Info->adjustTripCount(-(Schedule.getNumStages() - 1)); - Info->setPreheader(Prologs.back()); + LoopInfo->adjustTripCount(-(Schedule.getNumStages() - 1)); + LoopInfo->setPreheader(Prologs.back()); } else { - Info->disposed(); + LoopInfo->disposed(); } } @@ -1991,8 +1991,8 @@ BB = Schedule.getLoop()->getTopBlock(); Preheader = Schedule.getLoop()->getLoopPreheader(); LLVM_DEBUG(Schedule.dump()); - Info = TII->analyzeLoopForPipelining(BB); - assert(Info); + LoopInfo = TII->analyzeLoopForPipelining(BB); + assert(LoopInfo); rewriteKernel(); peelPrologAndEpilogs();