C++: data flow AlwaysTrueUponEntryLoop perf fix

The predicate `AlwaysTrueUponEntryLoop.getARelevantVariable` was very
sensitive to join ordering, and with the 1.19 QL engine it got an
unfortunate join order that made it explode on certain snapshots. With
this change, it goes from taking minutes to taking less than a second on
a libretro-uae snapshot.
This commit is contained in:
Jonas Jensen
2018-12-01 10:07:08 +01:00
parent 608d84cfa3
commit d14cf34cc6

View File

@@ -292,10 +292,7 @@ module FlowVar_internal {
* Gets a variable that is assigned in this loop and read outside the loop.
*/
private Variable getARelevantVariable() {
exists(BasicBlock bbAssign |
assignmentLikeOperation(bbAssign.getANode(), result, _) and
this.bbInLoop(bbAssign)
) and
result = this.getAVariableAssignedInLoop() and
exists(VariableAccess va |
va.getTarget() = result and
readAccess(va) and
@@ -303,6 +300,15 @@ module FlowVar_internal {
)
}
/** Gets a variable that is assigned in this loop. */
pragma[noinline]
private Variable getAVariableAssignedInLoop() {
exists(BasicBlock bbAssign |
assignmentLikeOperation(bbAssign.getANode(), result, _) and
this.bbInLoop(bbAssign)
)
}
private predicate bbInLoopCondition(BasicBlock bb) {
getCFNParent*(bb.getANode()) = this.(Loop).getCondition()
}