mirror of
https://github.com/github/codeql.git
synced 2026-04-26 17:25:19 +02:00
C++: Speed up variableLiveOnEntryToBlock in IR
This predicate computed a local CP between all defs and uses of the same virtual variable in a basic block. This wasn't a problem in `unaliased_ssa`, but it became a huge problem in `aliased_ssa`, probably because many variables can be modelled with a single virtual variable there. Before this commit, evaluation of `aliased_ssa`'s `variableLiveOnEntryToBlock#ff#antijoin_rhs` on Wireshark took 80 _minutes_. After this commit, that predicate and its immediate dependencies take around 5 _seconds_.
This commit is contained in:
@@ -392,9 +392,15 @@ cached private module Cached {
|
||||
}
|
||||
|
||||
private predicate variableLiveOnEntryToBlock(Alias::VirtualVariable vvar, OldBlock block) {
|
||||
exists (int index | hasUse(vvar, _, block, index) |
|
||||
not exists (int j | ssa_variableUpdate(vvar, _, block, j) | j < index)
|
||||
) or
|
||||
exists(int firstAccess |
|
||||
hasUse(vvar, _, block, firstAccess) and
|
||||
firstAccess = min(int index |
|
||||
hasUse(vvar, _, block, index)
|
||||
or
|
||||
ssa_variableUpdate(vvar, _, block, index)
|
||||
)
|
||||
)
|
||||
or
|
||||
(variableLiveOnExitFromBlock(vvar, block) and not ssa_variableUpdate(vvar, _, block, _))
|
||||
}
|
||||
|
||||
|
||||
@@ -392,9 +392,15 @@ cached private module Cached {
|
||||
}
|
||||
|
||||
private predicate variableLiveOnEntryToBlock(Alias::VirtualVariable vvar, OldBlock block) {
|
||||
exists (int index | hasUse(vvar, _, block, index) |
|
||||
not exists (int j | ssa_variableUpdate(vvar, _, block, j) | j < index)
|
||||
) or
|
||||
exists(int firstAccess |
|
||||
hasUse(vvar, _, block, firstAccess) and
|
||||
firstAccess = min(int index |
|
||||
hasUse(vvar, _, block, index)
|
||||
or
|
||||
ssa_variableUpdate(vvar, _, block, index)
|
||||
)
|
||||
)
|
||||
or
|
||||
(variableLiveOnExitFromBlock(vvar, block) and not ssa_variableUpdate(vvar, _, block, _))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user