mirror of
https://github.com/github/codeql.git
synced 2025-12-20 10:46:30 +01:00
HashCons: Make some functionality apparent.
The user knows that an expression functionally determines its hashCons value, and that an expression functionally determines its number of children, but this is not provable from the definitions, and so not usable by the optimiser. By storing the result of those known-functional calls in a variable, rather than repeating the call, we enable better join orders.
This commit is contained in:
@@ -766,11 +766,13 @@ private predicate mk_ClassAggregateLiteral(Class c, HC_Fields hcf, ClassAggregat
|
||||
analyzableClassAggregateLiteral(cal) and
|
||||
c = cal.getUnspecifiedType() and
|
||||
(
|
||||
exists(HC_Fields tail, Expr e, Field f |
|
||||
exists(HC_Fields tail, Expr e, Field f, int numChildren, HashCons eCons |
|
||||
f.getInitializationOrder() = cal.getNumChild() - 1 and
|
||||
e = cal.getFieldExpr(f).getFullyConverted() and
|
||||
hcf = HC_FieldCons(c, cal.getNumChild() - 1, f, hashCons(e), tail) and
|
||||
mk_FieldCons(c, cal.getNumChild() - 1, f, hashCons(e), tail, cal)
|
||||
eCons = hashCons(e) and
|
||||
numChildren = cal.getNumChild() and
|
||||
hcf = HC_FieldCons(c, numChildren - 1, f, eCons, tail) and
|
||||
mk_FieldCons(c, numChildren - 1, f, eCons, tail, cal)
|
||||
)
|
||||
or
|
||||
cal.getNumChild() = 0 and
|
||||
@@ -801,9 +803,10 @@ private predicate mk_ArrayCons(Type t, int i, HashCons hc, HC_Array hca, ArrayAg
|
||||
private predicate mk_ArrayAggregateLiteral(Type t, HC_Array hca, ArrayAggregateLiteral aal) {
|
||||
t = aal.getUnspecifiedType() and
|
||||
(
|
||||
exists(HashCons head, HC_Array tail |
|
||||
hca = HC_ArrayCons(t, aal.getNumChild() - 1, head, tail) and
|
||||
mk_ArrayCons(t, aal.getNumChild() - 1, head, tail, aal)
|
||||
exists(HashCons head, HC_Array tail, int numElements |
|
||||
numElements = aal.getNumChild() and
|
||||
hca = HC_ArrayCons(t, numElements - 1, head, tail) and
|
||||
mk_ArrayCons(t, numElements - 1, head, tail, aal)
|
||||
)
|
||||
or
|
||||
aal.getNumChild() = 0 and
|
||||
|
||||
Reference in New Issue
Block a user