Next: Interprocedural Algorithm Up: Analyzing a Procedure Previous: Evaluating Dereferences

Evaluating Assignments

An assignment node in a flow graph specifies both the source and destination expressions, as well as the size of the value to be assigned. When building the flow graph from the intermediate representation of a program, we automatically convert the assignments to a ``points-to'' form. That is, since a variable reference on the right-hand side of an assignment refers to the contents of that variable, we add an extra dereference to each expression on the right-hand side. Source and destination expressions may also involve pointer arithmetic. Simple increments are included in the strides of the location sets. We simply keep a list of all the constant location sets and dereference subexpressions found in other arithmetic expressions.

The process of evaluating an assignment begins by finding the locations identified by the source and destination expressions. To evaluate an expression, we iterate through its constant location sets and dereference subexpressions. Constant locations require no computation. Dereference expressions may include any number of nested dereferences, which we evaluate one level at a time. For each destination location, we then update the points-to function to include the values from all the potential source locations. Figure 11 shows this process for the case where the size of the assignment is one word or less.

In an aggregate assignment, where multiple words are assigned at once, all the pointer fields from the sources are copied to the destinations. If a source location contains a pointer value at an offset within the range being copied, we add that pointer value at the corresponding offset to the destination location.



Next: Interprocedural Algorithm Up: Analyzing a Procedure Previous: Evaluating Dereferences


Bob Wilson