@@ -26,20 +26,18 @@ void MutationInfo::exitInfo()
26
26
writeLine (SaveMessageAsText (*m_protobufMsg));
27
27
}
28
28
29
- // / Initialize deterministic PRNG.
30
- static YulRandomNumGenerator s_rand (1337 );
31
-
32
29
// / Add m/sstore(0, variable)
33
30
static LPMPostProcessor<Block> addStoreToZero (
34
31
[](Block* _message, unsigned _seed)
35
32
{
36
33
if (_seed % YPM::s_highIP == 0 )
37
34
{
35
+ YulRandomNumGenerator yrand (_seed);
38
36
MutationInfo m{_message, " Added store to zero" };
39
37
auto storeStmt = new StoreFunc ();
40
- storeStmt->set_st (YPM::EnumTypeConverter<StoreFunc_Storage>{}.enumFromSeed (s_rand ()));
38
+ storeStmt->set_st (YPM::EnumTypeConverter<StoreFunc_Storage>{}.enumFromSeed (yrand ()));
41
39
storeStmt->set_allocated_loc (YPM::litExpression (0 ));
42
- storeStmt->set_allocated_val (YPM::refExpression (s_rand ));
40
+ storeStmt->set_allocated_val (YPM::refExpression (yrand ));
43
41
auto stmt = _message->add_statements ();
44
42
stmt->set_allocated_storage_func (storeStmt);
45
43
}
@@ -54,10 +52,10 @@ struct addControlFlow
54
52
{
55
53
addControlFlow ()
56
54
{
57
- function = [](T* _message, unsigned )
55
+ function = [](T* _message, unsigned _seed )
58
56
{
59
57
MutationInfo m{_message, " Added control flow." };
60
- YPM::addControlFlow (_message);
58
+ YPM::addControlFlow (_message, _seed );
61
59
};
62
60
// / Unused variable registers callback.
63
61
LPMPostProcessor<T> callback (function);
@@ -170,7 +168,7 @@ unsigned YPM::EnumTypeConverter<T>::enumMin()
170
168
}
171
169
172
170
template <typename T>
173
- void YPM::addControlFlow (T* _msg)
171
+ void YPM::addControlFlow (T* _msg, unsigned _seed )
174
172
{
175
173
enum class ControlFlowStmt : unsigned
176
174
{
@@ -188,8 +186,9 @@ void YPM::addControlFlow(T* _msg)
188
186
static_cast <unsigned >(ControlFlowStmt::For),
189
187
static_cast <unsigned >(ControlFlowStmt::Termination)
190
188
);
191
- auto random = static_cast <ControlFlowStmt>(d (s_rand.m_random ));
192
- Statement* s = basicBlock (_msg)->add_statements ();
189
+ YulRandomNumGenerator yrand (_seed);
190
+ auto random = static_cast <ControlFlowStmt>(d (yrand.m_random ));
191
+ Statement* s = basicBlock (_msg, _seed)->add_statements ();
193
192
switch (random)
194
193
{
195
194
case ControlFlowStmt::For:
@@ -222,7 +221,7 @@ void YPM::addControlFlow(T* _msg)
222
221
}
223
222
}
224
223
225
- Block* YPM::randomBlock (ForStmt* _stmt)
224
+ Block* YPM::randomBlock (ForStmt* _stmt, unsigned _seed )
226
225
{
227
226
enum class ForBlocks : unsigned
228
227
{
@@ -234,7 +233,8 @@ Block* YPM::randomBlock(ForStmt* _stmt)
234
233
static_cast <unsigned >(ForBlocks::Init),
235
234
static_cast <unsigned >(ForBlocks::Body)
236
235
);
237
- switch (static_cast <ForBlocks>(d (s_rand.m_random )))
236
+ YulRandomNumGenerator yrand (_seed);
237
+ switch (static_cast <ForBlocks>(d (yrand.m_random )))
238
238
{
239
239
case ForBlocks::Init:
240
240
return _stmt->mutable_for_init ();
@@ -246,10 +246,10 @@ Block* YPM::randomBlock(ForStmt* _stmt)
246
246
}
247
247
248
248
template <typename T>
249
- Block* YPM::basicBlock (T* _msg)
249
+ Block* YPM::basicBlock (T* _msg, unsigned _seed )
250
250
{
251
251
if constexpr (std::is_same_v<T, ForStmt>)
252
- return randomBlock (_msg);
252
+ return randomBlock (_msg, _seed );
253
253
else if constexpr (std::is_same_v<T, BoundedForStmt>)
254
254
return _msg->mutable_for_body ();
255
255
else if constexpr (std::is_same_v<T, SwitchStmt>)
0 commit comments