@@ -94,6 +94,9 @@ void dep_graph_domaint::control_dependencies(
94
94
from->is_assume ())
95
95
control_deps.insert (from);
96
96
97
+ const irep_idt id=goto_programt::get_function_id (from);
98
+ const cfg_post_dominatorst &pd=dep_graph.cfg_post_dominators ().at (id);
99
+
97
100
// check all candidates for M
98
101
for (depst::iterator
99
102
it=control_deps.begin ();
@@ -111,15 +114,17 @@ void dep_graph_domaint::control_dependencies(
111
114
// we could hard-code assume and goto handling here to improve
112
115
// performance
113
116
cfg_post_dominatorst::cfgt::entry_mapt::const_iterator e=
114
- dep_graph.cfg_post_dominators ().cfg .entry_map .find (*it);
115
- assert (e!=dep_graph.cfg_post_dominators ().cfg .entry_map .end ());
117
+ pd.cfg .entry_map .find (*it);
118
+
119
+ assert (e!=pd.cfg .entry_map .end ());
120
+
116
121
const cfg_post_dominatorst::cfgt::nodet &m=
117
- dep_graph. cfg_post_dominators () .cfg [e->second ];
122
+ pd .cfg [e->second ];
118
123
119
124
for (const auto &edge : m.out )
120
125
{
121
126
const cfg_post_dominatorst::cfgt::nodet &m_s=
122
- dep_graph. cfg_post_dominators () .cfg [edge.first ];
127
+ pd .cfg [edge.first ];
123
128
124
129
if (m_s.dominators .find (to)!=m_s.dominators .end ())
125
130
post_dom_one=true ;
@@ -252,30 +257,39 @@ void dep_graph_domaint::transform(
252
257
const namespacet &ns)
253
258
{
254
259
dependence_grapht *dep_graph=dynamic_cast <dependence_grapht*>(&ai);
255
- assert (dep_graph!=0 );
260
+ assert (dep_graph!=nullptr );
256
261
257
262
// propagate control dependencies across function calls
258
263
if (from->is_function_call ())
259
264
{
260
265
goto_programt::const_targett next=from;
261
266
++next;
262
267
263
- dep_graph_domaint *s=
264
- dynamic_cast <dep_graph_domaint*>(&(dep_graph->get_state (next)));
265
- assert (s!=0 );
266
-
267
- depst::iterator it=s->control_deps .begin ();
268
- for (const auto &c_dep : control_deps)
268
+ if (next==to)
269
269
{
270
- while (it!=s->control_deps .end () && *it<c_dep)
271
- ++it;
272
- if (it==s->control_deps .end () || c_dep<*it)
273
- s->control_deps .insert (it, c_dep);
274
- else if (it!=s->control_deps .end ())
275
- ++it;
270
+ control_dependencies (from, to, *dep_graph);
271
+ }
272
+ else
273
+ {
274
+ // edge to function entry point
275
+
276
+ dep_graph_domaint *s=
277
+ dynamic_cast <dep_graph_domaint*>(&(dep_graph->get_state (next)));
278
+ assert (s!=nullptr );
279
+
280
+ depst::iterator it=s->control_deps .begin ();
281
+ for (const auto &c_dep : control_deps)
282
+ {
283
+ while (it!=s->control_deps .end () && *it<c_dep)
284
+ ++it;
285
+ if (it==s->control_deps .end () || c_dep<*it)
286
+ s->control_deps .insert (it, c_dep);
287
+ else if (it!=s->control_deps .end ())
288
+ ++it;
289
+ }
290
+
291
+ control_deps.clear ();
276
292
}
277
-
278
- control_dependencies (from, next, *dep_graph);
279
293
}
280
294
else
281
295
control_dependencies (from, to, *dep_graph);
0 commit comments