Shared: Implement getInconsistencyCounts for SSA.

This commit is contained in:
Geoffrey White
2025-04-07 16:17:42 +01:00
parent 2c2506c4f8
commit 9c1567375d
2 changed files with 56 additions and 1 deletions

View File

@@ -1473,7 +1473,52 @@ module Make<LocationSig Location, InputSig<Location> Input> {
* Gets counts of inconsistencies of each type.
*/
int getInconsistencyCounts(string type) {
type = "" and result = 0
// total results from all the SSA consistency query predicates.
type = "Read can be reached from multiple definitions" and
result =
count(Definition def, SourceVariable v, BasicBlock bb, int i | nonUniqueDef(def, v, bb, i))
or
type = "Read cannot be reached from a definition" and
result = count(SourceVariable v, BasicBlock bb, int i | readWithoutDef(v, bb, i))
or
type = "Definition cannot reach a read" and
result = count(Definition def, SourceVariable v | deadDef(def, v))
or
type = "Read is not dominated by a definition" and
result =
count(Definition def, SourceVariable v, BasicBlock bb, int i |
notDominatedByDef(def, v, bb, i)
)
or
type = "End of a basic block can be reached by multiple definitions" and
result =
count(Definition def, SourceVariable v, BasicBlock bb |
nonUniqueDefReachesEndOfBlock(def, v, bb)
)
or
type = "Phi node has less than two inputs" and
result = count(PhiNode phi, int inputs | uselessPhiNode(phi, inputs))
or
type = "Read does not have a prior reference" and
result = count(SourceVariable v, BasicBlock bb, int i | readWithoutPriorRef(v, bb, i))
or
type = "Read has multiple prior references" and
result =
count(SourceVariable v, BasicBlock bb1, int i1, BasicBlock bb2, int i2 |
readWithMultiplePriorRefs(v, bb1, i1, bb2, i2)
)
or
type = "Phi has less than 2 immediately prior references" and
result =
count(PhiNode phi, BasicBlock bbPhi, SourceVariable v, int inputRefs |
phiWithoutTwoPriorRefs(phi, bbPhi, v, inputRefs)
)
or
type = "Phi read has less than 2 immediately prior references" and
result =
count(BasicBlock bbPhi, SourceVariable v, int inputRefs |
phiReadWithoutTwoPriorRefs(bbPhi, v, inputRefs)
)
}
}