Repository navigation
SSA: Refactor post-update support in DataFlowIntegration. - #22914
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved post-update SSA defects lose mutation flow and can introduce cross-variable flow, while a missing counter expectation will fail the Rust diagnostic test.
3 open issues
What changed in this PR
Refactors post-update handling in shared SSA, moving logic out of Unified’s data-flow integration and replacing synthetic reads with explicit read-to-update associations.
Changes:
- Adds mappings between variable reads and their post-update control-flow positions.
- Centralizes post-update traversal in shared SSA and adds a consistency check.
- Simplifies Unified’s SSA node mapping and local-flow integration.
| File | Description |
|---|---|
unified/ql/lib/codeql/unified/internal/dataflow/LocalSsa.qll |
Supplies explicit post-update mappings and removes Unified-specific traversal workarounds. |
shared/ssa/codeql/ssa/Ssa.qll |
Implements shared post-update handling across reference traversal, data-flow nodes, and diagnostics. |
Review effort: Max
1776e21 to
df1793e
Compare
| exists(DfInput::Expr e1, BasicBlock bb1, int i1, BasicBlock bb2, int i2 | | ||
| result = TExprNode(e1, v_, false) and | ||
| e1.hasCfgNode(bb1, i1) and | ||
| variableReadWithPostUpdate(bb1, i1, v_, bb2, i2) and | ||
| e.hasCfgNode(bb2, i2) |
There was a problem hiding this comment.
Irrelevant. We should get rid of getPreUpdateNode in the SSA output, since from the SSA point of view we actually want to conflate those two post-updates.
df1793e to
65529af
Compare
65529af to
51690fd
Compare
asgerf
left a comment
There was a problem hiding this comment.
Unified and SSA changes LGTM
|
Already discussed the C++ changes with Mathias. |


Unified added ad-hoc support for post-updates in SSA DataFlowIntegration to occur later in the CFG than the corresponding reads.
This PR refactors this support to make it a more principled inclusion in the various parts of SSA.
Along the way I uncovered a bug: when a read coincides with a write in the CFG then we mistakenly used to add outgoing use-use steps from the read. Fixing this uncovered another bug in C/C++, which had accidentally relied on the faulty use-use steps to get the desired flow steps. With the help of copilot and @MathiasVP, I also added a commit to fix this.