Skip to content

Commit 290b1c6

Browse files
committed
C++: cache the IR stage Operand class
1 parent 0b2daf7 commit 290b1c6

File tree

5 files changed

+25
-25
lines changed

5 files changed

+25
-25
lines changed

cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/Operand.qll

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ private class TStageOperand =
2525
* (the defining instruction) in another instruction (the use instruction)
2626
*/
2727
class Operand extends TStageOperand {
28-
Operand() {
28+
cached Operand() {
2929
// Ensure that the operand does not refer to instructions from earlier stages that are unreachable here
3030
exists(Instruction use, Instruction def | this = registerOperand(use, _, def)) or
3131
exists(Instruction use | this = nonSSAMemoryOperand(use, _)) or
@@ -190,7 +190,7 @@ class Operand extends TStageOperand {
190190
* An operand that consumes a memory result (e.g. the `LoadOperand` on a `Load` instruction).
191191
*/
192192
class MemoryOperand extends Operand {
193-
MemoryOperand() {
193+
cached MemoryOperand() {
194194
this instanceof TNonSSAMemoryOperand or
195195
this instanceof TPhiOperand or
196196
this instanceof TChiOperand
@@ -256,7 +256,7 @@ class RegisterOperand extends NonPhiOperand, TRegisterOperand {
256256
override RegisterOperandTag tag;
257257
Instruction defInstr;
258258

259-
RegisterOperand() { this = registerOperand(useInstr, tag, defInstr) }
259+
cached RegisterOperand() { this = registerOperand(useInstr, tag, defInstr) }
260260

261261
final override string toString() { result = tag.toString() }
262262

@@ -274,7 +274,7 @@ class RegisterOperand extends NonPhiOperand, TRegisterOperand {
274274
class NonPhiMemoryOperand extends NonPhiOperand, MemoryOperand, TNonPhiMemoryOperand {
275275
override MemoryOperandTag tag;
276276

277-
NonPhiMemoryOperand() {
277+
cached NonPhiMemoryOperand() {
278278
this = nonSSAMemoryOperand(useInstr, tag)
279279
or
280280
this = chiOperand(useInstr, tag)
@@ -426,7 +426,7 @@ class PhiInputOperand extends MemoryOperand, TPhiOperand {
426426
IRBlock predecessorBlock;
427427
Overlap overlap;
428428

429-
PhiInputOperand() { this = phiOperand(useInstr, defInstr, predecessorBlock, overlap) }
429+
cached PhiInputOperand() { this = phiOperand(useInstr, defInstr, predecessorBlock, overlap) }
430430

431431
override string toString() { result = "Phi" }
432432

cpp/ql/src/semmle/code/cpp/ir/implementation/raw/Operand.qll

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ private class TStageOperand =
2525
* (the defining instruction) in another instruction (the use instruction)
2626
*/
2727
class Operand extends TStageOperand {
28-
Operand() {
28+
cached Operand() {
2929
// Ensure that the operand does not refer to instructions from earlier stages that are unreachable here
3030
exists(Instruction use, Instruction def | this = registerOperand(use, _, def)) or
3131
exists(Instruction use | this = nonSSAMemoryOperand(use, _)) or
@@ -190,7 +190,7 @@ class Operand extends TStageOperand {
190190
* An operand that consumes a memory result (e.g. the `LoadOperand` on a `Load` instruction).
191191
*/
192192
class MemoryOperand extends Operand {
193-
MemoryOperand() {
193+
cached MemoryOperand() {
194194
this instanceof TNonSSAMemoryOperand or
195195
this instanceof TPhiOperand or
196196
this instanceof TChiOperand
@@ -256,7 +256,7 @@ class RegisterOperand extends NonPhiOperand, TRegisterOperand {
256256
override RegisterOperandTag tag;
257257
Instruction defInstr;
258258

259-
RegisterOperand() { this = registerOperand(useInstr, tag, defInstr) }
259+
cached RegisterOperand() { this = registerOperand(useInstr, tag, defInstr) }
260260

261261
final override string toString() { result = tag.toString() }
262262

@@ -274,7 +274,7 @@ class RegisterOperand extends NonPhiOperand, TRegisterOperand {
274274
class NonPhiMemoryOperand extends NonPhiOperand, MemoryOperand, TNonPhiMemoryOperand {
275275
override MemoryOperandTag tag;
276276

277-
NonPhiMemoryOperand() {
277+
cached NonPhiMemoryOperand() {
278278
this = nonSSAMemoryOperand(useInstr, tag)
279279
or
280280
this = chiOperand(useInstr, tag)
@@ -426,7 +426,7 @@ class PhiInputOperand extends MemoryOperand, TPhiOperand {
426426
IRBlock predecessorBlock;
427427
Overlap overlap;
428428

429-
PhiInputOperand() { this = phiOperand(useInstr, defInstr, predecessorBlock, overlap) }
429+
cached PhiInputOperand() { this = phiOperand(useInstr, defInstr, predecessorBlock, overlap) }
430430

431431
override string toString() { result = "Phi" }
432432

cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/Operand.qll

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ private class TStageOperand =
2525
* (the defining instruction) in another instruction (the use instruction)
2626
*/
2727
class Operand extends TStageOperand {
28-
Operand() {
28+
cached Operand() {
2929
// Ensure that the operand does not refer to instructions from earlier stages that are unreachable here
3030
exists(Instruction use, Instruction def | this = registerOperand(use, _, def)) or
3131
exists(Instruction use | this = nonSSAMemoryOperand(use, _)) or
@@ -190,7 +190,7 @@ class Operand extends TStageOperand {
190190
* An operand that consumes a memory result (e.g. the `LoadOperand` on a `Load` instruction).
191191
*/
192192
class MemoryOperand extends Operand {
193-
MemoryOperand() {
193+
cached MemoryOperand() {
194194
this instanceof TNonSSAMemoryOperand or
195195
this instanceof TPhiOperand or
196196
this instanceof TChiOperand
@@ -256,7 +256,7 @@ class RegisterOperand extends NonPhiOperand, TRegisterOperand {
256256
override RegisterOperandTag tag;
257257
Instruction defInstr;
258258

259-
RegisterOperand() { this = registerOperand(useInstr, tag, defInstr) }
259+
cached RegisterOperand() { this = registerOperand(useInstr, tag, defInstr) }
260260

261261
final override string toString() { result = tag.toString() }
262262

@@ -274,7 +274,7 @@ class RegisterOperand extends NonPhiOperand, TRegisterOperand {
274274
class NonPhiMemoryOperand extends NonPhiOperand, MemoryOperand, TNonPhiMemoryOperand {
275275
override MemoryOperandTag tag;
276276

277-
NonPhiMemoryOperand() {
277+
cached NonPhiMemoryOperand() {
278278
this = nonSSAMemoryOperand(useInstr, tag)
279279
or
280280
this = chiOperand(useInstr, tag)
@@ -426,7 +426,7 @@ class PhiInputOperand extends MemoryOperand, TPhiOperand {
426426
IRBlock predecessorBlock;
427427
Overlap overlap;
428428

429-
PhiInputOperand() { this = phiOperand(useInstr, defInstr, predecessorBlock, overlap) }
429+
cached PhiInputOperand() { this = phiOperand(useInstr, defInstr, predecessorBlock, overlap) }
430430

431431
override string toString() { result = "Phi" }
432432

csharp/ql/src/experimental/ir/implementation/raw/Operand.qll

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ private class TStageOperand =
2525
* (the defining instruction) in another instruction (the use instruction)
2626
*/
2727
class Operand extends TStageOperand {
28-
Operand() {
28+
cached Operand() {
2929
// Ensure that the operand does not refer to instructions from earlier stages that are unreachable here
3030
exists(Instruction use, Instruction def | this = registerOperand(use, _, def)) or
3131
exists(Instruction use | this = nonSSAMemoryOperand(use, _)) or
@@ -190,7 +190,7 @@ class Operand extends TStageOperand {
190190
* An operand that consumes a memory result (e.g. the `LoadOperand` on a `Load` instruction).
191191
*/
192192
class MemoryOperand extends Operand {
193-
MemoryOperand() {
193+
cached MemoryOperand() {
194194
this instanceof TNonSSAMemoryOperand or
195195
this instanceof TPhiOperand or
196196
this instanceof TChiOperand
@@ -256,7 +256,7 @@ class RegisterOperand extends NonPhiOperand, TRegisterOperand {
256256
override RegisterOperandTag tag;
257257
Instruction defInstr;
258258

259-
RegisterOperand() { this = registerOperand(useInstr, tag, defInstr) }
259+
cached RegisterOperand() { this = registerOperand(useInstr, tag, defInstr) }
260260

261261
final override string toString() { result = tag.toString() }
262262

@@ -274,7 +274,7 @@ class RegisterOperand extends NonPhiOperand, TRegisterOperand {
274274
class NonPhiMemoryOperand extends NonPhiOperand, MemoryOperand, TNonPhiMemoryOperand {
275275
override MemoryOperandTag tag;
276276

277-
NonPhiMemoryOperand() {
277+
cached NonPhiMemoryOperand() {
278278
this = nonSSAMemoryOperand(useInstr, tag)
279279
or
280280
this = chiOperand(useInstr, tag)
@@ -426,7 +426,7 @@ class PhiInputOperand extends MemoryOperand, TPhiOperand {
426426
IRBlock predecessorBlock;
427427
Overlap overlap;
428428

429-
PhiInputOperand() { this = phiOperand(useInstr, defInstr, predecessorBlock, overlap) }
429+
cached PhiInputOperand() { this = phiOperand(useInstr, defInstr, predecessorBlock, overlap) }
430430

431431
override string toString() { result = "Phi" }
432432

csharp/ql/src/experimental/ir/implementation/unaliased_ssa/Operand.qll

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ private class TStageOperand =
2525
* (the defining instruction) in another instruction (the use instruction)
2626
*/
2727
class Operand extends TStageOperand {
28-
Operand() {
28+
cached Operand() {
2929
// Ensure that the operand does not refer to instructions from earlier stages that are unreachable here
3030
exists(Instruction use, Instruction def | this = registerOperand(use, _, def)) or
3131
exists(Instruction use | this = nonSSAMemoryOperand(use, _)) or
@@ -190,7 +190,7 @@ class Operand extends TStageOperand {
190190
* An operand that consumes a memory result (e.g. the `LoadOperand` on a `Load` instruction).
191191
*/
192192
class MemoryOperand extends Operand {
193-
MemoryOperand() {
193+
cached MemoryOperand() {
194194
this instanceof TNonSSAMemoryOperand or
195195
this instanceof TPhiOperand or
196196
this instanceof TChiOperand
@@ -256,7 +256,7 @@ class RegisterOperand extends NonPhiOperand, TRegisterOperand {
256256
override RegisterOperandTag tag;
257257
Instruction defInstr;
258258

259-
RegisterOperand() { this = registerOperand(useInstr, tag, defInstr) }
259+
cached RegisterOperand() { this = registerOperand(useInstr, tag, defInstr) }
260260

261261
final override string toString() { result = tag.toString() }
262262

@@ -274,7 +274,7 @@ class RegisterOperand extends NonPhiOperand, TRegisterOperand {
274274
class NonPhiMemoryOperand extends NonPhiOperand, MemoryOperand, TNonPhiMemoryOperand {
275275
override MemoryOperandTag tag;
276276

277-
NonPhiMemoryOperand() {
277+
cached NonPhiMemoryOperand() {
278278
this = nonSSAMemoryOperand(useInstr, tag)
279279
or
280280
this = chiOperand(useInstr, tag)
@@ -426,7 +426,7 @@ class PhiInputOperand extends MemoryOperand, TPhiOperand {
426426
IRBlock predecessorBlock;
427427
Overlap overlap;
428428

429-
PhiInputOperand() { this = phiOperand(useInstr, defInstr, predecessorBlock, overlap) }
429+
cached PhiInputOperand() { this = phiOperand(useInstr, defInstr, predecessorBlock, overlap) }
430430

431431
override string toString() { result = "Phi" }
432432

0 commit comments

Comments
 (0)