mirror of
https://github.com/github/codeql.git
synced 2026-04-28 10:15:14 +02:00
C++: Performance fix for large basic blocks
The code is now quadratic in the number of statements in a basic block, whereas before it was quadratic in the number of _control-flow nodes_ in a basic block.
This commit is contained in:
@@ -13,12 +13,16 @@ predicate guardedAbs(Operation e, Expr use) {
|
||||
)
|
||||
}
|
||||
|
||||
/** This is `BasicBlock.getNode`, restricted to `Stmt` for performance. */
|
||||
pragma[noinline]
|
||||
private int getStmtIndexInBlock(BasicBlock block, Stmt stmt) { block.getNode(result) = stmt }
|
||||
|
||||
pragma[inline]
|
||||
private predicate stmtDominates(Stmt dominator, Stmt dominated) {
|
||||
// In same block
|
||||
exists(BasicBlock block, int dominatorIndex, int dominatedIndex |
|
||||
block.getNode(dominatorIndex) = dominator and
|
||||
block.getNode(dominatedIndex) = dominated and
|
||||
dominatorIndex = getStmtIndexInBlock(block, dominator) and
|
||||
dominatedIndex = getStmtIndexInBlock(block, dominated) and
|
||||
dominatedIndex >= dominatorIndex
|
||||
)
|
||||
or
|
||||
|
||||
Reference in New Issue
Block a user