Skip to content

goto-symex: drop the field names of parameters when a function returns - #9634

Draft
tautschnig wants to merge 1 commit into
diffblue:developfrom
tautschnig:kiro/symex-pop-frame-field-names
Draft

tautschnig wants to merge 1 commit into
diffblue:developfrom
tautschnig:kiro/symex-pop-frame-field-names

Conversation

@tautschnig

Copy link
Copy Markdown
Collaborator

When a function returns, pop_frame drops the L2 names of its local objects so that later merges of paths do not assign them. It looks the objects up by their own L1 name, but field sensitivity gives a struct (or an array of at most --max-field-sensitivity-array-size elements) one L2 name per field and none for the whole object. The fields of struct parameters, which never have a DEAD instruction, therefore stayed live for the rest of symbolic execution, and every later merge where one path had called the function assigned each of them again (a phi step per field and merge). DEAD had a smaller gap of the same kind: it dropped the members of a union but not the union's own name, which field sensitivity also tracks.

pop_frame now also drops the names of the fields of the frame's objects that field sensitivity divides, as DEAD does, except for objects whose address is taken: string abstraction returns pointers to local dummy objects and reads them after the function returned (regression/cbmc String_Abstraction19 and Malloc13 fail otherwise). DEAD also drops the own name of a divided union.

Programs that pass structs by value to functions called on some paths only gain most. A C program that calls a function with a struct parameter (a tag, a union and a pointer) on some paths of a loop of 100 iterations takes 2,730 instead of 3,330 SSA steps. A Lua front end built on CBMC, whose runtime model passes a struct of ten L2 names to most of its functions, saw 13 % to 59 % fewer steps on six small programs with symbolic table keys (a weak table: 330,266 to 177,217 steps; symbolic appends: 221,728 to 108,752).

regression/cbmc/dead-field-names checks that no merge assigns the fields of a returned parameter or of a dead local union (test.desc fails on develop; verify.desc checks the verdict).

scripts/profile_cbmc.py --auto-large --runs 3: the same steps on all ten benchmarks; pre-solver time -1.5 % to +25.5 % across runs in both orders on a host shared with other jobs (load 7 to 23), within its noise.

regression/cbmc (also with --paths lifo), cbmc-concurrency, cbmc-cpp, cbmc-cover, cbmc-shadow-memory and cbmc-primitives pass with --validate-goto-model --validate-ssa-equation; cbmc-library's mmap/test, mmap/test_02 and munmap/test fail with these options, as on develop.

  • Each commit message has a non-empty body, explaining why the change was made.
  • n/a Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • n/a The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • n/a My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • n/a White-space or formatting changes outside the feature-related changed lines are in commits of their own.

When a function returns, pop_frame drops the L2 names of its local
objects so that later merges of paths do not assign them. It looks the
objects up by their own L1 name, but field sensitivity gives a struct (or
an array of at most --max-field-sensitivity-array-size elements) one L2
name per field and none for the whole object. The fields of struct
parameters, which never have a DEAD instruction, therefore stayed live
for the rest of symbolic execution, and every later merge where one path
had called the function assigned each of them again (a phi step per
field and merge). DEAD had a smaller gap of the same kind: it dropped the
members of a union but not the union's own name, which field sensitivity
also tracks.

pop_frame now also drops the names of the fields of the frame's objects
that field sensitivity divides, as DEAD does, except for objects whose
address is taken: string abstraction returns pointers to local dummy
objects and reads them after the function returned (regression/cbmc
String_Abstraction19 and Malloc13 fail otherwise). DEAD also drops the
own name of a divided union.

Programs that pass structs by value to functions called on some paths
only gain most. A C program that calls a function with a struct
parameter (a tag, a union and a pointer) on some paths of a loop of 100
iterations takes 2,730 instead of 3,330 SSA steps. A Lua front end built
on CBMC, whose runtime model passes a struct of ten L2 names to most of
its functions, saw 13 % to 59 % fewer steps on six small programs with
symbolic table keys (a weak table: 330,266 to 177,217 steps; symbolic
appends: 221,728 to 108,752).

regression/cbmc/dead-field-names checks that no merge assigns the fields
of a returned parameter or of a dead local union (test.desc fails on
develop; verify.desc checks the verdict).

scripts/profile_cbmc.py --auto-large --runs 3: the same steps on all ten
benchmarks; pre-solver time -1.5 % to +25.5 % across runs in both orders
on a host shared with other jobs (load 7 to 23), within its noise.

regression/cbmc (also with --paths lifo), cbmc-concurrency, cbmc-cpp,
cbmc-cover, cbmc-shadow-memory and cbmc-primitives pass with
--validate-goto-model --validate-ssa-equation; cbmc-library's mmap/test,
mmap/test_02 and munmap/test fail with these options, as on develop.

Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant