Skip to content

Commit 73eb3e2

Browse files
authored
Merge pull request #21202 from MathiasVP/add-is-live-predicate-to-ssa-definition
C++: Add `isLiveAtEndOfBlock` predicate to `Ssa::Definition`
2 parents dd41538 + 60ee92d commit 73eb3e2

File tree

1 file changed

+19
-1
lines changed
  • cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal

1 file changed

+19
-1
lines changed

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/SsaImpl.qll

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,16 @@ module SsaCached {
940940
SsaImpl::phiHasInputFromBlock(phi, inp, bb)
941941
}
942942

943+
cached
944+
predicate uncertainWriteDefinitionInput(Definition uncertain, Definition inp) {
945+
SsaImpl::uncertainWriteDefinitionInput(uncertain, inp)
946+
}
947+
948+
cached
949+
predicate ssaDefReachesEndOfBlock(IRBlock bb, Definition def) {
950+
SsaImpl::ssaDefReachesEndOfBlock(bb, def, _)
951+
}
952+
943953
predicate variableRead = SsaInput::variableRead/4;
944954

945955
predicate variableWrite = SsaInput::variableWrite/4;
@@ -1173,9 +1183,17 @@ class Definition extends SsaImpl::Definition {
11731183
private Definition getAPhiInputOrPriorDefinition() {
11741184
result = this.(PhiNode).getAnInput()
11751185
or
1176-
SsaImpl::uncertainWriteDefinitionInput(this, result)
1186+
uncertainWriteDefinitionInput(this, result)
11771187
}
11781188

1189+
/**
1190+
* Holds if this SSA definition is live at the end of basic block `bb`.
1191+
* That is, this definition reaches the end of basic block `bb`, at which
1192+
* point it is still live, without crossing another SSA definition of the
1193+
* same source variable.
1194+
*/
1195+
predicate isLiveAtEndOfBlock(IRBlock bb) { ssaDefReachesEndOfBlock(bb, this) }
1196+
11791197
/**
11801198
* Gets a definition that ultimately defines this SSA definition and is
11811199
* not itself a phi node.

0 commit comments

Comments
 (0)