From 6bcbb3af059b05056c7343cafd99004d4cd4cd35 Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Wed, 31 May 2023 14:22:44 +0100 Subject: [PATCH] [ConstraintElim] Move logic to remove stack entry to helper (NFC). Preparation for follow-up patch that uses the logic in a separate place. --- .../Transforms/Scalar/ConstraintElimination.cpp | 28 ++++++++++++++-------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp index 71d3fda..b519c37 100644 --- a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp +++ b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp @@ -987,6 +987,22 @@ static bool checkAndReplaceCondition( return Changed; } +static void +removeEntryFromStack(const StackEntry &E, ConstraintInfo &Info, + Module *ReproducerModule, + SmallVectorImpl &ReproducerCondStack, + SmallVectorImpl &DFSInStack) { + Info.popLastConstraint(E.IsSigned); + // Remove variables in the system that went out of scope. + auto &Mapping = Info.getValue2Index(E.IsSigned); + for (Value *V : E.ValuesToRelease) + Mapping.erase(V); + Info.popLastNVariables(E.IsSigned, E.ValuesToRelease.size()); + DFSInStack.pop_back(); + if (ReproducerModule) + ReproducerCondStack.pop_back(); +} + void ConstraintInfo::addFact(CmpInst::Predicate Pred, Value *A, Value *B, unsigned NumIn, unsigned NumOut, SmallVectorImpl &DFSInStack) { @@ -1170,16 +1186,8 @@ static bool eliminateConstraints(Function &F, DominatorTree &DT, Info.getValue2Index(E.IsSigned)); dbgs() << "\n"; }); - - Info.popLastConstraint(E.IsSigned); - // Remove variables in the system that went out of scope. - auto &Mapping = Info.getValue2Index(E.IsSigned); - for (Value *V : E.ValuesToRelease) - Mapping.erase(V); - Info.popLastNVariables(E.IsSigned, E.ValuesToRelease.size()); - DFSInStack.pop_back(); - if (ReproducerModule) - ReproducerCondStack.pop_back(); + removeEntryFromStack(E, Info, ReproducerModule.get(), ReproducerCondStack, + DFSInStack); } LLVM_DEBUG({ -- 2.7.4