C++: Add PostUpdateNode for updates to structs with no chi instructions #3295
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In #3118 we added basic IR field flow by attaching PostUpdateNodes to chi instructions. However, updating a field in a
struct
doesn't always generate a chi instruction. In particular, writing to a struct with a single field doesn't generate a chi instruction. This means we don't catch the following dataflow:But we catch it if
A
is replaced with a struct with more than 1 field like:One problem with adding a
PostUpdateNode
to the assignmenta.i = source()
is that the dataflow library requires a predicategetPreUpdateNode
that returns the node before the update to its state. For field updates generating a chi instruction we can pick the total operand of the chi (as this represents the memory allocated to the struct), but without a chi instruction it's definately to define a meaningful result of this predicate. So this PR simply implements this predicate asnone()
.I don't know if this breaks something in the dataflow library, but it does catch the above flow even when
A
contains a single field.This PR also adds an additional rule to
simpleInstructionLocalFlowStep
in order to propagate dataflow toloads
with inexact memory operands that arise from stores to single field structs. This rule could be avoided if the overlap was consideredMustExactlyOverlap
.