[llvm] f276ad4 - [VPlan] Make sure Inductions outlive returned VPlan.
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 19 14:02:55 PDT 2026
Author: Florian Hahn
Date: 2026-03-19T21:02:26Z
New Revision: f276ad429091cb1353ce1348afbfe3d59ac652a7
URL: https://github.com/llvm/llvm-project/commit/f276ad429091cb1353ce1348afbfe3d59ac652a7
DIFF: https://github.com/llvm/llvm-project/commit/f276ad429091cb1353ce1348afbfe3d59ac652a7.diff
LOG: [VPlan] Make sure Inductions outlive returned VPlan.
Move Inductions to VPlanTestBase, to make sure it outlives
VPlanTestBase::getPlan(). Fixes a use-after-free issue.
Added:
Modified:
llvm/unittests/Transforms/Vectorize/VPlanTestBase.h
Removed:
################################################################################
diff --git a/llvm/unittests/Transforms/Vectorize/VPlanTestBase.h b/llvm/unittests/Transforms/Vectorize/VPlanTestBase.h
index 68fc8e045bc98..a4bbf6cbd9056 100644
--- a/llvm/unittests/Transforms/Vectorize/VPlanTestBase.h
+++ b/llvm/unittests/Transforms/Vectorize/VPlanTestBase.h
@@ -43,6 +43,8 @@ class VPlanTestIRBase : public testing::Test {
std::unique_ptr<TargetLibraryInfoImpl> TLII;
std::unique_ptr<TargetLibraryInfo> TLI;
+ MapVector<PHINode *, InductionDescriptor> Inductions;
+
VPlanTestIRBase()
: DL("e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-"
"f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:"
@@ -79,8 +81,8 @@ class VPlanTestIRBase : public testing::Test {
{}, PSE);
if (Style != UncountableExitStyle::NoUncountableExit) {
+ Inductions.clear();
// handleEarlyExits requires induction phi recipes.
- MapVector<PHINode *, InductionDescriptor> Inductions;
for (PHINode &Phi : LoopHeader->phis()) {
InductionDescriptor ID;
if (InductionDescriptor::isInductionPHI(&Phi, L, PSE, ID))
More information about the llvm-commits
mailing list