Skip to content

Commit 9c15673

Browse files
committed
Shared: Implement getInconsistencyCounts for SSA.
1 parent 2c2506c commit 9c15673

File tree

2 files changed

+56
-1
lines changed

2 files changed

+56
-1
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
| Definition cannot reach a read | 0 |
2+
| End of a basic block can be reached by multiple definitions | 0 |
3+
| Phi has less than 2 immediately prior references | 0 |
4+
| Phi node has less than two inputs | 0 |
5+
| Phi read has less than 2 immediately prior references | 0 |
6+
| Read can be reached from multiple definitions | 0 |
7+
| Read cannot be reached from a definition | 0 |
8+
| Read does not have a prior reference | 0 |
9+
| Read has multiple prior references | 0 |
10+
| Read is not dominated by a definition | 0 |

shared/ssa/codeql/ssa/Ssa.qll

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1473,7 +1473,52 @@ module Make<LocationSig Location, InputSig<Location> Input> {
14731473
* Gets counts of inconsistencies of each type.
14741474
*/
14751475
int getInconsistencyCounts(string type) {
1476-
type = "" and result = 0
1476+
// total results from all the SSA consistency query predicates.
1477+
type = "Read can be reached from multiple definitions" and
1478+
result =
1479+
count(Definition def, SourceVariable v, BasicBlock bb, int i | nonUniqueDef(def, v, bb, i))
1480+
or
1481+
type = "Read cannot be reached from a definition" and
1482+
result = count(SourceVariable v, BasicBlock bb, int i | readWithoutDef(v, bb, i))
1483+
or
1484+
type = "Definition cannot reach a read" and
1485+
result = count(Definition def, SourceVariable v | deadDef(def, v))
1486+
or
1487+
type = "Read is not dominated by a definition" and
1488+
result =
1489+
count(Definition def, SourceVariable v, BasicBlock bb, int i |
1490+
notDominatedByDef(def, v, bb, i)
1491+
)
1492+
or
1493+
type = "End of a basic block can be reached by multiple definitions" and
1494+
result =
1495+
count(Definition def, SourceVariable v, BasicBlock bb |
1496+
nonUniqueDefReachesEndOfBlock(def, v, bb)
1497+
)
1498+
or
1499+
type = "Phi node has less than two inputs" and
1500+
result = count(PhiNode phi, int inputs | uselessPhiNode(phi, inputs))
1501+
or
1502+
type = "Read does not have a prior reference" and
1503+
result = count(SourceVariable v, BasicBlock bb, int i | readWithoutPriorRef(v, bb, i))
1504+
or
1505+
type = "Read has multiple prior references" and
1506+
result =
1507+
count(SourceVariable v, BasicBlock bb1, int i1, BasicBlock bb2, int i2 |
1508+
readWithMultiplePriorRefs(v, bb1, i1, bb2, i2)
1509+
)
1510+
or
1511+
type = "Phi has less than 2 immediately prior references" and
1512+
result =
1513+
count(PhiNode phi, BasicBlock bbPhi, SourceVariable v, int inputRefs |
1514+
phiWithoutTwoPriorRefs(phi, bbPhi, v, inputRefs)
1515+
)
1516+
or
1517+
type = "Phi read has less than 2 immediately prior references" and
1518+
result =
1519+
count(BasicBlock bbPhi, SourceVariable v, int inputRefs |
1520+
phiReadWithoutTwoPriorRefs(bbPhi, v, inputRefs)
1521+
)
14771522
}
14781523
}
14791524

0 commit comments

Comments
 (0)