[llvm] 1b37e80 - [VPlan] use getVPValueOrAddLiveIn in VPlan::duplicate.

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 28 04:39:51 PST 2024


Author: Florian Hahn
Date: 2024-01-28T12:39:39Z
New Revision: 1b37e8087e1e1ecf5aadd8da536ee17dc21832e2

URL: https://github.com/llvm/llvm-project/commit/1b37e8087e1e1ecf5aadd8da536ee17dc21832e2
DIFF: https://github.com/llvm/llvm-project/commit/1b37e8087e1e1ecf5aadd8da536ee17dc21832e2.diff

LOG: [VPlan] use getVPValueOrAddLiveIn in VPlan::duplicate.

Instead of creating live-ins manually, use getOrAddLiveIn which
automatically takes care of adding them to VPLiveInsToFree. Also use it
to create the VPValue for the trip-count. This fixes a leak:
https://lab.llvm.org/buildbot/#/builders/168/builds/18308/steps/10/logs/stdio

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Vectorize/VPlan.cpp b/llvm/lib/Transforms/Vectorize/VPlan.cpp
index b7ff1e1af65ac18..a1bd6aaf0e5512a 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlan.cpp
@@ -1078,9 +1078,8 @@ VPlan *VPlan::duplicate() {
   auto *NewPlan = new VPlan(NewPreheader, cast<VPBasicBlock>(NewEntry));
   DenseMap<VPValue *, VPValue *> Old2NewVPValues;
   for (VPValue *OldLiveIn : VPLiveInsToFree) {
-    VPValue *NewLiveIn = new VPValue(OldLiveIn->getLiveInIRValue());
-    NewPlan->VPLiveInsToFree.push_back(NewLiveIn);
-    Old2NewVPValues[OldLiveIn] = NewLiveIn;
+    Old2NewVPValues[OldLiveIn] =
+        NewPlan->getVPValueOrAddLiveIn(OldLiveIn->getLiveInIRValue());
   }
   Old2NewVPValues[&VectorTripCount] = &NewPlan->VectorTripCount;
   Old2NewVPValues[&VFxUF] = &NewPlan->VFxUF;
@@ -1090,7 +1089,8 @@ VPlan *VPlan::duplicate() {
   }
   assert(TripCount && "trip count must be set");
   if (TripCount->isLiveIn())
-    Old2NewVPValues[TripCount] = new VPValue(TripCount->getLiveInIRValue());
+    Old2NewVPValues[TripCount] =
+        NewPlan->getVPValueOrAddLiveIn(TripCount->getLiveInIRValue());
   // else NewTripCount will be created and inserted into Old2NewVPValues when
   // TripCount is cloned. In any case NewPlan->TripCount is updated below.
 


        


More information about the llvm-commits mailing list