Skip to content

Go CFG: remove dead "send" additional node#22050

Draft
Copilot wants to merge 1 commit into
mainfrom
copilot/copilotvscode-mndb17m3-9fpv
Draft

Go CFG: remove dead "send" additional node#22050
Copilot wants to merge 1 commit into
mainfrom
copilot/copilotvscode-mndb17m3-9fpv

Conversation

Copilot AI commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Investigation into minimizing the additional CFG nodes produced by predicate additionalNode in go/ql/lib/semmle/go/controlflow/ControlFlowGraphShared.qll, comparing against Java/C# which share the same CFG library.

Findings

  • Java emits 1 language-specific additional node, C# emits 0. Go emits ~20 because its IR is built on top of the CFG (every CFG node is an IR::Instruction), so the additional nodes encode IR semantics (assignment writes, tuple extraction, zero-init, parameter/argument binding, implicit derefs/bounds, promoted-field reads, …) that the data-flow library depends on. These are genuinely required.
  • The "send" node is the sole exception: no step wires it into the graph, so it is unreachable (0 reachable nodes on the test DB). The send is already modeled by the SendStmt's own isIn node, and the only consumer of the dead node — the SendInstruction IR class — was unused except for toString.

Changes

  • ControlFlowGraphShared.qll: drop the dead "send" branch from additionalNode.
  • IR.qll: remove the unused SendInstruction class and its getInsnKind branch.

CFG and IR library tests are unchanged (empty .expected diffs), consistent with the removed node being unreachable.

Original prompt

Starting from this branch (copilot/vscode-mndb17m3-9fpv), look at predicate additionalNode in go/ql/lib/semmle/go/controlflow/ControlFlowGraphShared.qll. We want to use as few additional nodes as possible. Investigate if we need all of the additional nodes. You can also compare how java and C# (which are the languages using this shared CFG library) do things.

[Chronological Review: The conversation began with the user requesting to explore the possibility of using more default behavior from the shared control flow graph (CFG) library for Go's select statements. The user then decided to keep the CFG for select clauses language-specific due to existing problems and requested an investigation into the correctness of successor types on edges. The user later asked to check the git history for the main branch to understand the CFG better. The focus shifted to examining the `predicate additionalNode` in the shared CFG library to minimize additional nodes and compare implementations with Java and C#. The conversation culminated in the user specifying the current file and selection context for further investigation.]

[Intent Mapping:

  1. "Is there any way to use more of the default behaviour of the shared library...?" - Explore integration of shared CFG behavior for Go select statements.
  2. "Okay, let's keep the CFG for select clauses language-specific then." - Confirm decision to maintain language-specific CFG for select clauses and request improvements.
  3. "You should have git history available to look what the cfg looks like on main." - Request to review git history for CFG insights.
  4. "Starting from this branch... look at predicate additionalNode..." - Direct investigation into minimizing additional nodes in the CFG.]

[Technical Inventory:

  • Repository: codeql
  • Branch: copilot/vscode-mndb17m3-9fpv
  • Default branch: main
  • Key files: ControlFlowGraph.qll, ControlFlowGraphShared.qll
  • Concepts: Control Flow Graph (CFG), predicates, language-specific edges, additional nodes, successor types.]

[Code Archaeology:

  • File: ControlFlowGraph.qll - Contains language-specific edges for Go select statements.
  • File: ControlFlowGraphShared.qll - Contains the predicate additionalNode which is under investigation for optimization.]

[Progress Assessment:

  • Completed: User confirmed to keep CFG for select clauses language-specific.
  • Pending: Investigation into the correctness of successor types and the necessity of additional nodes in the CFG.]

[Context Validation: All critical information for continuation is captured, including user decisions and specific areas of focus for code investigation.]

[Recent Commands Analysis:

  • Last Agent Commands: User requested to look at predicate additionalNode in ControlFlowGraphShared.qll and compare with Java and C# implementations.
  • Tool Results Summary: User's active file context was established, focusing on the predicate additionalNode and its implementation details.
  • Pre-Summary State: The agent was actively investigating the predicate additionalNode in the context of minimizing additional nodes in the CFG.
  • Operation Context: These commands were executed to align the CFG implementation with user goals of optimizing the control flow graph for Go.]
1. Conversation Overview: - Primary Objectives: - "Is there any way to use more of the default behaviour of the shared library...?" - Explore shared CFG behavior for Go. - "Okay, let's keep the CFG for select clauses language-specific then." - Confirm decision to maintain language-specific CFG for select clauses. - "You should have git history available to look what the cfg looks like on main." - Review git history for CFG insights. - "Starting from this branch... look at `predicate additionalNode`..." - Investigate minimizing additional nodes in the CFG. - Session Context: The conversation flowed from exploring shared library behavior to confirming language-specific implementations and investigating specific predicates in the CFG. - User Intent Evolution: The user shifted from exploring shared behavior to focusing on optimizing the existing language-specific CFG for Go.
  1. Technical Foundation:
  • Repository: codeql
  • Branch: copilot/vscode-mndb17m3-9fpv
  • Default branch: main
  • Key files: ControlFlowGraph.qll, ControlFlowGraphShared.qll
  1. Codebase Status:
  • File: ControlFlowGraph.qll
    • Purpose: Models language-specific edges for Go select statements.
    • Current State: Under review for potential integration with shared library behavior.
  • File: ControlFlowGraphShared.qll
    • Purpose: Contains shared CFG logic and predicates.
    • Current State: Focus on predicate additionalNode for optimization.
  1. Problem Resolution:
  • Issues Encountered: Potential problems with the current CFG implementation for select statements and correctness of successor types.
  • Solutions Implemented: Decision to keep select clauses language-specific while investigating improvements.
  • D...

Created from VS Code.

Copilot AI changed the title [WIP] Investigate additional nodes in ControlFlowGraphShared.qll Clarify additionalNode target for shared CFG minimization (no code change) Jun 25, 2026
Copilot AI requested a review from owen-mc June 25, 2026 09:18
Copilot AI changed the title Clarify additionalNode target for shared CFG minimization (no code change) Go CFG: remove dead "send" additional node Jun 25, 2026
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.

2 participants