mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
fix performance
This commit is contained in:
@@ -275,9 +275,12 @@ module AccessPath {
|
||||
* Either the definition or a use of the SSA variable
|
||||
*/
|
||||
private VarRef getAVariableRef(SsaVariable variable) {
|
||||
result = variable.getAUse()
|
||||
or
|
||||
result = variable.getDefinition().(SsaExplicitDefinition).getDef().getTarget()
|
||||
(
|
||||
result = variable.getAUse()
|
||||
or
|
||||
result = variable.getDefinition().(SsaExplicitDefinition).getDef().getTarget()
|
||||
) and
|
||||
variable = getARelevantVariableSimple()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -341,13 +344,24 @@ module AccessPath {
|
||||
if result = getBaseVar(_) then usedInWrite = true else usedInWrite = false
|
||||
}
|
||||
|
||||
/** Gets a variable that is relevant for the computations in the `GetLaterAccess` module. */
|
||||
private SsaVariable getARelevantVariable() {
|
||||
/**
|
||||
* Gets a variable that is relevant for the computations in the `GetLaterAccess` module.
|
||||
* This predicate restricts as much as it can, but without depending on `getAVariableRef`.
|
||||
*/
|
||||
pragma[inline]
|
||||
private SsaVariable getARelevantVariableSimple() {
|
||||
// The variable might be used where `getLaterBaseAccess()` is called.
|
||||
exists(DataFlow::Node node |
|
||||
exists(fromRhs(node, _)) and
|
||||
node.asExpr() = getAVariableRef(result)
|
||||
) and
|
||||
node.asExpr() = result.getAUse()
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a variable that is relevant for the computations in the `GetLaterAccess` module.
|
||||
* This predicate depends on `getAVariableRef`, which in turn depends on `getARelevantVariableSimple`.
|
||||
*/
|
||||
private SsaVariable getARelevantVariable() {
|
||||
// There is a write that writes to the variable.
|
||||
getBaseVar(_) = getAVariableRef(result) and
|
||||
// There is both a "write" and "read" in the same container of the variable.
|
||||
@@ -364,7 +378,7 @@ module AccessPath {
|
||||
getAVariableRef(var) = baseExpr and
|
||||
var = getARelevantVariable() and
|
||||
writeNode = write.getWriteNode() and
|
||||
writeNode.getBasicBlock().(ReachableBasicBlock).strictlyDominates(result) and
|
||||
result.getImmediateDominator+() = writeNode.getBasicBlock() and
|
||||
// manual magic.
|
||||
result = getAnAccessInContainer(getARelevantVariable(), _, false).getBasicBlock()
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user