[llvm] r279858 - TailDuplication: Record blocks that received the duplicated block. NFC.

Kyle Butt via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 26 13:12:40 PDT 2016


Author: iteratee
Date: Fri Aug 26 15:12:40 2016
New Revision: 279858

URL: http://llvm.org/viewvc/llvm-project?rev=279858&view=rev
Log:
TailDuplication: Record blocks that received the duplicated block. NFC.

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

Modified:
    llvm/trunk/include/llvm/CodeGen/TailDuplicator.h
    llvm/trunk/lib/CodeGen/TailDuplicator.cpp

Modified: llvm/trunk/include/llvm/CodeGen/TailDuplicator.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/TailDuplicator.h?rev=279858&r1=279857&r2=279858&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/TailDuplicator.h (original)
+++ llvm/trunk/include/llvm/CodeGen/TailDuplicator.h Fri Aug 26 15:12:40 2016
@@ -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;

Modified: llvm/trunk/lib/CodeGen/TailDuplicator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TailDuplicator.cpp?rev=279858&r1=279857&r2=279858&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/TailDuplicator.cpp (original)
+++ llvm/trunk/lib/CodeGen/TailDuplicator.cpp Fri Aug 26 15:12:40 2016
@@ -119,8 +119,13 @@ static void VerifyPHIs(MachineFunction &
 }
 
 /// 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::tailDuplicateAndUpd
   if (NewPHIs.size())
     NumAddedPHIs += NewPHIs.size();
 
+  if (DuplicatedPreds)
+    *DuplicatedPreds = std::move(TDBBs);
+
   return true;
 }
 




More information about the llvm-commits mailing list