Skip to content

Commit 0c6b60b

Browse files
committed
C++: Avoid two joins on value number.
1 parent d325082 commit 0c6b60b

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

cpp/ql/lib/experimental/semmle/code/cpp/semantic/SemanticExprSpecific.qll

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ module SemanticExprConfig {
215215
newtype TSsaVariable =
216216
TSsaInstruction(IR::Instruction instr) { instr.hasMemoryResult() } or
217217
TSsaOperand(IR::Operand op) { op.isDefinitionInexact() } or
218-
TSsaPointerArithmeticGuard(IR::PointerArithmeticInstruction instr) {
218+
TSsaPointerArithmeticGuard(ValueNumber instr) {
219219
exists(Guard g, IR::Operand use | use = instr.getAUse() |
220220
g.comparesLt(use, _, _, _, _) or
221221
g.comparesLt(_, use, _, _, _) or
@@ -231,7 +231,7 @@ module SemanticExprConfig {
231231

232232
IR::Instruction asInstruction() { none() }
233233

234-
IR::PointerArithmeticInstruction asPointerArithGuard() { none() }
234+
ValueNumber asPointerArithGuard() { none() }
235235

236236
IR::Operand asOperand() { none() }
237237
}
@@ -249,15 +249,15 @@ module SemanticExprConfig {
249249
}
250250

251251
class SsaPointerArithmeticGuard extends SsaVariable, TSsaPointerArithmeticGuard {
252-
IR::PointerArithmeticInstruction instr;
252+
ValueNumber vn;
253253

254-
SsaPointerArithmeticGuard() { this = TSsaPointerArithmeticGuard(instr) }
254+
SsaPointerArithmeticGuard() { this = TSsaPointerArithmeticGuard(vn) }
255255

256-
final override string toString() { result = instr.toString() }
256+
final override string toString() { result = vn.toString() }
257257

258-
final override Location getLocation() { result = instr.getLocation() }
258+
final override Location getLocation() { result = vn.getLocation() }
259259

260-
final override IR::PointerArithmeticInstruction asPointerArithGuard() { result = instr }
260+
final override ValueNumber asPointerArithGuard() { result = vn }
261261
}
262262

263263
class SsaOperand extends SsaVariable, TSsaOperand {
@@ -289,7 +289,7 @@ module SemanticExprConfig {
289289
Expr getAUse(SsaVariable v) {
290290
result.getUnconverted().(IR::LoadInstruction).getSourceValue() = v.asInstruction()
291291
or
292-
result.getUnconverted() = valueNumber(v.asPointerArithGuard()).getAnInstruction()
292+
result.getUnconverted() = v.asPointerArithGuard().getAnInstruction()
293293
}
294294

295295
SemType getSsaVariableType(SsaVariable v) {
@@ -331,7 +331,7 @@ module SemanticExprConfig {
331331
final override predicate hasRead(SsaVariable v) {
332332
exists(IR::Operand operand |
333333
operand.getDef() = v.asInstruction() or
334-
operand.getDef() = valueNumber(v.asPointerArithGuard()).getAnInstruction()
334+
operand.getDef() = v.asPointerArithGuard().getAnInstruction()
335335
|
336336
not operand instanceof IR::PhiInputOperand and
337337
operand.getUse().getBlock() = block
@@ -352,7 +352,7 @@ module SemanticExprConfig {
352352
final override predicate hasRead(SsaVariable v) {
353353
exists(IR::PhiInputOperand operand |
354354
operand.getDef() = v.asInstruction() or
355-
operand.getDef() = valueNumber(v.asPointerArithGuard()).getAnInstruction()
355+
operand.getDef() = v.asPointerArithGuard().getAnInstruction()
356356
|
357357
operand.getPredecessorBlock() = pred and
358358
operand.getUse().getBlock() = succ

0 commit comments

Comments
 (0)