@@ -22,6 +22,7 @@ Author: Daniel Kroening, kroening@kroening.com
2222static  void  locality (
2323  const  irep_idt &function_identifier,
2424  goto_symext::statet &state,
25+   path_storaget &path_storage,
2526  const  goto_functionst::goto_functiont &goto_function,
2627  const  namespacet &ns);
2728
@@ -306,7 +307,7 @@ void goto_symext::symex_function_call_code(
306307  framet &frame = state.call_stack ().new_frame (state.source );
307308
308309  //  preserve locality of local variables
309-   locality (identifier, state, goto_function, ns);
310+   locality (identifier, state, path_storage,  goto_function, ns);
310311
311312  //  assign actuals to formal parameters
312313  parameter_assignments (identifier, goto_function, state, arguments);
@@ -382,68 +383,27 @@ void goto_symext::symex_end_of_function(statet &state)
382383  pop_frame (state);
383384}
384385
385- // / preserves  locality of local variables  of a given function by applying L1
386- // / renaming to the local identifiers 
386+ // / Preserves  locality of parameters  of a given function by applying L1
387+ // / renaming to them. 
387388static  void  locality (
388389  const  irep_idt &function_identifier,
389390  goto_symext::statet &state,
391+   path_storaget &path_storage,
390392  const  goto_functionst::goto_functiont &goto_function,
391393  const  namespacet &ns)
392394{
393395  unsigned  &frame_nr=
394396    state.threads [state.source .thread_nr ].function_frame [function_identifier];
395397  frame_nr++;
396398
397-   std::set<irep_idt> local_identifiers;
398- 
399-   get_local_identifiers (goto_function, local_identifiers);
400- 
401-   framet &frame = state.call_stack ().top ();
402- 
403-   for (std::set<irep_idt>::const_iterator
404-       it=local_identifiers.begin ();
405-       it!=local_identifiers.end ();
406-       it++)
399+   for (const  auto  ¶m : goto_function.parameter_identifiers )
407400  {
408401    //  get L0 name
409402    ssa_exprt ssa =
410-       state.rename_ssa <L0>(ssa_exprt{ns.lookup (*it).symbol_expr ()}, ns);
411-     const  irep_idt l0_name=ssa.get_identifier ();
412- 
413-     //  save old L1 name for popping the frame
414-     auto  c_it = state.level1 .current_names .find (l0_name);
415- 
416-     if (c_it != state.level1 .current_names .end ())
417-     {
418-       frame.old_level1 .emplace (l0_name, c_it->second );
419-       c_it->second  = std::make_pair (ssa, frame_nr);
420-     }
421-     else 
422-     {
423-       c_it = state.level1 .current_names 
424-                .emplace (l0_name, std::make_pair (ssa, frame_nr))
425-                .first ;
426-     }
427- 
428-     //  do L1 renaming -- these need not be unique, as
429-     //  identifiers may be shared among functions
430-     //  (e.g., due to inlining or other code restructuring)
431- 
432-     ssa_exprt ssa_l1 = state.rename_ssa <L1>(std::move (ssa), ns);
433- 
434-     irep_idt l1_name = ssa_l1.get_identifier ();
435-     unsigned  offset=0 ;
436- 
437-     while (state.l1_history .find (l1_name)!=state.l1_history .end ())
438-     {
439-       symex_renaming_levelt::increase_counter (c_it);
440-       ++offset;
441-       ssa_l1.set_level_1 (frame_nr + offset);
442-       l1_name = ssa_l1.get_identifier ();
443-     }
403+       state.rename_ssa <L0>(ssa_exprt{ns.lookup (param).symbol_expr ()}, ns);
444404
445-     //  now unique -- store 
446-     frame. local_objects . insert (l1_name );
447-     state.l1_history . insert (l1_name );
405+     const  std:: size_t  fresh_l1_index = 
406+       path_storage. get_unique_index (ssa. get_identifier (), frame_nr );
407+     state.add_object (ssa, fresh_l1_index, ns );
448408  }
449409}
0 commit comments