1010#include " llvm/ADT/StringExtras.h"
1111#include " llvm/Analysis/MemoryLocation.h"
1212#include " llvm/CodeGen/LiveIntervals.h"
13+ #include " llvm/CodeGen/MachineBasicBlock.h"
1314#include " llvm/CodeGen/MachineInstrBuilder.h"
1415#include " llvm/CodeGen/MachineLoopInfo.h"
1516#include " llvm/CodeGen/MachineRegisterInfo.h"
@@ -859,20 +860,6 @@ void ModuloScheduleExpander::splitLifetimes(MachineBasicBlock *KernelBB,
859860 }
860861}
861862
862- // / Remove the incoming block from the Phis in a basic block.
863- static void removePhis (MachineBasicBlock *BB, MachineBasicBlock *Incoming) {
864- for (MachineInstr &MI : *BB) {
865- if (!MI.isPHI ())
866- break ;
867- for (unsigned i = 1 , e = MI.getNumOperands (); i != e; i += 2 )
868- if (MI.getOperand (i + 1 ).getMBB () == Incoming) {
869- MI.removeOperand (i + 1 );
870- MI.removeOperand (i);
871- break ;
872- }
873- }
874- }
875-
876863// / Create branches from each prolog basic block to the appropriate epilog
877864// / block. These edges are needed if the loop ends before reaching the
878865// / kernel.
@@ -906,7 +893,7 @@ void ModuloScheduleExpander::addBranches(MachineBasicBlock &PreheaderBB,
906893 Prolog->removeSuccessor (LastPro);
907894 LastEpi->removeSuccessor (Epilog);
908895 numAdded = TII->insertBranch (*Prolog, Epilog, nullptr , Cond, DebugLoc ());
909- removePhis ( Epilog, LastEpi);
896+ Epilog-> removePHIsIncomingValuesForPredecessor (* LastEpi);
910897 // Remove the blocks that are no longer referenced.
911898 if (LastPro != LastEpi) {
912899 for (auto &MI : *LastEpi)
@@ -924,7 +911,7 @@ void ModuloScheduleExpander::addBranches(MachineBasicBlock &PreheaderBB,
924911 LastPro->eraseFromParent ();
925912 } else {
926913 numAdded = TII->insertBranch (*Prolog, LastPro, nullptr , Cond, DebugLoc ());
927- removePhis ( Epilog, Prolog);
914+ Epilog-> removePHIsIncomingValuesForPredecessor (* Prolog);
928915 }
929916 LastPro = Prolog;
930917 LastEpi = Epilog;
0 commit comments