fix performance

This commit is contained in:
erik-krogh
2023-03-20 12:03:32 +01:00
parent 34fe1a8f5e
commit 070468ab68

View File

@@ -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()
)