Skip to content
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

Ssa: Refactor shared SSA in preparation for eliminating phi-read definitions #18819

Merged
merged 30 commits into from
Feb 21, 2025
Merged
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
3822d14
SSA: Elaborate qldoc.
aschackmull Feb 11, 2025
36613e1
SSA: Remove superfluous conjunct (implied by refRank).
aschackmull Feb 11, 2025
b62432f
SSA: Remove superfluous boolean.
aschackmull Feb 14, 2025
c5e2884
SSA: Remove superfluous column from liveAtRank.
aschackmull Feb 14, 2025
5723d27
SSA: Make inReadDominanceFrontier a bit smaller without affecting phi…
aschackmull Feb 14, 2025
f80cd97
SSA: Factor out phi-read construction in its own predicate.
aschackmull Feb 17, 2025
81b3035
SSA: Inline predicate
aschackmull Feb 17, 2025
613323e
SSA: Copy parts of SsaDefReaches verbatim to new module.
aschackmull Feb 17, 2025
ea08c60
SSA: Copy 3 predicates from the outer scope verbatim into the new Rea…
aschackmull Feb 17, 2025
6e272d0
SSA: Ignore phi-reads in the new def-reaches module.
aschackmull Feb 17, 2025
77ccff6
SSA: Replace exported def-reaches predicates (behaviour-preserving).
aschackmull Feb 17, 2025
7e441d9
SSA: Fold getImmediateBasicBlockDominator into loop-invariant predicate.
aschackmull Feb 17, 2025
a4fee2e
SSA: Minor perf tweak to reduce tuple duplication.
aschackmull Feb 17, 2025
d5ac5b4
SSA: Replace uncertainWriteDefinitionInput implementation.
aschackmull Feb 17, 2025
11166fc
SSA: Restrict phi-read creation to be based on reachable reads.
aschackmull Feb 17, 2025
411aff6
SSA: Refactor ranking into parameterised module.
aschackmull Feb 17, 2025
d6dc91d
SSA: Inline predicate to simplify negation.
aschackmull Feb 17, 2025
35f50ba
SSA: Reimplement use-use.
aschackmull Feb 17, 2025
194afbb
Java: Simplify SSA for variable capture.
aschackmull Feb 18, 2025
cf2136f
SSA: Export simple firstUse and adjacentUseUse predicates.
aschackmull Feb 18, 2025
5379506
Java: Use firstUse and adjacentUseUse predicates.
aschackmull Feb 18, 2025
291ea6f
Java: Move SSA data flow test and extend it to cover phi-read input e…
aschackmull Feb 18, 2025
ed40035
C#/Ruby/Rust: Fix bug in adjacentReadPairSameVar.
aschackmull Feb 19, 2025
17ae747
C#: Switch use-use predicates to new implementation.
aschackmull Feb 19, 2025
b0a5e62
C#: Clean up unused.
aschackmull Feb 19, 2025
4ddc5c9
Ruby: Switch use-use predicates to new implementation.
aschackmull Feb 19, 2025
7e59603
Rust: Switch use-use predicates to new implementation.
aschackmull Feb 19, 2025
b76e5f5
SSA: Deprecate unused predicate.
aschackmull Feb 19, 2025
8e609b1
Ruby: Accept qltest change.
aschackmull Feb 20, 2025
8c0cc07
Ssa: Fix qldoc duplicate word.
aschackmull Feb 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions shared/ssa/codeql/ssa/Ssa.qll
Original file line number Diff line number Diff line change
Expand Up @@ -294,11 +294,26 @@ module Make<LocationSig Location, InputSig<Location> Input> {
variableRead(readbb, _, v, _) and
not variableWrite(readbb, _, v, _)
or
exists(TPhiReadNode(v, readbb)) and
synthPhiRead(readbb, v) and
not ref(readbb, _, v, _)
)
}

/**
* Holds if we should synthesize a pseudo-read of `v` at the beginning of `bb`.
*
* These reads are named phi-reads, since they are constructed in the same
* way as ordinary phi nodes except all all reads are treated as potential
Copy link
Contributor

Choose a reason for hiding this comment

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

remove the extra all.

* "definitions". This ensures that use-use flow has the same dominance
* properties as def-use flow.
*/
private predicate synthPhiRead(BasicBlock bb, SourceVariable v) {
inReadDominanceFrontier(bb, v) and
liveAtEntry(bb, v) and
// no need to create a phi-read if there is already a normal phi
not any(PhiNode def).definesAt(v, bb, _)
}

cached
private newtype TDefinitionExt =
TWriteDef(SourceVariable v, BasicBlock bb, int i) {
Expand All @@ -309,12 +324,7 @@ module Make<LocationSig Location, InputSig<Location> Input> {
inDefDominanceFrontier(bb, v) and
liveAtEntry(bb, v)
} or
TPhiReadNode(SourceVariable v, BasicBlock bb) {
inReadDominanceFrontier(bb, v) and
liveAtEntry(bb, v) and
// no need to create a phi-read if there is already a normal phi
not any(PhiNode def).definesAt(v, bb, _)
}
TPhiReadNode(SourceVariable v, BasicBlock bb) { synthPhiRead(bb, v) }

private class TDefinition = TWriteDef or TPhiNode;

Expand Down