Skip to content

Conversation

kkjeer
Copy link
Contributor

@kkjeer kkjeer commented Sep 9, 2021

This PR modifies the way that rvalue bounds are determined for the value of a member expression, pointer deference, or array subscript to be consistent with the way that rvalue bounds are determined for the value of a variable. The rvalue bounds for the value of a variable, member expression, pointer dereference, or array subscript expression e are determined by looking at the ObservedBounds map in the checking state. If the AbstractSet containing e is present in ObservedBounds, then those are the bounds for the value of e. Otherwise, the bounds for the value of e default to the lvalue target bounds of e (or the lvalue bounds of e if e is the subexpression of an ArrayToPointerDecay cast.

One consequence of this change is that the order of expressions used to get or create an AbstractSet may differ, which may affect the representative expression for the AbstractSet. For example, consider the assignment *p = p[0] + 1. The rvalue bounds of p[0] are determined before modifying the observed bounds of *p. This means that p[0] is the first expression that is used to create the AbstractSet that contains *p and p[0], so p[0] is the representative expression for this AbstractSet.

This PR also includes a minor fix in CanonBounds where ExtVectorElementExprs are compared by address. This prevents an llvm_unreachable that would otherwise occur when creating an AbstractSet for a member expression that contains an ExtVectorElementExpr.

kakje added 10 commits September 8, 2021 14:05
…ds of q before the decrement q-- in the "false" conditional arm
… compound assignment p += 2 are bounds(p, p + (i - 1))
… expression for certain AbstractSets changed

Since getting the observed bounds for expressions that appear on the RHS of assignments happens before updating the observed bounds of expressions that appear on the LHS, an AbstractSet is created for an expression on the RHS of an assignment before the expression on the LHS.
Copy link
Contributor

@sulekhark sulekhark left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you!

Copy link

@mgrang mgrang left a comment

Choose a reason for hiding this comment

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

LGTM.

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.

3 participants