C++: Work around join-order issue in flow-through

In this non-linear recursion, a `#prev` relation was joined earlier than
the `#prev_delta` relation. As a result, each iteration of the predicate
processes every tuple from previous iterations.

This quadratic behavior caused severe slowdowns on oneapi-src/oneDNN.
This commit is contained in:
Jonas Jensen
2020-06-29 18:57:04 +02:00
parent 17beb2d867
commit cff0f48d34
4 changed files with 36 additions and 8 deletions

View File

@@ -198,16 +198,23 @@ private module Cached {
compatibleTypes(getErasedNodeTypeBound(p), read.getContainerType())
)
or
parameterValueFlow0_0(TReadStepTypesNone(), p, node, read)
}
pragma[nomagic]
private predicate parameterValueFlow0_0(
ReadStepTypesOption mustBeNone, ParameterNode p, Node node, ReadStepTypesOption read
) {
// flow through: no prior read
exists(ArgumentNode arg |
parameterValueFlowArg(p, arg, TReadStepTypesNone()) and
parameterValueFlowArg(p, arg, mustBeNone) and
argumentValueFlowsThrough(arg, read, node)
)
or
// flow through: no read inside method
exists(ArgumentNode arg |
parameterValueFlowArg(p, arg, read) and
argumentValueFlowsThrough(arg, TReadStepTypesNone(), node)
argumentValueFlowsThrough(arg, mustBeNone, node)
)
}