TailDuplication: Record blocks that received the duplicated block. NFC.

This will allow tail duplication during layout to handle the cfg changes more
cleanly.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279858 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Kyle Butt 2016-08-26 20:12:40 +00:00
parent 7921d70074
commit db440c8640
2 changed files with 17 additions and 3 deletions

View File

@ -57,7 +57,13 @@ public:
bool shouldTailDuplicate(bool IsSimple, MachineBasicBlock &TailBB);
/// Returns true if TailBB can successfully be duplicated into PredBB
bool canTailDuplicate(MachineBasicBlock *TailBB, MachineBasicBlock *PredBB);
bool tailDuplicateAndUpdate(bool IsSimple, MachineBasicBlock *MBB);
/// Tail duplicate a single basic block into its predecessors, and then clean
/// up.
/// If \p DuplicatePreds is not null, it will be updated to contain the list
/// of predecessors that received a copy of \p MBB.
bool tailDuplicateAndUpdate(
bool IsSimple, MachineBasicBlock *MBB,
SmallVectorImpl<MachineBasicBlock*> *DuplicatedPreds = nullptr);
private:
typedef TargetInstrInfo::RegSubRegPair RegSubRegPair;

View File

@ -119,8 +119,13 @@ static void VerifyPHIs(MachineFunction &MF, bool CheckExtra) {
}
/// Tail duplicate the block and cleanup.
bool TailDuplicator::tailDuplicateAndUpdate(bool IsSimple,
MachineBasicBlock *MBB) {
/// \p IsSimple - return value of isSimpleBB
/// \p MBB - block to be duplicated
/// \p DuplicatedPreds - if non-null, \p DuplicatedPreds will contain a list of
/// all Preds that received a copy of \p MBB.
bool TailDuplicator::tailDuplicateAndUpdate(
bool IsSimple, MachineBasicBlock *MBB,
SmallVectorImpl<MachineBasicBlock*> *DuplicatedPreds) {
// Save the successors list.
SmallSetVector<MachineBasicBlock *, 8> Succs(MBB->succ_begin(),
MBB->succ_end());
@ -216,6 +221,9 @@ bool TailDuplicator::tailDuplicateAndUpdate(bool IsSimple,
if (NewPHIs.size())
NumAddedPHIs += NewPHIs.size();
if (DuplicatedPreds)
*DuplicatedPreds = std::move(TDBBs);
return true;
}