@@ -66,11 +66,12 @@ void static_analysis_baset::operator()(
66
66
}
67
67
68
68
void static_analysis_baset::operator ()(
69
+ const irep_idt &function_identifier,
69
70
const goto_programt &goto_program)
70
71
{
71
72
initialize (goto_program);
72
73
goto_functionst goto_functions;
73
- fixedpoint (goto_program, goto_functions);
74
+ fixedpoint (function_identifier, goto_program, goto_functions);
74
75
}
75
76
76
77
void static_analysis_baset::output (
@@ -166,6 +167,7 @@ static_analysis_baset::locationt static_analysis_baset::get_next(
166
167
}
167
168
168
169
bool static_analysis_baset::fixedpoint (
170
+ const irep_idt &function_identifier,
169
171
const goto_programt &goto_program,
170
172
const goto_functionst &goto_functions)
171
173
{
@@ -184,14 +186,15 @@ bool static_analysis_baset::fixedpoint(
184
186
{
185
187
locationt l=get_next (working_set);
186
188
187
- if (visit (l, working_set, goto_program, goto_functions))
189
+ if (visit (function_identifier, l, working_set, goto_program, goto_functions))
188
190
new_data=true ;
189
191
}
190
192
191
193
return new_data;
192
194
}
193
195
194
196
bool static_analysis_baset::visit (
197
+ const irep_idt &function_identifier,
195
198
locationt l,
196
199
working_sett &working_set,
197
200
const goto_programt &goto_program,
@@ -220,14 +223,17 @@ bool static_analysis_baset::visit(
220
223
to_code_function_call (l->code );
221
224
222
225
do_function_call_rec (
223
- l, to_l,
226
+ function_identifier,
227
+ l,
228
+ to_l,
224
229
code.function (),
225
230
code.arguments (),
226
231
new_values,
227
232
goto_functions);
228
233
}
229
234
else
230
- new_values.transform (ns, l, to_l);
235
+ new_values.transform (
236
+ ns, function_identifier, l, function_identifier, to_l);
231
237
232
238
statet &other=get_state (to_l);
233
239
@@ -245,7 +251,9 @@ bool static_analysis_baset::visit(
245
251
}
246
252
247
253
void static_analysis_baset::do_function_call (
248
- locationt l_call, locationt l_return,
254
+ const irep_idt &calling_function,
255
+ locationt l_call,
256
+ locationt l_return,
249
257
const goto_functionst &goto_functions,
250
258
const goto_functionst::function_mapt::const_iterator f_it,
251
259
const exprt::operandst &,
@@ -264,7 +272,7 @@ void static_analysis_baset::do_function_call(
264
272
265
273
// do the edge from the call site to the beginning of the function
266
274
std::unique_ptr<statet> tmp_state (make_temporary_state (new_state));
267
- tmp_state->transform (ns, l_call, l_begin);
275
+ tmp_state->transform (ns, calling_function, l_call, f_it-> first , l_begin);
268
276
269
277
statet &begin_state=get_state (l_begin);
270
278
@@ -286,7 +294,7 @@ void static_analysis_baset::do_function_call(
286
294
if (new_data)
287
295
{
288
296
// recursive call
289
- fixedpoint (goto_function.body , goto_functions);
297
+ fixedpoint (f_it-> first , goto_function.body , goto_functions);
290
298
}
291
299
}
292
300
@@ -301,7 +309,7 @@ void static_analysis_baset::do_function_call(
301
309
// do edge from end of function to instruction after call
302
310
std::unique_ptr<statet> tmp_state (
303
311
make_temporary_state (end_of_function));
304
- tmp_state->transform (ns, l_end, l_return);
312
+ tmp_state->transform (ns, f_it-> first , l_end, calling_function , l_return);
305
313
306
314
// propagate those -- not exceedingly precise, this is,
307
315
// as still it contains all the state from the
@@ -311,12 +319,15 @@ void static_analysis_baset::do_function_call(
311
319
312
320
{
313
321
// effect on current procedure (if any)
314
- new_state.transform (ns, l_call, l_return);
322
+ new_state.transform (
323
+ ns, calling_function, l_call, calling_function, l_return);
315
324
}
316
325
}
317
326
318
327
void static_analysis_baset::do_function_call_rec (
319
- locationt l_call, locationt l_return,
328
+ const irep_idt &calling_function,
329
+ locationt l_call,
330
+ locationt l_return,
320
331
const exprt &function,
321
332
const exprt::operandst &arguments,
322
333
statet &new_state,
@@ -345,7 +356,9 @@ void static_analysis_baset::do_function_call_rec(
345
356
throw " failed to find function " +id2string (identifier);
346
357
347
358
do_function_call (
348
- l_call, l_return,
359
+ calling_function,
360
+ l_call,
361
+ l_return,
349
362
goto_functions,
350
363
it,
351
364
arguments,
@@ -361,14 +374,18 @@ void static_analysis_baset::do_function_call_rec(
361
374
std::unique_ptr<statet> n2 (make_temporary_state (new_state));
362
375
363
376
do_function_call_rec (
364
- l_call, l_return,
377
+ calling_function,
378
+ l_call,
379
+ l_return,
365
380
function.op1 (),
366
381
arguments,
367
382
new_state,
368
383
goto_functions);
369
384
370
385
do_function_call_rec (
371
- l_call, l_return,
386
+ calling_function,
387
+ l_call,
388
+ l_return,
372
389
function.op2 (),
373
390
arguments,
374
391
*n2,
@@ -392,7 +409,13 @@ void static_analysis_baset::do_function_call_rec(
392
409
const object_descriptor_exprt &o=to_object_descriptor_expr (value);
393
410
std::unique_ptr<statet> n2 (make_temporary_state (new_state));
394
411
do_function_call_rec (
395
- l_call, l_return, o.object (), arguments, *n2, goto_functions);
412
+ calling_function,
413
+ l_call,
414
+ l_return,
415
+ o.object (),
416
+ arguments,
417
+ *n2,
418
+ goto_functions);
396
419
merge (new_state, *n2, l_return);
397
420
}
398
421
}
@@ -424,7 +447,7 @@ void static_analysis_baset::sequential_fixedpoint(
424
447
425
448
forall_goto_functions (it, goto_functions)
426
449
if (functions_done.insert (it->first ).second )
427
- fixedpoint (it->second .body , goto_functions);
450
+ fixedpoint (it->first , it-> second .body , goto_functions);
428
451
}
429
452
430
453
void static_analysis_baset::concurrent_fixedpoint (
@@ -442,16 +465,32 @@ void static_analysis_baset::concurrent_fixedpoint(
442
465
generate_state (sh_target);
443
466
statet &shared_state=get_state (sh_target);
444
467
445
- typedef std::list<std::pair<goto_programt const *,
446
- goto_programt::const_targett> > thread_wlt;
468
+ struct wl_entryt
469
+ {
470
+ wl_entryt (
471
+ const irep_idt &_function_identifier,
472
+ const goto_programt &_goto_program,
473
+ locationt _location)
474
+ : function_identifier(_function_identifier),
475
+ goto_program (&_goto_program),
476
+ location(_location)
477
+ {
478
+ }
479
+
480
+ irep_idt function_identifier;
481
+ const goto_programt *goto_program;
482
+ locationt location;
483
+ };
484
+
485
+ typedef std::list<wl_entryt> thread_wlt;
447
486
thread_wlt thread_wl;
448
487
449
488
forall_goto_functions (it, goto_functions)
450
489
forall_goto_program_instructions(t_it, it->second.body)
451
490
{
452
491
if (is_threaded (t_it))
453
492
{
454
- thread_wl.push_back (std::make_pair (&( it->second .body ) , t_it));
493
+ thread_wl.push_back (wl_entryt ( it->first , it-> second .body , t_it));
455
494
456
495
goto_programt::const_targett l_end=
457
496
it->second .body .instructions .end ();
@@ -472,16 +511,21 @@ void static_analysis_baset::concurrent_fixedpoint(
472
511
for (const auto &thread : thread_wl)
473
512
{
474
513
working_sett working_set;
475
- put_in_working_set (working_set, thread.second );
514
+ put_in_working_set (working_set, thread.location );
476
515
477
- statet &begin_state= get_state (thread.second );
478
- merge (begin_state, shared_state, thread.second );
516
+ statet &begin_state = get_state (thread.location );
517
+ merge (begin_state, shared_state, thread.location );
479
518
480
519
while (!working_set.empty ())
481
520
{
482
521
goto_programt::const_targett l=get_next (working_set);
483
522
484
- visit (l, working_set, *thread.first , goto_functions);
523
+ visit (
524
+ thread.function_identifier ,
525
+ l,
526
+ working_set,
527
+ *thread.goto_program ,
528
+ goto_functions);
485
529
486
530
// the underlying domain must make sure that the final state
487
531
// carries all possible values; otherwise we would need to
0 commit comments