Skip to content

Go: use shared SSA library (codeql.ssa.Ssa)#21554

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/make-go-use-ssa-library
Draft

Go: use shared SSA library (codeql.ssa.Ssa)#21554
Copilot wants to merge 4 commits intomainfrom
copilot/make-go-use-ssa-library

Conversation

Copy link
Contributor

Copilot AI commented Mar 23, 2026

Go was the last language with its own bespoke SSA implementation. This migrates it to the shared codeql.ssa.Ssa library, consistent with C#, Java, Ruby, Rust, and Swift.

Key changes

  • go/ql/lib/qlpack.yml: Add codeql/ssa: ${workspace} dependency.

  • BasicBlocks.qll: Add module Cfg implements BB::CfgSig<Location> — the CFG adapter required by the shared library.

  • SsaImpl.qll (complete rewrite):

    • Keeps private Go-specific predicates (defAt, useAt, mayCapture, assignedThroughClosure).
    • Implements SsaInput implements SsaImplCommon::InputSig<Location, BasicBlock> feeding variableWrite (certain = explicit def, uncertain = capture) and variableRead.
    • Adds a synthetic uncertain read at function-exit for captured variables to preserve liveness for variables used only in nested functions — preserving the old v.isCaptured() short-circuit.
    • Instantiates via SsaImplCommon::Make<Location, BasicBlocks::Cfg, SsaInput> as Impl.
    • Exports type aliases (Definition, WriteDefinition, UncertainWriteDefinition, PhiNode) and cached predicates (ssaDefReachesRead, phiHasInputFromBlock, firstUse, adjacentUseUse).
  • SSA.qll (updated public API):

    • SsaVariable, SsaDefinition now extend the shared Definition instead of a local newtype.
    • SsaExplicitDefinition extends SsaDefinition, WriteDefinition
    • SsaVariableCapture extends SsaImplicitDefinition, UncertainWriteDefinition
    • SsaPhiNode extends SsaPseudoDefinition, PhiNode
    • All toString() formats match the prior output ("definition of x", "capture variable x", "x = phi(def@L:C, ...)") so test expectations are unchanged. Removed the definesAt(bb, idx, v) compatibility wrapper (no external callers) and the now-redundant getBasicBlock() override (it's final in the shared library).
Original prompt

cpp, csharp, java, ruby, rust and swift all use the shared SSA library. You can see this by searching for files containing import codeql.ssa.Ssa. Make go use it to.

Created from VS Code.


📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.

Copilot AI changed the title [WIP] Add shared SSA library integration for Go Go: use shared SSA library (codeql.ssa.Ssa) Mar 23, 2026
Copilot AI requested a review from owen-mc March 23, 2026 17:21
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