Skip to content
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

C++: Reuse even more DataFlow::Nodes #14008

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

MathiasVP
Copy link
Contributor

@MathiasVP MathiasVP commented Aug 21, 2023

In C/C++ dataflow we reuse some dataflow nodes that we know are sementically equivalent to gain a small amount of performance, and to make it easier to select the right dataflow node in sources, sinks, barriers, etc. For example, consider the following snippet of IR:

r1(glval<char **>) = VariableAddress[a]          :
r2(char **)        = Load[a]                     : &:r1, m1
r3(glval<char *>)  = CopyValue                   : r2

For dataflow we have a node that represents &:r1 (i.e, the value of type char***), as well as nodes for the possible indirections of &:r1: *&:r1 (i.e., the value of type char**), **&:r1 (i.e, the value of type char*), and ***&:r1 (i.e., the value of type char).

Similarly, we have a node that represents the r2 operand (i.e., the value of type char**), as well as nodes for the possible indirections of r2: *r2 (i.e., the value of type char*), and **r2 (i.e., the value of type char).

However, some of these nodes represent the semantically same value. For example, both *&:r1 and r2 represent the char** value (i.e., the value you get when you dereference VariableAddress[a]).

The getIRRepresentationOfIndirectOperand and getIRRepresentationOfIndirectInstruction predicates are used to identify such semantically identical representations.

Currently, however, getIRRepresentationOfIndirectOperand and getIRRepresentationOfIndirectInstruction only identified that *&:r1 and r2 represented the same value. But **&:r1 and *r2, and ***&:r1 and **r2 also represent the same values. This PR extends those predicates to identify these cases.

This should (hopefully) give us a small speedup, a reduced memory footprint, and possible even remove some FPs in queries in cases where we selected a equivalent (but until now not identical!) node to the one on the actual dataflow path.

@github-actions github-actions bot added the C++ label Aug 21, 2023
@MathiasVP MathiasVP added the no-change-note-required This PR does not need a change note label Aug 21, 2023
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.

None yet

1 participant