[SCEV] Use SaveAndRestore<T> instead of a hand rolled struct; NFCI.
authorSanjoy Das <sanjoy@playingwithpointers.com>
Tue, 22 Sep 2015 00:10:57 +0000 (00:10 +0000)
committerSanjoy Das <sanjoy@playingwithpointers.com>
Tue, 22 Sep 2015 00:10:57 +0000 (00:10 +0000)
`ClearWalkingBEDominatingCondsOnExit` is exactly `SaveAndRestore<bool>`,
so use `SaveAndRestore<bool>` instead.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@248227 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/ScalarEvolution.cpp

index 262280c8a9c007b2d3cdc0d052b913249bff5d58..df1e3eb183a1c10e2760f1c03eae9176060ab3d4 100644 (file)
@@ -88,6 +88,7 @@
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/MathExtras.h"
 #include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/SaveAndRestore.h"
 #include <algorithm>
 using namespace llvm;
 
@@ -6987,24 +6988,12 @@ ScalarEvolution::isLoopBackedgeGuardedByCond(const Loop *L,
                     LoopContinuePredicate->getSuccessor(0) != L->getHeader()))
     return true;
 
-  struct ClearWalkingBEDominatingCondsOnExit {
-    ScalarEvolution &SE;
-
-    explicit ClearWalkingBEDominatingCondsOnExit(ScalarEvolution &SE)
-        : SE(SE){}
-
-    ~ClearWalkingBEDominatingCondsOnExit() {
-      SE.WalkingBEDominatingConds = false;
-    }
-  };
-
   // We don't want more than one activation of the following loops on the stack
   // -- that can lead to O(n!) time complexity.
   if (WalkingBEDominatingConds)
     return false;
 
-  WalkingBEDominatingConds = true;
-  ClearWalkingBEDominatingCondsOnExit ClearOnExit(*this);
+  SaveAndRestore<bool> ClearOnExit(WalkingBEDominatingConds, true);
 
   // Check conditions due to any @llvm.assume intrinsics.
   for (auto &AssumeVH : AC.assumptions()) {