Skip to content

Commit 9885ac8

Browse files
author
Daniel Kroening
authored
Merge pull request #420 from danpoe/dependence-graph-fix
Dependency graph fix
2 parents c655301 + eef9570 commit 9885ac8

File tree

4 files changed

+38
-5
lines changed

4 files changed

+38
-5
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
int x;
3+
4+
void func()
5+
{
6+
int r;
7+
8+
r = x;
9+
}
10+
11+
int main()
12+
{
13+
x = 1;
14+
func();
15+
16+
return 0;
17+
}
18+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CORE
2+
main.c
3+
--show-dependence-graph
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring

src/analyses/ai.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -499,10 +499,11 @@ void ai_baset::sequential_fixedpoint(
499499
const goto_functionst &goto_functions,
500500
const namespacet &ns)
501501
{
502-
// do each function at least once
502+
goto_functionst::function_mapt::const_iterator
503+
f_it=goto_functions.function_map.find(goto_functions.entry_point());
503504

504-
forall_goto_functions(it, goto_functions)
505-
fixedpoint(it->second.body, goto_functions, ns);
505+
if(f_it!=goto_functions.function_map.end())
506+
fixedpoint(f_it->second.body, goto_functions, ns);
506507
}
507508

508509
/*******************************************************************\

src/analyses/dependence_graph.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,20 @@ class dep_graph_domaint:public ai_domain_baset
9494

9595
void make_top() final override
9696
{
97+
assert(node_id!=std::numeric_limits<node_indext>::max());
98+
9799
has_values=tvt(true);
98-
node_id=std::numeric_limits<node_indext>::max();
100+
control_deps.clear();
101+
data_deps.clear();
99102
}
100103

101104
void make_bottom() final override
102105
{
106+
assert(node_id!=std::numeric_limits<node_indext>::max());
107+
103108
has_values=tvt(false);
104-
node_id=std::numeric_limits<node_indext>::max();
109+
control_deps.clear();
110+
data_deps.clear();
105111
}
106112

107113
void make_entry() final override
@@ -161,6 +167,7 @@ class dependence_grapht:
161167

162168
void initialize(const goto_programt &goto_program)
163169
{
170+
ait<dep_graph_domaint>::initialize(goto_program);
164171
post_dominators(goto_program);
165172
}
166173

0 commit comments

Comments
 (0)