aboutsummaryrefslogtreecommitdiff
path: root/tools/llvm-stress/llvm-stress.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/llvm-stress/llvm-stress.cpp')
-rw-r--r--tools/llvm-stress/llvm-stress.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/tools/llvm-stress/llvm-stress.cpp b/tools/llvm-stress/llvm-stress.cpp
index 731a24d0ac2d..74b7735f8cd1 100644
--- a/tools/llvm-stress/llvm-stress.cpp
+++ b/tools/llvm-stress/llvm-stress.cpp
@@ -28,6 +28,7 @@
#include "llvm/Support/PrettyStackTrace.h"
#include "llvm/Support/ToolOutputFile.h"
#include <algorithm>
+#include <random>
#include <vector>
namespace llvm {
@@ -113,6 +114,12 @@ public:
return Rand64() % y;
}
+ /// Make this like a C++11 random device
+ typedef uint32_t result_type;
+ uint32_t operator()() { return Rand32(); }
+ static constexpr result_type min() { return 0; }
+ static constexpr result_type max() { return 0x7ffff; }
+
private:
unsigned Seed;
};
@@ -417,7 +424,9 @@ struct AllocaModifier: public Modifier {
void Act() override {
Type *Tp = pickType();
- PT->push_back(new AllocaInst(Tp, "A", BB->getFirstNonPHI()));
+ const DataLayout &DL = BB->getModule()->getDataLayout();
+ PT->push_back(new AllocaInst(Tp, DL.getAllocaAddrSpace(),
+ "A", BB->getFirstNonPHI()));
}
};
@@ -662,7 +671,7 @@ static void IntroduceControlFlow(Function *F, Random &R) {
BoolInst.push_back(&Instr);
}
- std::random_shuffle(BoolInst.begin(), BoolInst.end(), R);
+ std::shuffle(BoolInst.begin(), BoolInst.end(), R);
for (auto *Instr : BoolInst) {
BasicBlock *Curr = Instr->getParent();