Skip to content

Commit e4d4ff4

Browse files
committed
Enable merge_ireps for goto traces
A goto trace includes freshly constructed expressions, which thus lack sharing. This results in excessive memory use when storing multiple traces, as is done for coverage computation. On a particular benchmark, coverage computation previously ran out of memory at 768 GB. This same benchmark can now be run with just 80 GB of memory.
1 parent 4743cb9 commit e4d4ff4

File tree

4 files changed

+34
-0
lines changed

4 files changed

+34
-0
lines changed

src/goto-checker/goto_trace_storage.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ const goto_tracet &goto_trace_storaget::insert(goto_tracet &&trace)
2727
emplace_result.second,
2828
"cannot associate more than one error trace with property " +
2929
id2string(last_step.property_id));
30+
31+
for(auto &step : traces.back().steps)
32+
step.merge_ireps(merge_ireps);
33+
3034
return traces.back();
3135
}
3236

@@ -40,6 +44,10 @@ const goto_tracet &goto_trace_storaget::insert_all(goto_tracet &&trace)
4044
{
4145
property_id_to_trace_index.emplace(property_id, traces.size() - 1);
4246
}
47+
48+
for(auto &step : traces.back().steps)
49+
step.merge_ireps(merge_ireps);
50+
4351
return traces.back();
4452
}
4553

src/goto-checker/goto_trace_storage.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Author: Daniel Kroening, Peter Schrammel
1414

1515
#include <goto-programs/goto_trace.h>
1616

17+
#include <util/merge_irep.h>
18+
1719
#include <list>
1820

1921
class goto_trace_storaget
@@ -44,6 +46,9 @@ class goto_trace_storaget
4446

4547
// maps property ID to index in traces
4648
std::unordered_map<irep_idt, std::size_t> property_id_to_trace_index;
49+
50+
/// irep container for shared ireps
51+
merge_irept merge_ireps;
4752
};
4853

4954
#endif // CPROVER_GOTO_CHECKER_GOTO_TRACE_STORAGE_H

src/goto-programs/goto_trace.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Author: Daniel Kroening
1818
#include <util/arith_tools.h>
1919
#include <util/byte_operators.h>
2020
#include <util/format_expr.h>
21+
#include <util/merge_irep.h>
2122
#include <util/range.h>
2223
#include <util/string_utils.h>
2324
#include <util/symbol.h>
@@ -133,6 +134,20 @@ void goto_trace_stept::output(
133134

134135
out << '\n';
135136
}
137+
138+
void goto_trace_stept::merge_ireps(merge_irept &dest)
139+
{
140+
dest(cond_expr);
141+
dest(full_lhs);
142+
dest(full_lhs_value);
143+
144+
for(auto &io_arg : io_args)
145+
dest(io_arg);
146+
147+
for(auto &function_arg : function_arguments)
148+
dest(function_arg);
149+
}
150+
136151
/// Returns the numeric representation of an expression, based on
137152
/// options. The default is binary without a base-prefix. Setting
138153
/// options.hex_representation to be true outputs hex format. Setting

src/goto-programs/goto_trace.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ Date: July 2005
2424

2525
#include <goto-programs/goto_program.h>
2626

27+
class merge_irept;
28+
2729
/// Step of the trace of a GOTO program
2830
///
2931
/// A step is either:
@@ -162,6 +164,10 @@ class goto_trace_stept
162164
full_lhs_value.make_nil();
163165
cond_expr.make_nil();
164166
}
167+
168+
/// Use \p dest to establish sharing among ireps.
169+
/// \param [out] dest: irep storage container.
170+
void merge_ireps(merge_irept &dest);
165171
};
166172

167173
/// Trace of a GOTO program.

0 commit comments

Comments
 (0)