[llvm] 74af9c3 - [VPlan] Consolidate VPRegionBlock constructors (NFC).

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 14 13:19:55 PDT 2026


Author: Florian Hahn
Date: 2026-03-14T20:18:25Z
New Revision: 74af9c3252cb1d04ddc32273f8f16fdc53a39de1

URL: https://github.com/llvm/llvm-project/commit/74af9c3252cb1d04ddc32273f8f16fdc53a39de1
DIFF: https://github.com/llvm/llvm-project/commit/74af9c3252cb1d04ddc32273f8f16fdc53a39de1.diff

LOG: [VPlan] Consolidate VPRegionBlock constructors (NFC).

Unify VPRegionBlock constructors into a single one, in preparation for
https://github.com/llvm/llvm-project/pull/156262. Split off as
suggested.

Added: 
    

Modified: 
    llvm/lib/Transforms/Vectorize/VPlan.h

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h
index 35fa8a2aff352..80df058dfcf66 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -4443,14 +4443,14 @@ class LLVM_ABI_FOR_TEST VPRegionBlock : public VPBlockBase {
                 const std::string &Name = "", bool IsReplicator = false)
       : VPBlockBase(VPRegionBlockSC, Name), Entry(Entry), Exiting(Exiting),
         IsReplicator(IsReplicator) {
-    assert(!Entry->hasPredecessors() && "Entry block has predecessors.");
-    assert(!Exiting->hasSuccessors() && "Exit block has successors.");
-    Entry->setParent(this);
-    Exiting->setParent(this);
+    if (Entry) {
+      assert(!Entry->hasPredecessors() && "Entry block has predecessors.");
+      assert(Exiting && "Must also pass Exiting if Entry is passed.");
+      assert(!Exiting->hasSuccessors() && "Exit block has successors.");
+      Entry->setParent(this);
+      Exiting->setParent(this);
+    }
   }
-  VPRegionBlock(const std::string &Name = "", bool IsReplicator = false)
-      : VPBlockBase(VPRegionBlockSC, Name), Entry(nullptr), Exiting(nullptr),
-        IsReplicator(IsReplicator) {}
 
 public:
   ~VPRegionBlock() override = default;
@@ -4901,8 +4901,7 @@ class VPlan {
   VPRegionBlock *createLoopRegion(const std::string &Name = "",
                                   VPBlockBase *Entry = nullptr,
                                   VPBlockBase *Exiting = nullptr) {
-    auto *VPB = Entry ? new VPRegionBlock(Entry, Exiting, Name)
-                      : new VPRegionBlock(Name);
+    auto *VPB = new VPRegionBlock(Entry, Exiting, Name);
     CreatedBlocks.push_back(VPB);
     return VPB;
   }


        


More information about the llvm-commits mailing list