@@ -30,25 +30,26 @@ struct procedure_local_cfg_baset<
30
30
31
31
procedure_local_cfg_baset () {}
32
32
33
- void operator ()(const method_with_amapt& args)
33
+ void operator ()(const method_with_amapt & args)
34
34
{
35
35
const auto &method=args.first ;
36
- const auto & amap=args.second ;
37
- for (const auto & inst : amap)
36
+ const auto & amap=args.second ;
37
+ for (const auto & inst : amap)
38
38
{
39
39
// Map instruction PCs onto node indices:
40
40
entry_map[inst.first ]=this ->add_node ();
41
41
// Map back:
42
42
(*this )[entry_map[inst.first ]].PC =inst.first ;
43
43
}
44
- for (const auto & inst : amap)
44
+ // Add edges declared in the address map:
45
+ for (const auto &inst : amap)
45
46
{
46
47
for (auto succ : inst.second .successors )
47
48
this ->add_edge (entry_map.at (inst.first ), entry_map.at (succ));
48
49
}
49
- // Add edges declared in the exception table, which don't figure
50
- // in the address map successors/predecessors as yet.
51
- for (const auto & table_entry : method.exception_table )
50
+ // Next, add edges declared in the exception table, which
51
+ // don't figure in the address map successors/predecessors as yet:
52
+ for (const auto & table_entry : method.exception_table )
52
53
{
53
54
auto findit=amap.find (table_entry.start_pc );
54
55
assert (findit!=amap.end () &&
@@ -61,9 +62,9 @@ struct procedure_local_cfg_baset<
61
62
++succit;
62
63
if (succit==amap.end ())
63
64
continue ;
64
- const auto & thisinst=findit->second ;
65
+ const auto & thisinst=findit->second ;
65
66
if (thisinst.successors .size ()==1 &&
66
- * thisinst.successors .begin ()==succit->first )
67
+ thisinst.successors .back ()==succit->first )
67
68
{
68
69
this ->add_edge (
69
70
entry_map.at (findit->first ),
@@ -73,15 +74,15 @@ struct procedure_local_cfg_baset<
73
74
}
74
75
}
75
76
76
- unsigned get_first_node (const method_with_amapt& args) const
77
+ unsigned get_first_node (const method_with_amapt & args) const
77
78
{
78
79
return args.second .begin ()->first ;
79
80
}
80
- unsigned get_last_node (const method_with_amapt& args) const
81
+ unsigned get_last_node (const method_with_amapt & args) const
81
82
{
82
83
return (--args.second .end ())->first ;
83
84
}
84
- unsigned nodes_empty (const method_with_amapt& args) const
85
+ unsigned nodes_empty (const method_with_amapt & args) const
85
86
{
86
87
return args.second .empty ();
87
88
}
@@ -102,8 +103,8 @@ typedef java_bytecode_convert_methodt::java_cfg_dominatorst
102
103
// Comparators for local variables:
103
104
104
105
static bool lt_index (
105
- const local_variable_with_holest& a,
106
- const local_variable_with_holest& b)
106
+ const local_variable_with_holest & a,
107
+ const local_variable_with_holest & b)
107
108
{
108
109
return a.var .index <b.var .index ;
109
110
}
@@ -123,9 +124,9 @@ typedef std::map<
123
124
124
125
struct is_predecessor_oft
125
126
{
126
- const predecessor_mapt& order;
127
+ const predecessor_mapt & order;
127
128
128
- explicit is_predecessor_oft (const predecessor_mapt& _order) : order(_order) {}
129
+ explicit is_predecessor_oft (const predecessor_mapt & _order) : order(_order) {}
129
130
130
131
bool operator ()(
131
132
local_variable_with_holest* a,
@@ -156,7 +157,7 @@ Function: gather_transitive_predecessors
156
157
157
158
static void gather_transitive_predecessors (
158
159
local_variable_with_holest* start,
159
- const predecessor_mapt& predecessor_map,
160
+ const predecessor_mapt & predecessor_map,
160
161
std::set<local_variable_with_holest*>& result)
161
162
{
162
163
if (!result.insert (start).second )
@@ -183,7 +184,7 @@ Function: is_store_to_slot
183
184
\*******************************************************************/
184
185
185
186
static bool is_store_to_slot (
186
- const java_bytecode_convert_methodt::instructiont& inst,
187
+ const java_bytecode_convert_methodt::instructiont & inst,
187
188
unsigned slotidx)
188
189
{
189
190
const std::string prevstatement=id2string (inst.statement );
@@ -194,7 +195,7 @@ static bool is_store_to_slot(
194
195
if (inst.args .size ()==1 )
195
196
{
196
197
// Store with an argument:
197
- const auto & arg=inst.args [0 ];
198
+ const auto & arg=inst.args [0 ];
198
199
storeslot=id2string (to_constant_expr (arg).get_value ());
199
200
}
200
201
else
@@ -222,7 +223,7 @@ Function: maybe_add_hole
222
223
\*******************************************************************/
223
224
224
225
static void maybe_add_hole (
225
- local_variable_with_holest& var,
226
+ local_variable_with_holest & var,
226
227
unsigned from,
227
228
unsigned to)
228
229
{
@@ -298,9 +299,9 @@ static void populate_predecessor_map(
298
299
local_variable_table_with_holest::iterator firstvar,
299
300
local_variable_table_with_holest::iterator varlimit,
300
301
const std::vector<local_variable_with_holest*>& live_variable_at_address,
301
- const address_mapt& amap,
302
- predecessor_mapt& predecessor_map,
303
- message_handlert& msg_handler)
302
+ const address_mapt & amap,
303
+ predecessor_mapt & predecessor_map,
304
+ message_handlert & msg_handler)
304
305
{
305
306
messaget msg (msg_handler);
306
307
for (auto it=firstvar, itend=varlimit; it!=itend; ++it)
@@ -412,7 +413,7 @@ Function: get_common_dominator
412
413
413
414
static unsigned get_common_dominator (
414
415
const std::set<local_variable_with_holest*>& merge_vars,
415
- const java_cfg_dominatorst& dominator_analysis)
416
+ const java_cfg_dominatorst & dominator_analysis)
416
417
{
417
418
assert (!merge_vars.empty ());
418
419
@@ -426,9 +427,9 @@ static unsigned get_common_dominator(
426
427
std::vector<unsigned > candidate_dominators;
427
428
for (auto v : merge_vars)
428
429
{
429
- const auto & dominator_nodeidx=
430
+ const auto & dominator_nodeidx=
430
431
dominator_analysis.cfg .entry_map .at (v->var .start_pc );
431
- const auto & this_var_doms=
432
+ const auto & this_var_doms=
432
433
dominator_analysis.cfg [dominator_nodeidx].dominators ;
433
434
for (const auto this_var_dom : this_var_doms)
434
435
if (this_var_dom<=first_pc)
@@ -478,7 +479,7 @@ Function: populate_live_range_holes
478
479
\*******************************************************************/
479
480
480
481
static void populate_live_range_holes (
481
- local_variable_with_holest& merge_into,
482
+ local_variable_with_holest & merge_into,
482
483
const std::set<local_variable_with_holest*>& merge_vars,
483
484
unsigned expanded_live_range_start)
484
485
{
@@ -516,10 +517,10 @@ Function: merge_variable_table_entries
516
517
\*******************************************************************/
517
518
518
519
static void merge_variable_table_entries (
519
- local_variable_with_holest& merge_into,
520
+ local_variable_with_holest & merge_into,
520
521
const std::set<local_variable_with_holest*>& merge_vars,
521
- const java_cfg_dominatorst& dominator_analysis,
522
- std::ostream& debug_out)
522
+ const java_cfg_dominatorst & dominator_analysis,
523
+ std::ostream & debug_out)
523
524
{
524
525
// Because we need a lexically-scoped declaration,
525
526
// we must have the merged variable
@@ -554,7 +555,7 @@ static void merge_variable_table_entries(
554
555
#endif
555
556
556
557
// Nuke the now-subsumed var-table entries:
557
- for (auto & v : merge_vars)
558
+ for (auto & v : merge_vars)
558
559
if (v!=&merge_into)
559
560
v->var .length =0 ;
560
561
}
@@ -584,8 +585,8 @@ Function: find_initialisers_for_slot
584
585
void java_bytecode_convert_methodt::find_initialisers_for_slot (
585
586
local_variable_table_with_holest::iterator firstvar,
586
587
local_variable_table_with_holest::iterator varlimit,
587
- const address_mapt& amap,
588
- const java_cfg_dominatorst& dominator_analysis)
588
+ const address_mapt & amap,
589
+ const java_cfg_dominatorst & dominator_analysis)
589
590
{
590
591
// Build a simple map from instruction PC to the variable
591
592
// live in this slot at that PC, and a map from each variable
@@ -609,7 +610,7 @@ void java_bytecode_convert_methodt::find_initialisers_for_slot(
609
610
// Now merge vartable entries according to the predecessor_map:
610
611
611
612
// Take the transitive closure of the predecessor map:
612
- for (auto & kv : predecessor_map)
613
+ for (auto & kv : predecessor_map)
613
614
{
614
615
std::set<local_variable_with_holest*> closed_preds;
615
616
gather_transitive_predecessors (kv.first , predecessor_map, closed_preds);
@@ -636,7 +637,7 @@ void java_bytecode_convert_methodt::find_initialisers_for_slot(
636
637
if (findit==predecessor_map.end ())
637
638
continue ;
638
639
639
- const auto & merge_vars=findit->second ;
640
+ const auto & merge_vars=findit->second ;
640
641
assert (merge_vars.size ()>=2 );
641
642
642
643
merge_variable_table_entries (
@@ -665,8 +666,8 @@ Function: walk_to_next_index
665
666
\*******************************************************************/
666
667
667
668
static void walk_to_next_index (
668
- local_variable_table_with_holest::iterator& it1,
669
- local_variable_table_with_holest::iterator& it2,
669
+ local_variable_table_with_holest::iterator & it1,
670
+ local_variable_table_with_holest::iterator & it2,
670
671
local_variable_table_with_holest::iterator itend)
671
672
{
672
673
if (it2==itend)
@@ -698,9 +699,9 @@ Function: find_initialisers
698
699
\*******************************************************************/
699
700
700
701
void java_bytecode_convert_methodt::find_initialisers (
701
- local_variable_table_with_holest& vars,
702
- const address_mapt& amap,
703
- const java_cfg_dominatorst& dominator_analysis)
702
+ local_variable_table_with_holest & vars,
703
+ const address_mapt & amap,
704
+ const java_cfg_dominatorst & dominator_analysis)
704
705
{
705
706
// Sort table entries by local slot index:
706
707
std::sort (vars.begin (), vars.end (), lt_index);
@@ -766,18 +767,18 @@ Function: setup_local_variables
766
767
\*******************************************************************/
767
768
768
769
void java_bytecode_convert_methodt::setup_local_variables (
769
- const methodt& m,
770
- const address_mapt& amap)
770
+ const methodt & m,
771
+ const address_mapt & amap)
771
772
{
772
773
// Compute CFG dominator tree
773
774
java_cfg_dominatorst dominator_analysis;
774
- method_with_amapt dominator_args (m,amap);
775
+ method_with_amapt dominator_args (m, amap);
775
776
dominator_analysis (dominator_args);
776
777
777
778
// Find out which local variable table entries should be merged:
778
779
// Wrap each entry so we have somewhere to record live ranges with holes:
779
780
std::vector<local_variable_with_holest> vars_with_holes;
780
- for (const auto & v : m.local_variable_table )
781
+ for (const auto & v : m.local_variable_table )
781
782
vars_with_holes.push_back ({v, {}});
782
783
783
784
// Merge variable records:
0 commit comments