Skip to content

Commit fe75b71

Browse files
tautschnigDaniel Kroening
authored and
Daniel Kroening
committed
goto-symex: move safe_pointers to path storage
As local_safe_pointerst no longer needs a namespace we can do a partial revert of 959c7a5 (Bugfix: Maintain safe_pointers per-path). On SV-COMP's ReachSafety-ECA, copying safe_pointers accounted for 14% of the time spent in goto_symext::symex_goto (715 of 5119 seconds).
1 parent 7bddbb0 commit fe75b71

File tree

6 files changed

+17
-15
lines changed

6 files changed

+17
-15
lines changed

src/goto-symex/goto_symex.h

-2
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ Author: Daniel Kroening, [email protected]
1717

1818
#include <goto-programs/abstract_goto_model.h>
1919

20-
#include "goto_symex_state.h"
2120
#include "path_storage.h"
22-
#include "symex_target_equation.h"
2321

2422
class byte_extract_exprt;
2523
class typet;

src/goto-symex/goto_symex_state.h

-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ Author: Daniel Kroening, [email protected]
1616
#include <unordered_set>
1717

1818
#include <analyses/dirty.h>
19-
#include <analyses/local_safe_pointers.h>
2019

2120
#include <util/invariant.h>
2221
#include <util/guard.h>
@@ -68,7 +67,6 @@ class goto_statet
6867
/// Threads
6968
unsigned atomic_section_id = 0;
7069

71-
std::unordered_map<irep_idt, local_safe_pointerst> safe_pointers;
7270
unsigned total_vccs = 0;
7371
unsigned remaining_vccs = 0;
7472

@@ -325,7 +323,6 @@ inline goto_statet::goto_statet(const class goto_symex_statet &s)
325323
source(s.source),
326324
propagation(s.propagation),
327325
atomic_section_id(s.atomic_section_id),
328-
safe_pointers(s.safe_pointers),
329326
total_vccs(s.total_vccs),
330327
remaining_vccs(s.remaining_vccs)
331328
{

src/goto-symex/path_storage.h

+13-5
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,18 @@
55
#ifndef CPROVER_GOTO_SYMEX_PATH_STORAGE_H
66
#define CPROVER_GOTO_SYMEX_PATH_STORAGE_H
77

8-
#include "goto_symex_state.h"
9-
#include "symex_target_equation.h"
10-
11-
#include <util/options.h>
128
#include <util/cmdline.h>
13-
#include <util/ui_message.h>
149
#include <util/invariant.h>
10+
#include <util/message.h>
11+
#include <util/options.h>
12+
13+
#include <analyses/local_safe_pointers.h>
1514

1615
#include <memory>
1716

17+
#include "goto_symex_state.h"
18+
#include "symex_target_equation.h"
19+
1820
/// Functor generating fresh nondet symbols
1921
class symex_nondet_generatort
2022
{
@@ -90,6 +92,12 @@ class path_storaget
9092
/// Counter for nondet objects, which require unique names
9193
symex_nondet_generatort build_symex_nondet;
9294

95+
/// Map function identifiers to \ref local_safe_pointerst instances. This is
96+
/// to identify derferences that are guaranteed to be safe in a given
97+
/// execution context, thus helping to avoid symex to follow spurious
98+
/// error-handling paths.
99+
std::unordered_map<irep_idt, local_safe_pointerst> safe_pointers;
100+
93101
private:
94102
// Derived classes should override these methods, allowing the base class to
95103
// enforce preconditions.

src/goto-symex/symex_dereference.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,8 @@ void goto_symext::dereference_rec(exprt &expr, statet &state)
211211
{
212212
get_original_name(to_check);
213213

214-
expr_is_not_null =
215-
state.safe_pointers.at(expr_function).is_safe_dereference(
216-
to_check, state.source.pc);
214+
expr_is_not_null = path_storage.safe_pointers.at(expr_function)
215+
.is_safe_dereference(to_check, state.source.pc);
217216
}
218217
}
219218

src/goto-symex/symex_function_call.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ void goto_symext::symex_function_call_code(
229229
state.dirty.populate_dirty_for_function(identifier, goto_function);
230230

231231
auto emplace_safe_pointers_result =
232-
state.safe_pointers.emplace(identifier, local_safe_pointerst{});
232+
path_storage.safe_pointers.emplace(identifier, local_safe_pointerst{});
233233
if(emplace_safe_pointers_result.second)
234234
emplace_safe_pointers_result.first->second(goto_function.body);
235235

src/goto-symex/symex_main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ std::unique_ptr<goto_symext::statet> goto_symext::initialize_entry_point_state(
310310

311311
// initialize support analyses
312312
auto emplace_safe_pointers_result =
313-
state->safe_pointers.emplace(entry_point_id, local_safe_pointerst{});
313+
path_storage.safe_pointers.emplace(entry_point_id, local_safe_pointerst{});
314314
if(emplace_safe_pointers_result.second)
315315
emplace_safe_pointers_result.first->second(start_function->body);
316316

0 commit comments

Comments
 (0)