Merge pull request #10339 from MathiasVP/dont-use-get-unique-id-in-range-analysis

C++: Don't use `getUniqueId` in range analysis
This commit is contained in:
Robert Marsh
2022-09-08 11:13:43 -04:00
committed by GitHub
3 changed files with 59 additions and 70 deletions

View File

@@ -73,7 +73,7 @@ class ValueNumberBound extends Bound, TBoundValueNumber {
this = TBoundValueNumber(valueNumber(result)) and delta = 0
}
override string toString() { result = vn.getExampleInstruction().toString() }
override string toString() { result = "ValueNumberBound" }
override Location getLocation() { result = vn.getLocation() }

View File

@@ -112,12 +112,11 @@ module SemanticExprConfig {
predicate hasDominanceInformation(BasicBlock block) { any() }
int getBasicBlockUniqueId(BasicBlock block) {
// REVIEW: `getDisplayIndex()` is not intended for use in real queries, but for now it's the
// best we can do because `equivalentRelation` won't accept a predicate whose parameters are IPA
// types.
result = block.getDisplayIndex()
}
private predicate id(Cpp::Locatable x, Cpp::Locatable y) { x = y }
private predicate idOf(Cpp::Locatable x, int y) = equivalenceRelation(id/2)(x, y)
int getBasicBlockUniqueId(BasicBlock block) { idOf(block.getFirstInstruction().getAst(), result) }
newtype TSsaVariable =
TSsaInstruction(IR::Instruction instr) { instr.hasMemoryResult() } or
@@ -267,17 +266,7 @@ module SemanticExprConfig {
ValueNumberBound() { bound = this }
override string toString() {
result =
min(SsaVariable v |
v.asInstruction() = bound.getValueNumber().getAnInstruction()
|
v
order by
v.asInstruction().getBlock().getDisplayIndex(),
v.asInstruction().getDisplayIndexInBlock()
).toString()
}
override string toString() { result = bound.toString() }
}
predicate zeroBound(Bound bound) { bound instanceof IRBound::ZeroBound }