Skip to content

Commit eb84153

Browse files
committed
Dependence graph: refactor function-call control dependency branching
Avoid a nested if when the top-level else and the inner if branch will execute the same code. There is substantial white-space change in this commit for it removes one level of indentation. No changes in behaviour intended.
1 parent ecc813d commit eb84153

File tree

1 file changed

+17
-24
lines changed

1 file changed

+17
-24
lines changed

src/analyses/dependence_graph.cpp

+17-24
Original file line numberDiff line numberDiff line change
@@ -233,36 +233,29 @@ void dep_graph_domaint::transform(
233233
control_deps = std::move(filtered_control_deps);
234234

235235
// propagate control dependencies across function calls
236-
if(from->is_function_call())
236+
if(from->is_function_call() && function_from != function_to)
237237
{
238-
if(function_from == function_to)
239-
{
240-
control_dependencies(function_from, from, to, *dep_graph);
241-
}
242-
else
243-
{
244-
// edge to function entry point
245-
const goto_programt::const_targett next = std::next(from);
238+
// edge to function entry point
239+
const goto_programt::const_targett next = std::next(from);
246240

247-
dep_graph_domaint *s=
248-
dynamic_cast<dep_graph_domaint*>(&(dep_graph->get_state(next)));
249-
assert(s!=nullptr);
241+
dep_graph_domaint *s =
242+
dynamic_cast<dep_graph_domaint *>(&(dep_graph->get_state(next)));
243+
CHECK_RETURN(s != nullptr);
250244

251-
if(s->is_bottom())
252-
{
253-
s->has_values = tvt::unknown();
254-
s->has_changed = true;
255-
}
245+
if(s->is_bottom())
246+
{
247+
s->has_values = tvt::unknown();
248+
s->has_changed = true;
249+
}
256250

257-
s->has_changed |= util_inplace_set_union(s->control_deps, control_deps);
258-
s->has_changed |= util_inplace_set_union(
259-
s->control_dep_candidates, control_dep_candidates);
251+
s->has_changed |= util_inplace_set_union(s->control_deps, control_deps);
252+
s->has_changed |=
253+
util_inplace_set_union(s->control_dep_candidates, control_dep_candidates);
260254

261-
control_deps.clear();
262-
control_deps.insert(from);
255+
control_deps.clear();
256+
control_deps.insert(from);
263257

264-
control_dep_candidates.clear();
265-
}
258+
control_dep_candidates.clear();
266259
}
267260
else
268261
control_dependencies(function_from, from, to, *dep_graph);

0 commit comments

Comments
 (0)