Skip to content

Commit 7b8a4e6

Browse files
authored
Merge pull request #654 from danpoe/inlining-no-caching
Option to disable caching for inlining
2 parents 7a8961e + 0f0ab68 commit 7b8a4e6

File tree

12 files changed

+163
-13
lines changed

12 files changed

+163
-13
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
--function-inline main --log -
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
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
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
--function-inline main --log - --no-caching --verbosity 9
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring

src/goto-instrument/goto_instrument_parse_options.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,6 +1052,8 @@ void goto_instrument_parse_optionst::instrument_goto_program()
10521052
std::string function=cmdline.get_value("function-inline");
10531053
assert(!function.empty());
10541054

1055+
bool caching=!cmdline.isset("no-caching");
1056+
10551057
do_indirect_call_and_rtti_removal();
10561058

10571059
status() << "Inlining calls of function `" << function << "'" << eom;
@@ -1063,7 +1065,8 @@ void goto_instrument_parse_optionst::instrument_goto_program()
10631065
function,
10641066
ns,
10651067
ui_message_handler,
1066-
true);
1068+
true,
1069+
caching);
10671070
}
10681071
else
10691072
{
@@ -1076,7 +1079,8 @@ void goto_instrument_parse_optionst::instrument_goto_program()
10761079
function,
10771080
ns,
10781081
ui_message_handler,
1079-
true);
1082+
true,
1083+
caching);
10801084

10811085
if(have_file)
10821086
{
@@ -1548,6 +1552,7 @@ void goto_instrument_parse_optionst::help()
15481552
" --inline perform full inlining\n"
15491553
" --partial-inline perform partial inlining\n"
15501554
" --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(*)
15511556
" --log <file> log in json format which code segments were inlined, use with --function-inline\n" // NOLINT(*)
15521557
" --remove-function-pointers replace function pointers by case statement over function calls\n" // NOLINT(*)
15531558
" --add-library add models of C library functions\n"

src/goto-instrument/goto_instrument_parse_options.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Author: Daniel Kroening, [email protected]
5353
"(show-struct-alignment)(interval-analysis)(show-intervals)" \
5454
"(show-uninitialized)(show-locations)" \
5555
"(full-slice)(reachability-slice)(slice-global-inits)" \
56-
"(inline)(partial-inline)(function-inline):(log):" \
56+
"(inline)(partial-inline)(function-inline):(log):(no-caching)" \
5757
"(remove-function-pointers)" \
5858
"(show-claims)(show-properties)(property):" \
5959
"(show-symbol-table)(show-points-to)(show-rw-set)" \

src/goto-programs/goto_inline.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,13 +273,15 @@ void goto_function_inline(
273273
const irep_idt function,
274274
const namespacet &ns,
275275
message_handlert &message_handler,
276-
bool adjust_function)
276+
bool adjust_function,
277+
bool caching)
277278
{
278279
goto_inlinet goto_inline(
279280
goto_functions,
280281
ns,
281282
message_handler,
282-
adjust_function);
283+
adjust_function,
284+
caching);
283285

284286
goto_functionst::function_mapt::iterator f_it=
285287
goto_functions.function_map.find(function);
@@ -327,13 +329,15 @@ jsont goto_function_inline_and_log(
327329
const irep_idt function,
328330
const namespacet &ns,
329331
message_handlert &message_handler,
330-
bool adjust_function)
332+
bool adjust_function,
333+
bool caching)
331334
{
332335
goto_inlinet goto_inline(
333336
goto_functions,
334337
ns,
335338
message_handler,
336-
adjust_function);
339+
adjust_function,
340+
caching);
337341

338342
goto_functionst::function_mapt::iterator f_it=
339343
goto_functions.function_map.find(function);
@@ -349,6 +353,7 @@ jsont goto_function_inline_and_log(
349353
// gather all calls
350354
goto_inlinet::inline_mapt inline_map;
351355

356+
// create empty call list
352357
goto_inlinet::call_listt &call_list=inline_map[f_it->first];
353358

354359
goto_programt &goto_program=goto_function.body;

src/goto-programs/goto_inline.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,23 @@ void goto_function_inline(
5050
goto_modelt &goto_model,
5151
const irep_idt function,
5252
message_handlert &message_handler,
53-
bool adjust_function=false);
53+
bool adjust_function=false,
54+
bool caching=true);
5455

5556
void goto_function_inline(
5657
goto_functionst &goto_functions,
5758
const irep_idt function,
5859
const namespacet &ns,
5960
message_handlert &message_handler,
60-
bool adjust_function=false);
61+
bool adjust_function=false,
62+
bool caching=true);
6163

6264
jsont goto_function_inline_and_log(
6365
goto_functionst &goto_functions,
6466
const irep_idt function,
6567
const namespacet &ns,
6668
message_handlert &message_handler,
67-
bool adjust_function=false);
69+
bool adjust_function=false,
70+
bool caching=true);
6871

6972
#endif // CPROVER_GOTO_PROGRAMS_GOTO_INLINE_H

0 commit comments

Comments
 (0)