Skip to content

Shared: Add and use a signature for basic blocks #20253

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

aschackmull
Copy link
Contributor

We already have a fairly canonical BasicBlock api in the shared library. This PR takes this one step further by canonicalizing that api in a signature and using it in mainly SSA and a few other places.

@Copilot Copilot AI review requested due to automatic review settings August 20, 2025 09:39
@aschackmull aschackmull requested review from a team as code owners August 20, 2025 09:39
@aschackmull aschackmull added the no-change-note-required This PR does not need a change note label Aug 20, 2025
@aschackmull aschackmull requested review from a team as code owners August 20, 2025 09:39
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.

Pull Request Overview

This PR introduces a canonical BasicBlock signature for the shared library and refactors existing SSA and dataflow implementations to use it instead of duplicating BasicBlock API definitions.

Key changes:

  • Introduces a canonical CfgSig signature in the shared controlflow library
  • Refactors SSA implementations across multiple languages to use the shared signature
  • Updates Variable Capture modules to use the standardized interface

Reviewed Changes

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

Show a summary per file
File Description
shared/ssa/codeql/ssa/Ssa.qll Updates SSA implementation to use the new BasicBlock signature
shared/dataflow/codeql/dataflow/VariableCapture.qll Refactors variable capture to use the shared BasicBlock signature
shared/controlflow/codeql/controlflow/BasicBlock.qll Adds the canonical CfgSig signature interface
swift/ql/lib/codeql/swift/dataflow/internal/DataFlowPrivate.qll Updates Swift dataflow to use shared BasicBlock interface
swift/ql/lib/codeql/swift/dataflow/Ssa.qll Refactors Swift SSA to use the new signature
swift/ql/lib/codeql/swift/controlflow/BasicBlocks.qll Implements the CfgSig signature for Swift
Multiple language-specific files Updates various language implementations to use the shared interface

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

@@ -1953,7 +1951,7 @@
* Holds if `(bb, i)` contains a write to an iterator that may have been obtained
* by calling `begin` (or related functions) on the variable `v`.
*/
predicate variableWrite(BasicBlock bb, int i, SourceVariable v, boolean certain) {
predicate variableWrite(IRCfg::BasicBlock bb, int i, SourceVariable v, boolean certain) {

Check warning

Code scanning / CodeQL

Missing QLDoc for parameter Warning

The QLDoc has no documentation for certain, but the QLDoc mentions begin
final private class FinalBasicBlock = BasicBlock;

module Cfg implements BB::CfgSig<DbLocation> {
private import javascript as Js

Check warning

Code scanning / CodeQL

Names only differing by case Warning

Js is only different by casing from js that is used elsewhere for modules.
Js is only different by casing from JS that is used elsewhere for modules.
deprecated private predicate lastRefSkipUncertainReadsExt(
Definition def, SsaInput::BasicBlock bb, int i
) {
deprecated private predicate lastRefSkipUncertainReadsExt(Definition def, BasicBlock bb, int i) {

Check warning

Code scanning / CodeQL

Missing QLDoc for parameter Warning

The QLDoc has no documentation for bb, or def, or i, but the QLDoc mentions lastRefRedef
this.hasValueBranchEdge(bb1, bb2, branch)
}
}

/** Holds if the guard `guard` controls block `bb` upon evaluating to `branch`. */
predicate guardDirectlyControlsBlock(Guard guard, SsaInput::BasicBlock bb, GuardValue branch) {
predicate guardDirectlyControlsBlock(Guard guard, BasicBlock bb, GuardValue branch) {

Check warning

Code scanning / CodeQL

Dead code Warning

This code is never used, and it's not publicly exported.
@aschackmull aschackmull force-pushed the shared/basicblock-signature2 branch from 5230eb5 to f8a1735 Compare August 22, 2025 09:07
@aschackmull aschackmull force-pushed the shared/basicblock-signature2 branch from f8a1735 to ab8a1b4 Compare August 22, 2025 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C# C++ DataFlow Library Java JS no-change-note-required This PR does not need a change note Python Ruby Rust Pull requests that update Rust code Swift
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant