Skip to content

Conversation

MathiasVP
Copy link
Contributor

@MathiasVP MathiasVP commented Mar 7, 2025

Intuitively, C++ has (at least) the following dataflow nodes:

  • A dataflow node for each instruction
  • A dataflow node for each operand
  • A dataflow node for each possible indirection of an instruction
  • A dataflow node for each possible indirection of an operand

Because many of these nodes semantically represent the same concept we merge some of these into a single dataflow node tuple. This has two benefits:

  • We allocate less dataflow nodes which saves on memory, and
  • It's easier to pick the right dataflow node for sources, sinks, and (especially) barriers.

For example, for IR such as:

r1(glval<int>) = VariableAddress[a]     : 
r2(int)        = Load[a]                : &:r1, m1

there will be a single dataflow node representing both the instruction r1 and the operand &:r1. That is, operands and instruction often share the same underlying IPA tuple (when the instruction has a unique use).

Similarly, if we have a piece of IR such as

r2(glval<int>) = VariableAddress[a]     :
r3(int*)       = Load[a]                : &:r2, m1
r4(void)       = Call[foo]              : func:r1 0:r3

the dataflow node representing the indirection of &:r2 (i.e., *&:r2) is represented by the same dataflow node as the one representing 0:r3 because they both represent the same concept: the result of dereferencing &:r2. It just so happens that (in this case) this concept is captured already in the IR and thus there's no need to create a new kind of dataflow node for it.

(For more information on this sharing see #11218, #12004, and #14008.)

This PR extends the sharing so that we recognize equivalent nodes across CopyValue instructions. So now *&:r4, *r3, and **&:r2 all share tuple number in:

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

whereas on main there was a tuple for *&:r4, and another tuple number for *r3 and **&:r2.

@Copilot Copilot AI review requested due to automatic review settings March 7, 2025 20:38
@MathiasVP MathiasVP requested a review from a team as a code owner March 7, 2025 20:38
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

Tip: Copilot only keeps its highest confidence comments to reduce noise and keep you focused. Learn more

@github-actions github-actions bot added the C++ label Mar 7, 2025
@MathiasVP MathiasVP added the no-change-note-required This PR does not need a change note label Mar 7, 2025
@MathiasVP MathiasVP merged commit 1aa1829 into github:main Mar 10, 2025
13 of 14 checks passed
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.

2 participants