|
22 | 22 | static void locality(
|
23 | 23 | const irep_idt &function_identifier,
|
24 | 24 | goto_symext::statet &state,
|
| 25 | + path_storaget &path_storage, |
25 | 26 | const goto_functionst::goto_functiont &goto_function,
|
26 | 27 | const namespacet &ns);
|
27 | 28 |
|
@@ -307,7 +308,7 @@ void goto_symext::symex_function_call_code(
|
307 | 308 | framet &frame = state.call_stack().new_frame(state.source);
|
308 | 309 |
|
309 | 310 | // preserve locality of local variables
|
310 |
| - locality(identifier, state, goto_function, ns); |
| 311 | + locality(identifier, state, path_storage, goto_function, ns); |
311 | 312 |
|
312 | 313 | // assign actuals to formal parameters
|
313 | 314 | parameter_assignments(identifier, goto_function, state, arguments);
|
@@ -383,68 +384,27 @@ void goto_symext::symex_end_of_function(statet &state)
|
383 | 384 | pop_frame(state);
|
384 | 385 | }
|
385 | 386 |
|
386 |
| -/// preserves locality of local variables of a given function by applying L1 |
387 |
| -/// renaming to the local identifiers |
| 387 | +/// Preserves locality of parameters of a given function by applying L1 |
| 388 | +/// renaming to them. |
388 | 389 | static void locality(
|
389 | 390 | const irep_idt &function_identifier,
|
390 | 391 | goto_symext::statet &state,
|
| 392 | + path_storaget &path_storage, |
391 | 393 | const goto_functionst::goto_functiont &goto_function,
|
392 | 394 | const namespacet &ns)
|
393 | 395 | {
|
394 | 396 | unsigned &frame_nr=
|
395 | 397 | state.threads[state.source.thread_nr].function_frame[function_identifier];
|
396 | 398 | frame_nr++;
|
397 | 399 |
|
398 |
| - std::set<irep_idt> local_identifiers; |
399 |
| - |
400 |
| - get_local_identifiers(goto_function, local_identifiers); |
401 |
| - |
402 |
| - framet &frame = state.call_stack().top(); |
403 |
| - |
404 |
| - for(std::set<irep_idt>::const_iterator |
405 |
| - it=local_identifiers.begin(); |
406 |
| - it!=local_identifiers.end(); |
407 |
| - it++) |
| 400 | + for(const auto ¶m : goto_function.parameter_identifiers) |
408 | 401 | {
|
409 | 402 | // get L0 name
|
410 | 403 | ssa_exprt ssa =
|
411 |
| - state.rename_ssa<L0>(ssa_exprt{ns.lookup(*it).symbol_expr()}, ns); |
412 |
| - const irep_idt l0_name=ssa.get_identifier(); |
413 |
| - |
414 |
| - // save old L1 name for popping the frame |
415 |
| - auto c_it = state.level1.current_names.find(l0_name); |
416 |
| - |
417 |
| - if(c_it != state.level1.current_names.end()) |
418 |
| - { |
419 |
| - frame.old_level1.emplace(l0_name, c_it->second); |
420 |
| - c_it->second = std::make_pair(ssa, frame_nr); |
421 |
| - } |
422 |
| - else |
423 |
| - { |
424 |
| - c_it = state.level1.current_names |
425 |
| - .emplace(l0_name, std::make_pair(ssa, frame_nr)) |
426 |
| - .first; |
427 |
| - } |
428 |
| - |
429 |
| - // do L1 renaming -- these need not be unique, as |
430 |
| - // identifiers may be shared among functions |
431 |
| - // (e.g., due to inlining or other code restructuring) |
432 |
| - |
433 |
| - ssa_exprt ssa_l1 = state.rename_ssa<L1>(std::move(ssa), ns); |
434 |
| - |
435 |
| - irep_idt l1_name = ssa_l1.get_identifier(); |
436 |
| - unsigned offset=0; |
437 |
| - |
438 |
| - while(state.l1_history.find(l1_name)!=state.l1_history.end()) |
439 |
| - { |
440 |
| - symex_renaming_levelt::increase_counter(c_it); |
441 |
| - ++offset; |
442 |
| - ssa_l1.set_level_1(frame_nr + offset); |
443 |
| - l1_name = ssa_l1.get_identifier(); |
444 |
| - } |
| 404 | + state.rename_ssa<L0>(ssa_exprt{ns.lookup(param).symbol_expr()}, ns); |
445 | 405 |
|
446 |
| - // now unique -- store |
447 |
| - frame.local_objects.insert(l1_name); |
448 |
| - state.l1_history.insert(l1_name); |
| 406 | + const std::size_t fresh_l1_index = |
| 407 | + path_storage.get_unique_index(ssa.get_identifier(), frame_nr); |
| 408 | + state.add_object(ssa, fresh_l1_index, ns); |
449 | 409 | }
|
450 | 410 | }
|
0 commit comments