[libcxx] [lld] [clang-tools-extra] [libc] [compiler-rt] [llvm] [lldb] [flang] [clang] [VPlan] Implement cloning of VPlans. (PR #73158)

Florian Hahn via cfe-commits cfe-commits at lists.llvm.org
Sun Jan 21 04:44:47 PST 2024


================
@@ -1200,6 +1271,59 @@ void VPUser::printOperands(raw_ostream &O, VPSlotTracker &SlotTracker) const {
 }
 #endif
 
+VPBlockBase *VPBlockUtils::cloneCFG(
+    VPBlockBase *Entry, DenseMap<VPBlockBase *, VPBlockBase *> &Old2New,
+    DenseMap<VPValue *, VPValue *> &Old2NewVPValues, bool FullRemapping) {
+  ReversePostOrderTraversal<VPBlockShallowTraversalWrapper<VPBlockBase *>> RPOT(
+      Entry);
+  VPBlockBase *NewEntry = nullptr;
+  for (VPBlockBase *BB : RPOT) {
+    VPBlockBase *NewBB = BB->clone();
+    if (!NewEntry)
+      NewEntry = NewBB;
+
+    for (VPBlockBase *Pred : BB->getPredecessors())
+      connectBlocks(Old2New[Pred], NewBB);
----------------
fhahn wrote:

Added asserts checking successors/predecessors after cloning the CFG, thanks!

https://github.com/llvm/llvm-project/pull/73158


More information about the cfe-commits mailing list