C++: Add an 'hasIncompleteSsa' predicate to check whether a function has correctly modelled SSA information.

This commit is contained in:
Mathias Vorreiter Pedersen
2025-05-12 19:46:50 +01:00
parent f1b4e05579
commit 510df38da2
6 changed files with 50 additions and 0 deletions

View File

@@ -58,4 +58,12 @@ class IRFunction extends IRFunctionBase {
* Gets all blocks in this function.
*/
final IRBlock getABlock() { result.getEnclosingIRFunction() = this }
/**
* Holds if this function may have incomplete def-use information.
*
* Def-use information may be omitted for a function when it is too expensive
* to compute.
*/
final predicate hasIncompleteSsa() { Construction::hasIncompleteSsa(this) }
}

View File

@@ -1319,6 +1319,18 @@ predicate canReuseSsaForMemoryResult(Instruction instruction) {
// We don't support reusing SSA for any location that could create a `Chi` instruction.
}
/**
* Holds if the def-use information for `f` may have been omitted because it
* was too expensive to compute. This happens if one of the memory allocations
* in `f` is a busy definition (i.e., it has many different overlapping uses).
*/
predicate hasIncompleteSsa(IRFunction f) {
exists(Alias::MemoryLocation0 defLocation |
Alias::isBusyDef(defLocation) and
defLocation.getIRFunction() = f
)
}
/**
* Expose some of the internal predicates to PrintSSA.qll. We do this by publicly importing those modules in the
* `DebugSsa` module, which is then imported by PrintSSA.

View File

@@ -58,4 +58,12 @@ class IRFunction extends IRFunctionBase {
* Gets all blocks in this function.
*/
final IRBlock getABlock() { result.getEnclosingIRFunction() = this }
/**
* Holds if this function may have incomplete def-use information.
*
* Def-use information may be omitted for a function when it is too expensive
* to compute.
*/
final predicate hasIncompleteSsa() { Construction::hasIncompleteSsa(this) }
}

View File

@@ -220,6 +220,8 @@ Instruction getMemoryOperandDefinition(
none()
}
predicate hasIncompleteSsa(IRFunction f) { none() }
/**
* Holds if the operand totally overlaps with its definition and consumes the
* bit range `[startBitOffset, endBitOffset)`.

View File

@@ -58,4 +58,12 @@ class IRFunction extends IRFunctionBase {
* Gets all blocks in this function.
*/
final IRBlock getABlock() { result.getEnclosingIRFunction() = this }
/**
* Holds if this function may have incomplete def-use information.
*
* Def-use information may be omitted for a function when it is too expensive
* to compute.
*/
final predicate hasIncompleteSsa() { Construction::hasIncompleteSsa(this) }
}

View File

@@ -1319,6 +1319,18 @@ predicate canReuseSsaForMemoryResult(Instruction instruction) {
// We don't support reusing SSA for any location that could create a `Chi` instruction.
}
/**
* Holds if the def-use information for `f` may have been omitted because it
* was too expensive to compute. This happens if one of the memory allocations
* in `f` is a busy definition (i.e., it has many different overlapping uses).
*/
predicate hasIncompleteSsa(IRFunction f) {
exists(Alias::MemoryLocation0 defLocation |
Alias::isBusyDef(defLocation) and
defLocation.getIRFunction() = f
)
}
/**
* Expose some of the internal predicates to PrintSSA.qll. We do this by publicly importing those modules in the
* `DebugSsa` module, which is then imported by PrintSSA.