Skip to content

Commit

Permalink
Library functions: mark them as compiled
Browse files Browse the repository at this point in the history
When adding library functions to the goto model we no longer need their
function bodies as values in the symbol table. Marking them as
"compiled" will make sure we don't re-convert them in any subsequent run
(e.g., running cbmc after goto-instrument). Doing so would undo any
application of "drop-unused-functions." This was most notable with
contracts/dynamic frames, where we ended up reporting thousands of
properties as "SUCCESS" in library functions that were never actually
called. For some contracts examples this now reduces the number of
properties reported from over a thousand to tens of properties.
  • Loading branch information
tautschnig committed Aug 13, 2024
1 parent 0760cd7 commit 40727c3
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions regression/contracts-dfcc/chain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,6 @@ elif echo $args_inst | grep -q -- "--dump-c" ; then

rm "${name}${dfcc_suffix}-mod.c"
fi
$goto_instrument --drop-unused-functions "${name}${dfcc_suffix}-mod.gb" "${name}${dfcc_suffix}-mod.gb"
$goto_instrument --show-goto-functions "${name}${dfcc_suffix}-mod.gb"
$cbmc "${name}${dfcc_suffix}-mod.gb" ${args_cbmc}
1 change: 1 addition & 0 deletions regression/contracts/chain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@ elif echo $args_inst | grep -q -- "--dump-c" ; then

rm "${name}-mod.c"
fi
$goto_instrument --drop-unused-functions "${name}-mod.gb" "${name}-mod.gb"
$goto_instrument --show-goto-functions "${name}-mod.gb"
$cbmc "${name}-mod.gb" ${args_cbmc}
3 changes: 3 additions & 0 deletions src/ansi-c/goto-conversion/link_to_library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ add_one_function(
library_model.symbol_table,
library_model.goto_functions,
message_handler);
library_model.symbol_table.get_writeable_ref(missing_function)
.set_compiled();
}
// We might need a function that's outside our own library, but brought in via
// some header file included by the library. Those functions already exist in
Expand All @@ -61,6 +63,7 @@ add_one_function(
goto_model.symbol_table,
library_model.goto_functions,
message_handler);
goto_model.symbol_table.get_writeable_ref(missing_function).set_compiled();
}

// check whether additional initialization may be required
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ void dfcc_libraryt::load(std::set<irep_idt> &to_instrument)
{
goto_convert(
id, goto_model.symbol_table, goto_model.goto_functions, message_handler);
goto_model.symbol_table.get_writeable_ref(id).set_compiled();
}

// check that all symbols have a goto_implementation
Expand Down

0 comments on commit 40727c3

Please sign in to comment.