8000 C++: Add an 'hasIncompleteSsa' predicate to check whether a function … · github/codeql@510df38 · GitHub
[go: up one dir, main page]

Skip to content

Commit 510df38

Browse files
committed
C++: Add an 'hasIncompleteSsa' predicate to check whether a function has correctly modelled SSA information 8000 .
1 parent f1b4e05 commit 510df38

File tree

6 files changed

+50
-0
lines changed

6 files changed

+50
-0
lines changed

cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/IRFunction.qll

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,12 @@ class IRFunction extends IRFunctionBase {
5858
* Gets all blocks in this function.
5959
*/
6060
final IRBlock getABlock() { result.getEnclosingIRFunction() = this }
61+
62+
/**
63+
* Holds if this function may have incomplete def-use information.
64+
*
65+
* Def-use information may be omitted for a function when it is too expensive
66+
* to compute.
67+
*/
68+
final predicate hasIncompleteSsa() { Construction::hasIncompleteSsa(this) }
6169
}

cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/internal/SSAConstruction.qll

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,6 +1319,18 @@ predicate canReuseSsaForMemoryResult(Instruction instruction) {
13191319
// We don't support reusing SSA for any location that could create a `Chi` instruction.
13201320
}
13211321

1322+
/**
1323+
* Holds if the def-use information for `f` may have been omitted because it
1324+
* was too expensive to compute. This happens if one of the memory allocations
1325+
* in `f` is a busy definition (i.e., it has many different overlapping uses).
1326+
*/
1327+
predicate hasIncompleteSsa(IRFunction f) {
1328+
exists(Alias::MemoryLocation0 defLocation |
1329+
Alias::isBusyDef(defLocation) and
1330+
defLocation.getIRFunction() = f
1331+
)
1332+
}
1333+
13221334
/**
13231335
* Expose some of the internal predicates to PrintSSA.qll. We do this by publicly importing those modules in the
13241336
* `DebugSsa` module, which is then imported by PrintSSA.

cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/IRFunction.qll

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,12 @@ class IRFunction extends IRFunctionBase {
5858
* Gets all blocks in this function.
5959
*/
6060
final IRBlock getABlock() { result.getEnclosingIRFunction() = this }
61+
62+
/**
63+
* Holds if this function may have incomplete def-use information.
64+
*
65+
* Def-use information may be omitted for a function when it is too expensive
66+
* to compute.
67+
*/
68+
final predicate hasIncompleteSsa() { Construct 8000 ion::hasIncompleteSsa(this) }
6169
}

cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/IRConstruction.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ Instruction getMemoryOperandDefinition(
220220
none()
221221
}
222222

223+
predicate hasIncompleteSsa(IRFunction f) { none() }
224+
223225
/**
224226
* Holds if the operand totally overlaps with its definition and consumes the
225227
* bit range `[startBitOffset, endBitOffset)`.

cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/IRFunction.qll

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,12 @@ class IRFunction extends IRFunctionBase {
5858
* Gets all blocks in this function.
5959
*/
6060
final IRBlock getABlock() { result.getEnclosingIRFunction() = this }
61+
62+
/**
63+
* Holds if this function may have incomplete def-use information.
64+
*
65+
* Def-use information may be omitted for a function when it is too expensive
66+
* to compute.
67+
*/
68+
final predicate hasIncompleteSsa() { Construction::hasIncompleteSsa(this) }
6169
}

cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/SSAConstruction.qll

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,6 +1319,18 @@ predicate canReuseSsaForMemoryResult(Instruction instruction) {
13191319
// We don't support reusing SSA for any location that could create a `Chi` instruction.
13201320
}
13211321

1322+
/**
1323+
* Holds if the def-use information for `f` may have been omitted because it
1324+
* was too expensive to compute. This happens if one of the memory allocations
1325+
* in `f` is a busy definition (i.e., it has many different overlapping uses).
1326+
*/
1327+
predicate hasIncompleteSsa(IRFunction f) {
1328+
exists(Alias::MemoryLocation0 defLocation |
1329+
Alias::isBusyDef(defLocation) and
1330+
defLocation.getIRFunction() = f
1331+
)
1332+
}
1333+
13221334
/**
13231335
* Expose some of the internal predicates to PrintSSA.qll. We do this by publicly importing those modules in the
13241336
* `DebugSsa` module, which is then imported by PrintSSA.

0 commit comments

Comments
 (0)
0