From: Andrew Trick Date: Wed, 18 Jul 2012 05:14:03 +0000 (+0000) Subject: SCEVTraversal: Add a visited set. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=18a1b616ea123548b61a037c4f4fea4133aac1b5;p=oota-llvm.git SCEVTraversal: Add a visited set. Expression trees may be DAGs. Make sure traversal has linear complexity. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160426 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Analysis/ScalarEvolutionExpressions.h b/include/llvm/Analysis/ScalarEvolutionExpressions.h index cf15f73a751..ded12974fac 100644 --- a/include/llvm/Analysis/ScalarEvolutionExpressions.h +++ b/include/llvm/Analysis/ScalarEvolutionExpressions.h @@ -15,6 +15,7 @@ #define LLVM_ANALYSIS_SCALAREVOLUTION_EXPRESSIONS_H #include "llvm/Analysis/ScalarEvolution.h" +#include "llvm/ADT/SmallPtrSet.h" #include "llvm/Support/ErrorHandling.h" namespace llvm { @@ -505,9 +506,10 @@ namespace llvm { class SCEVTraversal { SV &Visitor; SmallVector Worklist; + SmallPtrSet Visited; void push(const SCEV *S) { - if (Visitor.follow(S)) + if (Visited.insert(S) && Visitor.follow(S)) Worklist.push_back(S); } public: