[llvm] r248227 - [SCEV] Use SaveAndRestore<T> instead of a hand rolled struct; NFCI.

Sanjoy Das via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 21 17:10:57 PDT 2015


Author: sanjoy
Date: Mon Sep 21 19:10:57 2015
New Revision: 248227

URL: http://llvm.org/viewvc/llvm-project?rev=248227&view=rev
Log:
[SCEV] Use SaveAndRestore<T> instead of a hand rolled struct; NFCI.

`ClearWalkingBEDominatingCondsOnExit` is exactly `SaveAndRestore<bool>`,
so use `SaveAndRestore<bool>` instead.

Modified:
    llvm/trunk/lib/Analysis/ScalarEvolution.cpp

Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=248227&r1=248226&r2=248227&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original)
+++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Mon Sep 21 19:10:57 2015
@@ -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::isLoopBackedgeGuardedBy
                     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()) {




More information about the llvm-commits mailing list