File tree 11 files changed +43
-88
lines changed
11 files changed +43
-88
lines changed Original file line number Diff line number Diff line change @@ -84,20 +84,11 @@ int linker_script_merget::add_linker_script_definitions()
84
84
<< messaget::eom;
85
85
return fail;
86
86
}
87
- if (
88
- original_goto_model->goto_functions .function_map .erase (
89
- INITIALIZE_FUNCTION) != 0 )
87
+
88
+ if (original_goto_model->can_produce_function (INITIALIZE_FUNCTION))
90
89
{
91
- static_lifetime_init (
92
- original_goto_model->symbol_table ,
93
- original_goto_model->symbol_table .lookup_ref (INITIALIZE_FUNCTION)
94
- .location );
95
- goto_convert (
96
- INITIALIZE_FUNCTION,
97
- original_goto_model->symbol_table ,
98
- original_goto_model->goto_functions ,
99
- log .get_message_handler ());
100
- original_goto_model->goto_functions .update ();
90
+ recreate_initialize_function (
91
+ *original_goto_model, log .get_message_handler ());
101
92
}
102
93
103
94
fail=goto_and_object_mismatch (linker_defined_symbols, linker_values);
Original file line number Diff line number Diff line change @@ -560,8 +560,8 @@ void dfcct::reinitialize_model()
560
560
swap_and_wrap.get_swapped_functions (instrumented_functions);
561
561
562
562
log .status () << " Updating init function" << messaget::eom;
563
- utils. create_initialize_function ();
564
- goto_model. goto_functions . update ( );
563
+ if (goto_model. can_produce_function (INITIALIZE_FUNCTION))
564
+ recreate_initialize_function (goto_model, message_handler );
565
565
nondet_static (goto_model, to_exclude_from_nondet_static);
566
566
567
567
// Initialize the map of instrumented functions by adding extra instructions
Original file line number Diff line number Diff line change @@ -140,22 +140,6 @@ const symbolt &dfcc_utilst::create_static_symbol(
140
140
return symbol;
141
141
}
142
142
143
- void dfcc_utilst::create_initialize_function ()
144
- {
145
- if (goto_model.goto_functions .function_map .erase (INITIALIZE_FUNCTION) != 0 )
146
- {
147
- static_lifetime_init (
148
- goto_model.symbol_table ,
149
- goto_model.symbol_table .lookup_ref (INITIALIZE_FUNCTION).location );
150
- goto_convert (
151
- INITIALIZE_FUNCTION,
152
- goto_model.symbol_table ,
153
- goto_model.goto_functions ,
154
- message_handler);
155
- goto_model.goto_functions .update ();
156
- }
157
- }
158
-
159
143
void dfcc_utilst::fix_parameters_symbols (const irep_idt &function_id)
160
144
{
161
145
auto &function_symbol = get_function_symbol (function_id);
Original file line number Diff line number Diff line change @@ -82,10 +82,6 @@ class dfcc_utilst
82
82
const exprt &initial_value,
83
83
const bool no_nondet_initialization = true );
84
84
85
- // / Regenerates the CPROVER_INITIALIZE function which defines all global
86
- // / statics of the goto model.
87
- void create_initialize_function ();
88
-
89
85
// / Creates a new parameter symbol for the given function_id
90
86
const symbolt &create_new_parameter_symbol (
91
87
const irep_idt &function_id,
Original file line number Diff line number Diff line change @@ -210,18 +210,8 @@ void is_fresh_baset::add_declarations(const std::string &decl_string)
210
210
}
211
211
}
212
212
213
- if (goto_model.goto_functions .function_map .erase (INITIALIZE_FUNCTION) != 0 )
214
- {
215
- static_lifetime_init (
216
- goto_model.symbol_table ,
217
- goto_model.symbol_table .lookup_ref (INITIALIZE_FUNCTION).location );
218
- goto_convert (
219
- INITIALIZE_FUNCTION,
220
- goto_model.symbol_table ,
221
- goto_model.goto_functions ,
222
- log .get_message_handler ());
223
- goto_model.goto_functions .update ();
224
- }
213
+ if (goto_model.can_produce_function (INITIALIZE_FUNCTION))
214
+ recreate_initialize_function (goto_model, message_handler);
225
215
}
226
216
227
217
void is_fresh_baset::update_fn_call (
Original file line number Diff line number Diff line change @@ -40,18 +40,8 @@ static symbol_exprt add_stack_depth_symbol(
40
40
bool failed = goto_model.symbol_table .add (new_symbol);
41
41
CHECK_RETURN (!failed);
42
42
43
- if (goto_model.goto_functions .function_map .erase (INITIALIZE_FUNCTION) != 0 )
44
- {
45
- static_lifetime_init (
46
- goto_model.symbol_table ,
47
- goto_model.symbol_table .lookup_ref (INITIALIZE_FUNCTION).location );
48
- goto_convert (
49
- INITIALIZE_FUNCTION,
50
- goto_model.symbol_table ,
51
- goto_model.goto_functions ,
52
- message_handler);
53
- goto_model.goto_functions .update ();
54
- }
43
+ if (goto_model.can_produce_function (INITIALIZE_FUNCTION))
44
+ recreate_initialize_function (goto_model, message_handler);
55
45
56
46
return new_symbol.symbol_expr ();
57
47
}
Original file line number Diff line number Diff line change @@ -159,19 +159,8 @@ void link_to_library(
159
159
break ;
160
160
}
161
161
162
- if (need_reinit)
163
- {
164
- goto_model.unload (INITIALIZE_FUNCTION);
165
- static_lifetime_init (
166
- goto_model.symbol_table ,
167
- goto_model.symbol_table .lookup_ref (INITIALIZE_FUNCTION).location );
168
- goto_convert (
169
- INITIALIZE_FUNCTION,
170
- goto_model.symbol_table ,
171
- goto_model.goto_functions ,
172
- message_handler);
173
- goto_model.goto_functions .update ();
174
- }
162
+ if (need_reinit && goto_model.can_produce_function (INITIALIZE_FUNCTION))
163
+ recreate_initialize_function (goto_model, message_handler);
175
164
176
165
if (!object_type_updates.empty ())
177
166
finalize_linking (goto_model, object_type_updates);
Original file line number Diff line number Diff line change @@ -22,7 +22,6 @@ Date: December 2016
22
22
23
23
#include < linking/static_lifetime_init.h>
24
24
25
- #include " goto_convert_functions.h"
26
25
#include " goto_functions.h"
27
26
#include " goto_model.h"
28
27
@@ -132,18 +131,6 @@ void slice_global_inits(
132
131
}
133
132
}
134
133
135
- if (
136
- changed &&
137
- goto_model.goto_functions .function_map .erase (INITIALIZE_FUNCTION) != 0 )
138
- {
139
- static_lifetime_init (
140
- goto_model.symbol_table ,
141
- goto_model.symbol_table .lookup_ref (INITIALIZE_FUNCTION).location );
142
- goto_convert (
143
- INITIALIZE_FUNCTION,
144
- goto_model.symbol_table ,
145
- goto_model.goto_functions ,
146
- message_handler);
147
- goto_model.goto_functions .update ();
148
- }
134
+ if (changed && goto_model.can_produce_function (INITIALIZE_FUNCTION))
135
+ recreate_initialize_function (goto_model, message_handler);
149
136
}
Original file line number Diff line number Diff line change @@ -3,4 +3,4 @@ add_library(linking ${sources})
3
3
4
4
generic_includes(linking)
5
5
6
- target_link_libraries (linking util)
6
+ target_link_libraries (linking goto-programs util)
Original file line number Diff line number Diff line change 16
16
#include < util/std_code.h>
17
17
#include < util/symbol_table_base.h>
18
18
19
+ #include < goto-programs/goto_convert_functions.h>
20
+ #include < goto-programs/goto_model.h>
21
+
19
22
#include < set>
20
23
21
24
static optionalt<codet> static_lifetime_init (
@@ -157,3 +160,21 @@ void static_lifetime_init(
157
160
}
158
161
}
159
162
}
163
+
164
+ void recreate_initialize_function (
165
+ goto_modelt &goto_model,
166
+ message_handlert &message_handler)
167
+ {
168
+ auto unloaded = goto_model.unload (INITIALIZE_FUNCTION);
169
+ PRECONDITION (unloaded == 1 );
170
+
171
+ static_lifetime_init (
172
+ goto_model.symbol_table ,
173
+ goto_model.symbol_table .lookup_ref (INITIALIZE_FUNCTION).location );
174
+ goto_convert (
175
+ INITIALIZE_FUNCTION,
176
+ goto_model.symbol_table ,
177
+ goto_model.goto_functions ,
178
+ message_handler);
179
+ goto_model.goto_functions .update ();
180
+ }
Original file line number Diff line number Diff line change 12
12
13
13
#include < util/cprover_prefix.h>
14
14
15
+ class goto_modelt ;
16
+ class message_handlert ;
15
17
class source_locationt ;
16
18
class symbol_table_baset ;
17
19
@@ -21,4 +23,9 @@ void static_lifetime_init(
21
23
22
24
#define INITIALIZE_FUNCTION CPROVER_PREFIX " initialize"
23
25
26
+ // / Regenerates the CPROVER_INITIALIZE function, which initializes all
27
+ // / non-function symbols of the goto model that have static lifetime. It is an
28
+ // / error if CPROVER_INITIALIZE was not present beforehand.
29
+ void recreate_initialize_function (goto_modelt &, message_handlert &);
30
+
24
31
#endif // CPROVER_LINKING_STATIC_LIFETIME_INIT_H
You can’t perform that action at this time.
0 commit comments