Skip to content

Conversation

@dbartol
Copy link

@dbartol dbartol commented Apr 9, 2021

This change was necessary for my upcoming changes to introduce side effect instructions for indirections of smart pointers. The code to decide which parameters have which side effects appeared in both the IPA constructor for TTranslatedSideEffect and in TranslatedCall. These two versions didn't quite agree, especially once the SideEffectFunction model provides its own side effects instead of the defaults.
The relevant code has now been factored out into SideEffects.qll. This queries the model if one exists, and provides default side effects if no model exists. This fixes at least one existing issue, where we were emitting a buffer read side effect for *this instead of an indirect read side effect. This accounts for all of the IR diffs in the tests.

This change was necessary for my upcoming changes to introduce side effect instructions for indirections of smart pointers. The code to decide which parameters have which side effects appeared in both the IPA constructor for `TTranslatedSideEffect` and in `TranslatedCall`. These two versions didn't quite agree, especially once the `SideEffectFunction` model provides its own side effects instead of the defaults.
The relevant code has now been factored out into `SideEffects.qll`. This queries the model if one exists, and provides default side effects if no model exists. This fixes at least one existing issue, where we were emitting a buffer read side effect for `*this` instead of an indirect read side effect. This accounts for all of the IR diffs in the tests.
@dbartol dbartol added the C++ label Apr 9, 2021
@dbartol dbartol requested a review from rdmarsh2 April 9, 2021 20:15
@dbartol dbartol requested a review from a team as a code owner April 9, 2021 20:15
@dbartol dbartol added the no-change-note-required This PR does not need a change note label Apr 9, 2021
Copy link
Contributor

@rdmarsh2 rdmarsh2 left a comment

Choose a reason for hiding this comment

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

IR generation changes look good to me, with a couple nitpicks. Once the field flow tests are fixed, those changes should probably be reviewed by @MathiasVP

Dave Bartolomeo added 2 commits April 12, 2021 18:11
We have special code to handle field flow for single-field structs, but that special case was too specific. Some `Store`s to single-field structs have no `Chi` instruction, which is the case that we handled already. However, it is possible for the `Store` to have a `Chi` instruction (e.g. for `{AllAliased}`), but still have a use of the result of the `Store` directly. We now add a `PostUpdateNode` for the result of the `Store` itself in those cases, just like we already did if the `Store` had no `Chi`.
@dbartol dbartol requested a review from MathiasVP April 12, 2021 22:21
@dbartol
Copy link
Author

dbartol commented Apr 12, 2021

@MathiasVP I've added another commit to fix the broken dataflow tests. Hopefully the comment in the commit and in the code describes the change well enough.

@MathiasVP
Copy link
Contributor

@MathiasVP I've added another commit to fix the broken dataflow tests. Hopefully the comment in the commit and in the code describes the change well enough.

Commit 697b2dc LGTM (except for formatting).

@rdmarsh2
Copy link
Contributor

LGTM once formatting is fixed.

@rdmarsh2 rdmarsh2 merged commit fe57876 into github:main Apr 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C++ no-change-note-required This PR does not need a change note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants