Skip to content

Commit dd887d9

Browse files
committed
[PhiValues] Use SetVector to avoid non-determinism
I'm not sure whether this can cause actual non-determinism in the compiler output, but at least it causes non-determinism in the statistics collected by BasicAA. Use SetVector to have a predictable iteration order.
1 parent 1253c40 commit dd887d9

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

llvm/include/llvm/Analysis/PhiValues.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
#include "llvm/ADT/DenseMap.h"
2323
#include "llvm/ADT/DenseSet.h"
24-
#include "llvm/ADT/SmallPtrSet.h"
24+
#include "llvm/ADT/SetVector.h"
2525
#include "llvm/ADT/SmallVector.h"
2626
#include "llvm/IR/PassManager.h"
2727
#include "llvm/IR/ValueHandle.h"
@@ -40,7 +40,7 @@ class Function;
4040
/// it is queried.
4141
class PhiValues {
4242
public:
43-
using ValueSet = SmallPtrSet<Value *, 4>;
43+
using ValueSet = SmallSetVector<Value *, 4>;
4444

4545
/// Construct an empty PhiValues.
4646
PhiValues(const Function &F) : F(F) {}
@@ -70,8 +70,7 @@ class PhiValues {
7070
FunctionAnalysisManager::Invalidator &);
7171

7272
private:
73-
using PhiSet = SmallPtrSet<const PHINode *, 4>;
74-
using ConstValueSet = SmallPtrSet<const Value *, 4>;
73+
using ConstValueSet = SmallSetVector<const Value *, 4>;
7574

7675
/// The next depth number to be used by processPhi.
7776
unsigned int NextDepthNumber = 1;

llvm/lib/Analysis/PhiValues.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "llvm/Analysis/PhiValues.h"
10-
#include "llvm/ADT/SmallPtrSet.h"
1110
#include "llvm/ADT/SmallVector.h"
1211
#include "llvm/IR/Instructions.h"
1312
#include "llvm/InitializePasses.h"

0 commit comments

Comments
 (0)