mirror of
https://github.com/github/codeql.git
synced 2026-05-01 03:35:13 +02:00
C++: Faster implementation of BB entry node
The existing implementation of `primitive_basic_block_entry_node` was "cleverly" computing two properties about `node` with a single `strictcount`: whether `node` had multiple predecessors and whether any of those predecessors had more than once successor. This was fast enough on most snapshots, but on the snapshot of our own code it took 37 seconds to compute `primitive_basic_block_entry_node` and its auxiliary predicates. This is likely to have affected other large snapshots too. With this change, the property is computed like in our other languages, and it brings the run time down to 4 seconds.
This commit is contained in:
@@ -31,8 +31,11 @@ private cached module Cached {
|
||||
// or the node's predecessor has more than one successor,
|
||||
// then the node is the start of a new primitive basic block.
|
||||
or
|
||||
strictcount (Node pred, Node other
|
||||
| successors_extended(pred,node) and successors_extended(pred,other)) > 1
|
||||
strictcount(Node pred | successors_extended(pred, node)) > 1
|
||||
or
|
||||
exists(ControlFlowNode pred | successors_extended(pred, node) |
|
||||
strictcount(ControlFlowNode other | successors_extended(pred, other)) > 1
|
||||
)
|
||||
|
||||
// If the node has zero predecessors then it is the start of
|
||||
// a BB. However, the C++ AST contains many nodes with zero
|
||||
|
||||
Reference in New Issue
Block a user