summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis
diff options
context:
space:
mode:
authorSanjoy Das <sanjoy@playingwithpointers.com>2016-09-27 18:01:42 +0000
committerSanjoy Das <sanjoy@playingwithpointers.com>2016-09-27 18:01:42 +0000
commitc46bceb6323b1e3dd6d6e81838629c198cd2fa59 (patch)
tree1836d66e0e368018975b32c55f6967d554a3143c /llvm/lib/Analysis
parentdb93375711ad7dacd33541dddd7ef31a11cda7d9 (diff)
downloadbcm5719-llvm-c46bceb6323b1e3dd6d6e81838629c198cd2fa59.tar.gz
bcm5719-llvm-c46bceb6323b1e3dd6d6e81838629c198cd2fa59.zip
[SCEV] Remove custom RAII wrapper; NFC
Instead use the pre-existing `scope_exit` class. llvm-svn: 282512
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r--llvm/lib/Analysis/ScalarEvolution.cpp27
1 files changed, 5 insertions, 22 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 038204e8839..401e736396d 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -61,6 +61,7 @@
#include "llvm/Analysis/ScalarEvolution.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/ScopeExit.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/AssumptionCache.h"
@@ -8058,34 +8059,16 @@ ScalarEvolution::isLoopEntryGuardedByCond(const Loop *L,
return false;
}
-namespace {
-/// RAII wrapper to prevent recursive application of isImpliedCond.
-/// ScalarEvolution's PendingLoopPredicates set must be empty unless we are
-/// currently evaluating isImpliedCond.
-struct MarkPendingLoopPredicate {
- Value *Cond;
- SmallPtrSetImpl<Value *> &LoopPreds;
- bool Pending;
-
- MarkPendingLoopPredicate(Value *C, SmallPtrSetImpl<Value *> &LP)
- : Cond(C), LoopPreds(LP) {
- Pending = !LoopPreds.insert(Cond).second;
- }
- ~MarkPendingLoopPredicate() {
- if (!Pending)
- LoopPreds.erase(Cond);
- }
-};
-} // end anonymous namespace
-
bool ScalarEvolution::isImpliedCond(ICmpInst::Predicate Pred,
const SCEV *LHS, const SCEV *RHS,
Value *FoundCondValue,
bool Inverse) {
- MarkPendingLoopPredicate Mark(FoundCondValue, PendingLoopPredicates);
- if (Mark.Pending)
+ if (!PendingLoopPredicates.insert(FoundCondValue).second)
return false;
+ auto ClearOnExit =
+ make_scope_exit([&]() { PendingLoopPredicates.erase(FoundCondValue); });
+
// Recursively handle And and Or conditions.
if (BinaryOperator *BO = dyn_cast<BinaryOperator>(FoundCondValue)) {
if (BO->getOpcode() == Instruction::And) {
OpenPOWER on IntegriCloud