Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2658520

Browse files
committed
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.
1 parent 077ce6a commit 2658520

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

cpp/ql/src/semmle/code/cpp/controlflow/internal/PrimitiveBasicBlocks.qll

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,11 @@ private cached module Cached {
3131
// or the node's predecessor has more than one successor,
3232
// then the node is the start of a new primitive basic block.
3333
or
34-
strictcount (Node pred, Node other
35-
| successors_extended(pred,node) and successors_extended(pred,other)) > 1
34+
strictcount(Node pred | successors_extended(pred, node)) > 1
35+
or
36+
exists(ControlFlowNode pred | successors_extended(pred, node) |
37+
strictcount(ControlFlowNode other | successors_extended(pred, other)) > 1
38+
)
3639

3740
// If the node has zero predecessors then it is the start of
3841
// a BB. However, the C++ AST contains many nodes with zero

0 commit comments

Comments
 (0)