Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 5195a0c

Browse files
committedFeb 3, 2017
goto-instrument: remove virt calls and RTTI
This adds remove_virtual_functions and remove_instanceof calls to goto-instrument mirroring the situation in all other driver programs that use remove_function_pointers already.
1 parent be331e5 commit 5195a0c

File tree

2 files changed

+32
-29
lines changed

2 files changed

+32
-29
lines changed
 

‎src/goto-instrument/goto_instrument_parse_options.cpp

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Author: Daniel Kroening, kroening@kroening.com
1717

1818
#include <goto-programs/goto_convert_functions.h>
1919
#include <goto-programs/remove_function_pointers.h>
20+
#include <goto-programs/remove_virtual_functions.h>
21+
#include <goto-programs/remove_instanceof.h>
2022
#include <goto-programs/remove_skip.h>
2123
#include <goto-programs/goto_inline.h>
2224
#include <goto-programs/show_properties.h>
@@ -246,7 +248,7 @@ int goto_instrument_parse_optionst::doit()
246248

247249
if(cmdline.isset("show-value-sets"))
248250
{
249-
do_function_pointer_removal();
251+
do_indirect_call_and_rtti_removal();
250252
do_partial_inlining();
251253

252254
// recalculate numbers, etc.
@@ -263,7 +265,7 @@ int goto_instrument_parse_optionst::doit()
263265

264266
if(cmdline.isset("show-global-may-alias"))
265267
{
266-
do_function_pointer_removal();
268+
do_indirect_call_and_rtti_removal();
267269
do_partial_inlining();
268270
do_remove_returns();
269271
parameter_assignments(symbol_table, goto_functions);
@@ -281,7 +283,7 @@ int goto_instrument_parse_optionst::doit()
281283

282284
if(cmdline.isset("show-local-bitvector-analysis"))
283285
{
284-
do_function_pointer_removal();
286+
do_indirect_call_and_rtti_removal();
285287
do_partial_inlining();
286288
parameter_assignments(symbol_table, goto_functions);
287289

@@ -305,7 +307,7 @@ int goto_instrument_parse_optionst::doit()
305307

306308
if(cmdline.isset("show-custom-bitvector-analysis"))
307309
{
308-
do_function_pointer_removal();
310+
do_indirect_call_and_rtti_removal();
309311
do_partial_inlining();
310312
do_remove_returns();
311313
parameter_assignments(symbol_table, goto_functions);
@@ -331,7 +333,7 @@ int goto_instrument_parse_optionst::doit()
331333

332334
if(cmdline.isset("show-escape-analysis"))
333335
{
334-
do_function_pointer_removal();
336+
do_indirect_call_and_rtti_removal();
335337
do_partial_inlining();
336338
do_remove_returns();
337339
parameter_assignments(symbol_table, goto_functions);
@@ -351,7 +353,7 @@ int goto_instrument_parse_optionst::doit()
351353

352354
if(cmdline.isset("custom-bitvector-analysis"))
353355
{
354-
do_function_pointer_removal();
356+
do_indirect_call_and_rtti_removal();
355357
do_partial_inlining();
356358
do_remove_returns();
357359
parameter_assignments(symbol_table, goto_functions);
@@ -382,7 +384,7 @@ int goto_instrument_parse_optionst::doit()
382384

383385
if(cmdline.isset("show-points-to"))
384386
{
385-
do_function_pointer_removal();
387+
do_indirect_call_and_rtti_removal();
386388
do_partial_inlining();
387389

388390
// recalculate numbers, etc.
@@ -399,7 +401,7 @@ int goto_instrument_parse_optionst::doit()
399401

400402
if(cmdline.isset("show-intervals"))
401403
{
402-
do_function_pointer_removal();
404+
do_indirect_call_and_rtti_removal();
403405
do_partial_inlining();
404406

405407
// recalculate numbers, etc.
@@ -433,7 +435,7 @@ int goto_instrument_parse_optionst::doit()
433435

434436
if(!cmdline.isset("inline"))
435437
{
436-
do_function_pointer_removal();
438+
do_indirect_call_and_rtti_removal();
437439
do_partial_inlining();
438440

439441
// recalculate numbers, etc.
@@ -460,7 +462,7 @@ int goto_instrument_parse_optionst::doit()
460462

461463
if(cmdline.isset("show-reaching-definitions"))
462464
{
463-
do_function_pointer_removal();
465+
do_indirect_call_and_rtti_removal();
464466

465467
const namespacet ns(symbol_table);
466468
reaching_definitions_analysist rd_analysis(ns);
@@ -483,7 +485,7 @@ int goto_instrument_parse_optionst::doit()
483485

484486
if(cmdline.isset("show-dependence-graph"))
485487
{
486-
do_function_pointer_removal();
488+
do_indirect_call_and_rtti_removal();
487489

488490
const namespacet ns(symbol_table);
489491
dependence_grapht dependence_graph(ns);
@@ -674,7 +676,7 @@ int goto_instrument_parse_optionst::doit()
674676

675677
if(cmdline.isset("accelerate"))
676678
{
677-
do_function_pointer_removal();
679+
do_indirect_call_and_rtti_removal();
678680

679681
namespacet ns(symbol_table);
680682

@@ -757,7 +759,7 @@ int goto_instrument_parse_optionst::doit()
757759

758760
/*******************************************************************\
759761
760-
Function: goto_instrument_parse_optionst::do_function_pointer_removal
762+
Function: goto_instrument_parse_optionst::do_indirect_call_and_rtti_removal
761763
762764
Inputs:
763765
@@ -767,9 +769,10 @@ Function: goto_instrument_parse_optionst::do_function_pointer_removal
767769
768770
\*******************************************************************/
769771

770-
void goto_instrument_parse_optionst::do_function_pointer_removal()
772+
void goto_instrument_parse_optionst::do_indirect_call_and_rtti_removal(
773+
bool force)
771774
{
772-
if(function_pointer_removal_done)
775+
if(function_pointer_removal_done && !force)
773776
return;
774777

775778
function_pointer_removal_done=true;
@@ -779,6 +782,10 @@ void goto_instrument_parse_optionst::do_function_pointer_removal()
779782
symbol_table,
780783
goto_functions,
781784
cmdline.isset("pointer-check"));
785+
status() << "Virtual function removal" << eom;
786+
remove_virtual_functions(symbol_table, goto_functions);
787+
status() << "Java instanceof removal" << eom;
788+
remove_instanceof(symbol_table, goto_functions);
782789
}
783790

784791
/*******************************************************************\
@@ -954,7 +961,7 @@ void goto_instrument_parse_optionst::instrument_goto_program()
954961
// now do full inlining, if requested
955962
if(cmdline.isset("inline"))
956963
{
957-
do_function_pointer_removal();
964+
do_indirect_call_and_rtti_removal();
958965

959966
if(cmdline.isset("show-custom-bitvector-analysis") ||
960967
cmdline.isset("custom-bitvector-analysis"))
@@ -980,7 +987,7 @@ void goto_instrument_parse_optionst::instrument_goto_program()
980987

981988
if(cmdline.isset("escape-analysis"))
982989
{
983-
do_function_pointer_removal();
990+
do_indirect_call_and_rtti_removal();
984991
do_partial_inlining();
985992
do_remove_returns();
986993
parameter_assignments(symbol_table, goto_functions);
@@ -1009,14 +1016,14 @@ void goto_instrument_parse_optionst::instrument_goto_program()
10091016

10101017
// replace function pointers, if explicitly requested
10111018
if(cmdline.isset("remove-function-pointers"))
1012-
do_function_pointer_removal();
1019+
do_indirect_call_and_rtti_removal();
10131020

10141021
if(cmdline.isset("function-inline"))
10151022
{
10161023
std::string function=cmdline.get_value("function-inline");
10171024
assert(!function.empty());
10181025

1019-
do_function_pointer_removal();
1026+
do_indirect_call_and_rtti_removal();
10201027

10211028
status() << "Inlining calls of function `" << function << "'" << eom;
10221029

@@ -1067,7 +1074,7 @@ void goto_instrument_parse_optionst::instrument_goto_program()
10671074

10681075
if(cmdline.isset("partial-inline"))
10691076
{
1070-
do_function_pointer_removal();
1077+
do_indirect_call_and_rtti_removal();
10711078

10721079
status() << "Partial inlining" << eom;
10731080
goto_partial_inline(goto_functions, ns, ui_message_handler, true);
@@ -1079,11 +1086,7 @@ void goto_instrument_parse_optionst::instrument_goto_program()
10791086
// now do full inlining, if requested
10801087
if(cmdline.isset("inline"))
10811088
{
1082-
status() << "Function Pointer Removal" << eom;
1083-
remove_function_pointers(
1084-
symbol_table,
1085-
goto_functions,
1086-
cmdline.isset("pointer-check"));
1089+
do_indirect_call_and_rtti_removal(/*force=*/true);
10871090

10881091
if(cmdline.isset("show-custom-bitvector-analysis") ||
10891092
cmdline.isset("custom-bitvector-analysis"))
@@ -1099,7 +1102,7 @@ void goto_instrument_parse_optionst::instrument_goto_program()
10991102

11001103
if(cmdline.isset("constant-propagator"))
11011104
{
1102-
do_function_pointer_removal();
1105+
do_indirect_call_and_rtti_removal();
11031106

11041107
status() << "Propagating Constants" << eom;
11051108

@@ -1161,7 +1164,7 @@ void goto_instrument_parse_optionst::instrument_goto_program()
11611164
cmdline.isset("isr") ||
11621165
cmdline.isset("concurrency"))
11631166
{
1164-
do_function_pointer_removal();
1167+
do_indirect_call_and_rtti_removal();
11651168
do_partial_inlining();
11661169

11671170
status() << "Pointer Analysis" << eom;
@@ -1400,7 +1403,7 @@ void goto_instrument_parse_optionst::instrument_goto_program()
14001403
// full slice?
14011404
if(cmdline.isset("full-slice"))
14021405
{
1403-
do_function_pointer_removal();
1406+
do_indirect_call_and_rtti_removal();
14041407

14051408
status() << "Performing a full slice" << eom;
14061409
if(cmdline.isset("property"))

‎src/goto-instrument/goto_instrument_parse_options.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class goto_instrument_parse_optionst:
9696

9797
void eval_verbosity();
9898

99-
void do_function_pointer_removal();
99+
void do_indirect_call_and_rtti_removal(bool force=false);
100100
void do_partial_inlining();
101101
void do_remove_returns();
102102

0 commit comments

Comments
 (0)
Please sign in to comment.