summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKyle Butt <kyle+llvm@iteratee.net>2016-08-26 20:12:40 +0000
committerKyle Butt <kyle+llvm@iteratee.net>2016-08-26 20:12:40 +0000
commit723aa1327c653847158b39c87180ffb149b2b351 (patch)
treecf14f22acce99d2dc694bf27b573733c84b36bf6
parentc527a49b98848424b39cdc8ee70375d68a3ec760 (diff)
downloadbcm5719-llvm-723aa1327c653847158b39c87180ffb149b2b351.tar.gz
bcm5719-llvm-723aa1327c653847158b39c87180ffb149b2b351.zip
TailDuplication: Record blocks that received the duplicated block. NFC.
This will allow tail duplication during layout to handle the cfg changes more cleanly. llvm-svn: 279858
-rw-r--r--llvm/include/llvm/CodeGen/TailDuplicator.h8
-rw-r--r--llvm/lib/CodeGen/TailDuplicator.cpp12
2 files changed, 17 insertions, 3 deletions
diff --git a/llvm/include/llvm/CodeGen/TailDuplicator.h b/llvm/include/llvm/CodeGen/TailDuplicator.h
index 03fd4997794..cd13627f787 100644
--- a/llvm/include/llvm/CodeGen/TailDuplicator.h
+++ b/llvm/include/llvm/CodeGen/TailDuplicator.h
@@ -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;
diff --git a/llvm/lib/CodeGen/TailDuplicator.cpp b/llvm/lib/CodeGen/TailDuplicator.cpp
index bf3379eb576..a27e38d2d7d 100644
--- a/llvm/lib/CodeGen/TailDuplicator.cpp
+++ b/llvm/lib/CodeGen/TailDuplicator.cpp
@@ -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;
}
OpenPOWER on IntegriCloud