[llvm] 6bcbb3a - [ConstraintElim] Move logic to remove stack entry to helper (NFC).

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Wed May 31 06:23:04 PDT 2023


Author: Florian Hahn
Date: 2023-05-31T14:22:45+01:00
New Revision: 6bcbb3af059b05056c7343cafd99004d4cd4cd35

URL: https://github.com/llvm/llvm-project/commit/6bcbb3af059b05056c7343cafd99004d4cd4cd35
DIFF: https://github.com/llvm/llvm-project/commit/6bcbb3af059b05056c7343cafd99004d4cd4cd35.diff

LOG: [ConstraintElim] Move logic to remove stack entry to helper (NFC).

Preparation for follow-up patch that uses the logic in a separate place.

Added: 
    

Modified: 
    llvm/lib/Transforms/Scalar/ConstraintElimination.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
index 71d3fda429bf..b519c374a4e8 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<ReproducerEntry> &ReproducerCondStack,
+                     SmallVectorImpl<StackEntry> &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<StackEntry> &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({


        


More information about the llvm-commits mailing list