File tree Expand file tree Collapse file tree 10 files changed +119
-13
lines changed
regression/goto-instrument Expand file tree Collapse file tree 10 files changed +119
-13
lines changed Original file line number Diff line number Diff line change
1
+
2
+ int x ;
3
+
4
+ void g ()
5
+ {
6
+ x = 1 ;
7
+ }
8
+
9
+ void f ()
10
+ {
11
+ g ();
12
+ }
13
+
14
+ int main ()
15
+ {
16
+ f ();
17
+ }
18
+
Original file line number Diff line number Diff line change
1
+ CORE
2
+ main.c
3
+ --function-inline main --log -
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ ^VERIFICATION SUCCESSFUL$
7
+ --
8
+ ^warning: ignoring
Original file line number Diff line number Diff line change
1
+
2
+ int x ;
3
+
4
+ void h ()
5
+ {
6
+ x = 1 ;
7
+ }
8
+
9
+ void g ()
10
+ {
11
+ h ();
12
+ }
13
+
14
+ void f ()
15
+ {
16
+ g ();
17
+ }
18
+
19
+ int main ()
20
+ {
21
+ f ();
22
+ }
23
+
Original file line number Diff line number Diff line change
1
+ CORE
2
+ main.c
3
+ --function-inline main --log - --no-caching
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ ^VERIFICATION SUCCESSFUL$
7
+ --
8
+ ^warning: ignoring
Original file line number Diff line number Diff line change @@ -1052,6 +1052,8 @@ void goto_instrument_parse_optionst::instrument_goto_program()
1052
1052
std::string function=cmdline.get_value (" function-inline" );
1053
1053
assert (!function.empty ());
1054
1054
1055
+ bool caching=!cmdline.isset (" no-caching" );
1056
+
1055
1057
do_indirect_call_and_rtti_removal ();
1056
1058
1057
1059
status () << " Inlining calls of function `" << function << " '" << eom;
@@ -1063,7 +1065,8 @@ void goto_instrument_parse_optionst::instrument_goto_program()
1063
1065
function,
1064
1066
ns,
1065
1067
ui_message_handler,
1066
- true );
1068
+ true ,
1069
+ caching);
1067
1070
}
1068
1071
else
1069
1072
{
@@ -1076,7 +1079,8 @@ void goto_instrument_parse_optionst::instrument_goto_program()
1076
1079
function,
1077
1080
ns,
1078
1081
ui_message_handler,
1079
- true );
1082
+ true ,
1083
+ caching);
1080
1084
1081
1085
if (have_file)
1082
1086
{
@@ -1548,6 +1552,7 @@ void goto_instrument_parse_optionst::help()
1548
1552
" --inline perform full inlining\n "
1549
1553
" --partial-inline perform partial inlining\n "
1550
1554
" --function-inline <function> transitively inline all calls <function> makes\n " // NOLINT(*)
1555
+ " --no-caching disable caching of intermediate results during transitive function inlining\n " // NOLINT(*)
1551
1556
" --log <file> log in json format which code segments were inlined, use with --function-inline\n " // NOLINT(*)
1552
1557
" --remove-function-pointers replace function pointers by case statement over function calls\n " // NOLINT(*)
1553
1558
" --add-library add models of C library functions\n "
Original file line number Diff line number Diff line change 53
53
" (show-struct-alignment)(interval-analysis)(show-intervals)" \
54
54
" (show-uninitialized)(show-locations)" \
55
55
" (full-slice)(reachability-slice)(slice-global-inits)" \
56
- " (inline)(partial-inline)(function-inline):(log):" \
56
+ " (inline)(partial-inline)(function-inline):(log):(no-caching) " \
57
57
" (remove-function-pointers)" \
58
58
" (show-claims)(show-properties)(property):" \
59
59
" (show-symbol-table)(show-points-to)(show-rw-set)" \
Original file line number Diff line number Diff line change @@ -273,13 +273,15 @@ void goto_function_inline(
273
273
const irep_idt function,
274
274
const namespacet &ns,
275
275
message_handlert &message_handler,
276
- bool adjust_function)
276
+ bool adjust_function,
277
+ bool caching)
277
278
{
278
279
goto_inlinet goto_inline (
279
280
goto_functions,
280
281
ns,
281
282
message_handler,
282
- adjust_function);
283
+ adjust_function,
284
+ caching);
283
285
284
286
goto_functionst::function_mapt::iterator f_it=
285
287
goto_functions.function_map .find (function);
@@ -327,13 +329,15 @@ jsont goto_function_inline_and_log(
327
329
const irep_idt function,
328
330
const namespacet &ns,
329
331
message_handlert &message_handler,
330
- bool adjust_function)
332
+ bool adjust_function,
333
+ bool caching)
331
334
{
332
335
goto_inlinet goto_inline (
333
336
goto_functions,
334
337
ns,
335
338
message_handler,
336
- adjust_function);
339
+ adjust_function,
340
+ caching);
337
341
338
342
goto_functionst::function_mapt::iterator f_it=
339
343
goto_functions.function_map .find (function);
@@ -349,6 +353,7 @@ jsont goto_function_inline_and_log(
349
353
// gather all calls
350
354
goto_inlinet::inline_mapt inline_map;
351
355
356
+ // create empty call list
352
357
goto_inlinet::call_listt &call_list=inline_map[f_it->first ];
353
358
354
359
goto_programt &goto_program=goto_function.body ;
Original file line number Diff line number Diff line change @@ -50,20 +50,23 @@ void goto_function_inline(
50
50
goto_modelt &goto_model,
51
51
const irep_idt function,
52
52
message_handlert &message_handler,
53
- bool adjust_function=false );
53
+ bool adjust_function=false ,
54
+ bool caching=true );
54
55
55
56
void goto_function_inline (
56
57
goto_functionst &goto_functions,
57
58
const irep_idt function,
58
59
const namespacet &ns,
59
60
message_handlert &message_handler,
60
- bool adjust_function=false );
61
+ bool adjust_function=false ,
62
+ bool caching=true );
61
63
62
64
jsont goto_function_inline_and_log (
63
65
goto_functionst &goto_functions,
64
66
const irep_idt function,
65
67
const namespacet &ns,
66
68
message_handlert &message_handler,
67
- bool adjust_function=false );
69
+ bool adjust_function=false ,
70
+ bool caching=true );
68
71
69
72
#endif // CPROVER_GOTO_PROGRAMS_GOTO_INLINE_H
Original file line number Diff line number Diff line change @@ -682,6 +682,12 @@ void goto_inlinet::expand_function_call(
682
682
function,
683
683
arguments,
684
684
constrain);
685
+
686
+ if (!caching)
687
+ {
688
+ inline_log.cleanup (cached.body );
689
+ cache.erase (identifier);
690
+ }
685
691
}
686
692
else
687
693
{
@@ -1146,6 +1152,29 @@ void goto_inlinet::output_inline_map(
1146
1152
1147
1153
/* ******************************************************************\
1148
1154
1155
+ Function: output_cache
1156
+
1157
+ Inputs:
1158
+
1159
+ Outputs:
1160
+
1161
+ Purpose:
1162
+
1163
+ \*******************************************************************/
1164
+
1165
+ void goto_inlinet::output_cache (std::ostream &out) const
1166
+ {
1167
+ for (auto it=cache.begin (); it!=cache.end (); it++)
1168
+ {
1169
+ if (it!=cache.begin ())
1170
+ out << " , " ;
1171
+
1172
+ out << it->first << " \n " ;
1173
+ }
1174
+ }
1175
+
1176
+ /* ******************************************************************\
1177
+
1149
1178
Function: cleanup
1150
1179
1151
1180
Inputs:
@@ -1257,8 +1286,9 @@ void goto_inlinet::goto_inline_logt::copy_from(
1257
1286
assert (it1->location_number ==it2->location_number );
1258
1287
1259
1288
log_mapt::const_iterator l_it=log_map.find (it1);
1260
- if (l_it!=log_map.end ())
1289
+ if (l_it!=log_map.end ()) // a segment starts here
1261
1290
{
1291
+ // as 'to' is a fresh copy
1262
1292
assert (log_map.find (it2)==log_map.end ());
1263
1293
1264
1294
goto_inline_log_infot info=l_it->second ;
Original file line number Diff line number Diff line change @@ -24,11 +24,13 @@ class goto_inlinet:public messaget
24
24
goto_functionst &goto_functions,
25
25
const namespacet &ns,
26
26
message_handlert &message_handler,
27
- bool adjust_function):
27
+ bool adjust_function,
28
+ bool caching=true ):
28
29
messaget (message_handler),
29
30
goto_functions (goto_functions),
30
31
ns (ns),
31
- adjust_function (adjust_function)
32
+ adjust_function (adjust_function),
33
+ caching (caching)
32
34
{
33
35
}
34
36
@@ -64,6 +66,8 @@ class goto_inlinet:public messaget
64
66
std::ostream &out,
65
67
const inline_mapt &inline_map);
66
68
69
+ void output_cache (std::ostream &out) const ;
70
+
67
71
// call after goto_functions.update()!
68
72
jsont output_inline_log_json ()
69
73
{
@@ -127,6 +131,8 @@ class goto_inlinet:public messaget
127
131
const namespacet &ns;
128
132
129
133
const bool adjust_function;
134
+ const bool caching;
135
+
130
136
goto_inline_logt inline_log;
131
137
132
138
void goto_inline_nontransitive (
You can’t perform that action at this time.
0 commit comments