C++: Two fixes to ensure we don't use getUniqueId in the new range analysis library. (1) don't use it to rank basic blocks, and (2) don't use it in 'toString' on bounds.

This commit is contained in:
Mathias Vorreiter Pedersen
2022-09-07 18:45:43 +01:00
parent e174123c43
commit a052614dbf
2 changed files with 7 additions and 18 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 }