Skip to content

Commit c61ee27

Browse files
authored
Merge pull request #6711 from tautschnig/bugfixes/dependence-graph-return-values
Program dependence graph: track SET_RETURN_VALUE instruction
2 parents daa7996 + 8305936 commit c61ee27

File tree

4 files changed

+40
-41
lines changed

4 files changed

+40
-41
lines changed
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
--full-slice
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring

src/analyses/dependence_graph.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,24 @@ void dep_graph_domaint::data_dependencies(
188188

189189
dep_graph.reaching_definitions()[to].clear_cache(read_object_entry.first);
190190
}
191+
192+
if(to->is_set_return_value())
193+
{
194+
auto entry = dep_graph.end_function_map.find(function_to);
195+
CHECK_RETURN(entry != dep_graph.end_function_map.end());
196+
197+
goto_programt::const_targett end_function = entry->second;
198+
199+
dep_graph_domaint *s =
200+
dynamic_cast<dep_graph_domaint *>(&(dep_graph.get_state(end_function)));
201+
CHECK_RETURN(s != nullptr);
202+
203+
if(s->is_bottom())
204+
s->has_values = tvt::unknown();
205+
206+
if(s->data_deps.insert(to).second)
207+
s->has_changed = true;
208+
}
191209
}
192210

193211
void dep_graph_domaint::transform(

src/analyses/dependence_graph.h

+14
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,16 @@ class dependence_grapht:
224224
{
225225
ait<dep_graph_domaint>::initialize(goto_functions);
226226
rd(goto_functions, ns);
227+
228+
for(const auto &entry : goto_functions.function_map)
229+
{
230+
const goto_programt &goto_program = entry.second.body;
231+
if(!goto_program.empty())
232+
{
233+
end_function_map.emplace(
234+
entry.first, std::prev(goto_program.instructions.end()));
235+
}
236+
}
227237
}
228238

229239
void initialize(const irep_idt &function, const goto_programt &goto_program)
@@ -238,6 +248,9 @@ class dependence_grapht:
238248
{
239249
cfg_post_dominatorst &pd = post_dominators[function];
240250
pd(goto_program);
251+
252+
end_function_map.emplace(
253+
function, std::prev(goto_program.instructions.end()));
241254
}
242255
}
243256

@@ -273,6 +286,7 @@ class dependence_grapht:
273286

274287
post_dominators_mapt post_dominators;
275288
reaching_definitions_analysist rd;
289+
std::map<irep_idt, goto_programt::const_targett> end_function_map;
276290
};
277291

278292
#endif // CPROVER_ANALYSES_DEPENDENCE_GRAPH_H

src/analyses/reaching_definitions.cpp

-41
Original file line numberDiff line numberDiff line change
@@ -126,41 +126,6 @@ void rd_range_domaint::transform(
126126
// initial (non-deterministic) value
127127
else if(from->is_decl())
128128
transform_assign(ns, from, function_from, from, *rd);
129-
130-
#if 0
131-
// handle return values
132-
if(to->is_function_call())
133-
{
134-
const code_function_callt &code=to_code_function_call(to->code);
135-
136-
if(code.lhs().is_not_nil())
137-
{
138-
rw_range_set_value_sett rw_set(ns, rd->get_value_sets());
139-
goto_rw(to, rw_set);
140-
const bool is_must_alias=rw_set.get_w_set().size()==1;
141-
142-
for(const auto &written_object_entry : rw_set.get_w_set())
143-
{
144-
const irep_idt &identifier = written_object_entry.first;
145-
// ignore symex::invalid_object
146-
const symbolt *symbol_ptr;
147-
if(ns.lookup(identifier, symbol_ptr))
148-
continue;
149-
assert(symbol_ptr!=0);
150-
151-
const range_domaint &ranges =
152-
rw_set.get_ranges(written_object_entry.second);
153-
154-
if(is_must_alias &&
155-
(!rd->get_is_threaded()(from) ||
156-
(!symbol_ptr->is_shared() &&
157-
!rd->get_is_dirty()(identifier))))
158-
for(const auto &range : ranges)
159-
kill(identifier, range.first, range.second);
160-
}
161-
}
162-
}
163-
#endif
164129
}
165130

166131
/// Computes an instance obtained from a `*this` by transformation over `DEAD v`
@@ -322,12 +287,6 @@ void rd_range_domaint::transform_end_function(
322287
// handle return values
323288
if(call->call_lhs().is_not_nil())
324289
{
325-
#if 0
326-
rd_range_domaint *rd_state=
327-
dynamic_cast<rd_range_domaint*>(&(rd.get_state(call)));
328-
assert(rd_state!=0);
329-
rd_state->
330-
#endif
331290
transform_assign(ns, from, function_to, call, rd);
332291
}
333292
}

0 commit comments

Comments
 (0)