@@ -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
@@ -305,7 +306,7 @@ void goto_symext::symex_function_call_code(
305306  framet &frame = state.new_frame ();
306307
307308  //  preserve locality of local variables
308-   locality (identifier, state, goto_function, ns);
309+   locality (identifier, state, path_storage,  goto_function, ns);
309310
310311  //  assign actuals to formal parameters
311312  parameter_assignments (identifier, goto_function, state, arguments);
@@ -381,68 +382,27 @@ void goto_symext::symex_end_of_function(statet &state)
381382  pop_frame (state);
382383}
383384
384- // / preserves  locality of local variables  of a given function by applying L1
385- // / renaming to the local identifiers 
385+ // / Preserves  locality of parameters  of a given function by applying L1
386+ // / renaming to them. 
386387static  void  locality (
387388  const  irep_idt &function_identifier,
388389  goto_symext::statet &state,
390+   path_storaget &path_storage,
389391  const  goto_functionst::goto_functiont &goto_function,
390392  const  namespacet &ns)
391393{
392394  unsigned  &frame_nr=
393395    state.threads [state.source .thread_nr ].function_frame [function_identifier];
394396  frame_nr++;
395397
396-   std::set<irep_idt> local_identifiers;
397- 
398-   get_local_identifiers (goto_function, local_identifiers);
399- 
400-   framet &frame = state.top ();
401- 
402-   for (std::set<irep_idt>::const_iterator
403-       it=local_identifiers.begin ();
404-       it!=local_identifiers.end ();
405-       it++)
398+   for (const  auto  ¶m : goto_function.type .parameters ())
406399  {
407400    //  get L0 name
408-     ssa_exprt ssa =
409-       state.rename_ssa <L0>(ssa_exprt{ns.lookup (*it).symbol_expr ()}, ns);
410-     const  irep_idt l0_name=ssa.get_identifier ();
411- 
412-     //  save old L1 name for popping the frame
413-     auto  c_it = state.level1 .current_names .find (l0_name);
414- 
415-     if (c_it != state.level1 .current_names .end ())
416-     {
417-       frame.old_level1 .emplace (l0_name, c_it->second );
418-       c_it->second  = std::make_pair (ssa, frame_nr);
419-     }
420-     else 
421-     {
422-       c_it = state.level1 .current_names 
423-                .emplace (l0_name, std::make_pair (ssa, frame_nr))
424-                .first ;
425-     }
426- 
427-     //  do L1 renaming -- these need not be unique, as
428-     //  identifiers may be shared among functions
429-     //  (e.g., due to inlining or other code restructuring)
430- 
431-     ssa_exprt ssa_l1 = state.rename_ssa <L1>(std::move (ssa), ns);
432- 
433-     irep_idt l1_name = ssa_l1.get_identifier ();
434-     unsigned  offset=0 ;
435- 
436-     while (state.l1_history .find (l1_name)!=state.l1_history .end ())
437-     {
438-       symex_renaming_levelt::increase_counter (c_it);
439-       ++offset;
440-       ssa_l1.set_level_1 (frame_nr + offset);
441-       l1_name = ssa_l1.get_identifier ();
442-     }
401+     ssa_exprt ssa = state.rename_ssa <L0>(
402+       ssa_exprt{ns.lookup (param.get_identifier ()).symbol_expr ()}, ns);
443403
444-     //  now unique -- store 
445-     frame. local_objects . insert (l1_name );
446-     state.l1_history . insert (l1_name );
404+     const  std:: size_t  fresh_l1_index = 
405+       path_storage. get_unique_index (ssa. get_identifier (), frame_nr );
406+     state.add_object (ssa, fresh_l1_index, ns );
447407  }
448408}
0 commit comments