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
#define LLVM_ANALYSIS_SCALAREVOLUTION_EXPRESSIONS_H
#include "llvm/Analysis/ScalarEvolution.h"
+#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/Support/ErrorHandling.h"
namespace llvm {
class SCEVTraversal {
SV &Visitor;
SmallVector<const SCEV *, 8> Worklist;
+ SmallPtrSet<const SCEV *, 8> Visited;
void push(const SCEV *S) {
- if (Visitor.follow(S))
+ if (Visited.insert(S) && Visitor.follow(S))
Worklist.push_back(S);
}
public: