@@ -70,25 +70,6 @@ void variable_sensitivity_dependence_domaint::transform(
70
70
dynamic_cast <variable_sensitivity_dependence_grapht*>(&ai);
71
71
assert (dep_graph!=nullptr );
72
72
73
- // We do not propagate control dependencies on function calls, i.e., only the
74
- // entry point of a function should have a control dependency on the call
75
- if (!control_deps.empty ())
76
- {
77
- const goto_programt::const_targett &dep = control_deps.begin ()->first ;
78
- if (dep->is_function_call ())
79
- {
80
- INVARIANT (
81
- std::all_of (
82
- std::next (control_deps.begin ()),
83
- control_deps.end (),
84
- [](const std::pair<const goto_programt::const_targett, tvt> &d)
85
- { return d.first ->is_function_call (); }),
86
- " All entries must be function calls" );
87
-
88
- control_deps.clear ();
89
- }
90
- }
91
-
92
73
// propagate control dependencies across function calls
93
74
if (from->is_function_call ())
94
75
{
@@ -115,13 +96,15 @@ void variable_sensitivity_dependence_domaint::transform(
115
96
// modify abstract state of return location
116
97
if (s->merge_control_dependencies (
117
98
control_deps,
118
- control_dep_candidates))
99
+ control_dep_candidates,
100
+ control_dep_calls))
119
101
s->has_changed =true ;
120
102
121
103
control_deps.clear ();
122
- control_deps.insert (std::make_pair (from, tvt::unknown ()));
123
-
124
104
control_dep_candidates.clear ();
105
+
106
+ control_dep_calls.clear ();
107
+ control_dep_calls.insert (from);
125
108
}
126
109
}
127
110
else
@@ -178,7 +161,9 @@ void variable_sensitivity_dependence_domaint::control_dependencies(
178
161
control_dep_candidates.insert (from);
179
162
else if (from->is_end_function ())
180
163
{
164
+ control_deps.clear ();
181
165
control_dep_candidates.clear ();
166
+ control_dep_calls.clear ();
182
167
return ;
183
168
}
184
169
@@ -253,6 +238,7 @@ void variable_sensitivity_dependence_domaint::control_dependencies(
253
238
}
254
239
255
240
control_deps.insert (std::make_pair (cd, branch));
241
+ control_dep_calls.clear ();
256
242
}
257
243
}
258
244
@@ -263,7 +249,8 @@ void variable_sensitivity_dependence_domaint::control_dependencies(
263
249
264
250
bool variable_sensitivity_dependence_domaint::merge_control_dependencies (
265
251
const control_depst &other_control_deps,
266
- const control_dep_candidatest &other_control_dep_candidates)
252
+ const control_dep_candidatest &other_control_dep_candidates,
253
+ const control_dep_callst &other_control_dep_calls)
267
254
{
268
255
bool changed=false ;
269
256
@@ -312,6 +299,16 @@ bool variable_sensitivity_dependence_domaint::merge_control_dependencies(
312
299
313
300
changed|=n!=control_dep_candidates.size ();
314
301
302
+ // Merge call control dependencies
303
+
304
+ n=control_dep_calls.size ();
305
+
306
+ control_dep_calls.insert (
307
+ other_control_dep_calls.begin (),
308
+ other_control_dep_calls.end ());
309
+
310
+ changed|=n!=control_dep_calls.size ();
311
+
315
312
return changed;
316
313
}
317
314
@@ -349,7 +346,8 @@ bool variable_sensitivity_dependence_domaint::merge(
349
346
350
347
changed |= merge_control_dependencies (
351
348
cast_b.control_deps ,
352
- cast_b.control_dep_candidates );
349
+ cast_b.control_dep_candidates ,
350
+ cast_b.control_dep_calls );
353
351
354
352
has_changed=false ;
355
353
has_values=tvt::unknown ();
@@ -398,7 +396,7 @@ void variable_sensitivity_dependence_domaint::output(
398
396
const ai_baset &ai,
399
397
const namespacet &ns) const
400
398
{
401
- if (!control_deps.empty ())
399
+ if (!control_deps.empty () || !control_dep_calls. empty () )
402
400
{
403
401
out << " Control dependencies: " ;
404
402
for (control_depst::const_iterator
@@ -414,6 +412,18 @@ void variable_sensitivity_dependence_domaint::output(
414
412
415
413
out << cd->location_number << " [" << branch << " ]" ;
416
414
}
415
+
416
+ for (control_dep_callst::const_iterator
417
+ it=control_dep_calls.begin ();
418
+ it!=control_dep_calls.end ();
419
+ ++it)
420
+ {
421
+ if (!control_deps.empty () || it!=control_dep_calls.begin ())
422
+ out << " ," ;
423
+
424
+ out << (*it)->location_number << " [UNCONDITIONAL]" ;
425
+ }
426
+
417
427
out << " \n " ;
418
428
}
419
429
@@ -473,6 +483,16 @@ jsont variable_sensitivity_dependence_domaint::output_json(
473
483
link [" branch" ]=json_stringt (branch.to_string ());
474
484
}
475
485
486
+ for (const auto &target : control_dep_calls)
487
+ {
488
+ json_objectt &link =graph.push_back ().make_object ();
489
+ link [" locationNumber" ]=
490
+ json_numbert (std::to_string (target->location_number ));
491
+ link [" sourceLocation" ]=json (target->source_location );
492
+ link [" type" ]=json_stringt (" control" );
493
+ link [" branch" ]=json_stringt (" UNCONDITIONAL" );
494
+ }
495
+
476
496
for (const auto &dep : domain_data_deps)
477
497
{
478
498
json_objectt &link =graph.push_back ().make_object ();
@@ -503,6 +523,9 @@ void variable_sensitivity_dependence_domaint::populate_dep_graph(
503
523
for (const auto &c_dep : control_deps)
504
524
dep_graph.add_dep (vs_dep_edget::kindt::CTRL, c_dep.first , this_loc);
505
525
526
+ for (const auto &c_dep : control_dep_calls)
527
+ dep_graph.add_dep (vs_dep_edget::kindt::CTRL, c_dep, this_loc);
528
+
506
529
for (const auto &d_dep : domain_data_deps)
507
530
dep_graph.add_dep (vs_dep_edget::kindt::DATA, d_dep.first , this_loc);
508
531
}
0 commit comments