Skip to content

Add overview of constant propagator #2778

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/analyses/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@ To be documented.

To be documented.

\subsection analyses-constant-propagation Constant propagation (constant_propagator_ait)
\subsection analyses-constant-propagation Constant propagation (\ref constant_propagator_ait)

To be documented.
A simple, unsound constant propagator. Replaces RHS symbol expressions (variable
reads) with their values when they appear to have a unique value at a particular
program point. Unsound with respect to pointer operations on the left-hand side
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that genuinely the case? It's probably unsound for concurrent code, but I'm not sure about pointers.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes: https://github.com/diffblue/cbmc/blob/develop/src/analyses/constant_propagator.cpp#L38 (assign with anything but a symbol on the LHS is a no-op)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ouch. I wasn't quite aware how incomplete it was.

of assignments.

\subsection analyses-taint Taint analysis (custom_bitvector_analysist)

Expand Down
10 changes: 10 additions & 0 deletions src/analyses/constant_propagator.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ Author: Peter Schrammel

/// \file
/// Constant propagation
///
/// A simple, unsound constant propagator. Assignments to symbols (local and
/// global variables) are tracked, and propagated if a unique value is found
/// at a given use site. Function calls are accounted for (they are assumed to
/// overwrite all address-taken variables; see \ref dirtyt), but assignments
/// through pointers are not (they are assumed to have no effect).
///
/// Can be restricted to operate over only particular symbols by passing a
/// predicate to a \ref constant_propagator_ait constructor, in which case this
/// can be rendered sound by restricting it to non-address-taken variables.

#ifndef CPROVER_ANALYSES_CONSTANT_PROPAGATOR_H
#define CPROVER_ANALYSES_CONSTANT_PROPAGATOR_H
Expand Down