Skip to content

Commit 9ee8a89

Browse files
committed
C++ IR: Make TOperand cached
Just like `TInstruction` is cached to prevent re-numbering its tuples in every IR query, I think `TOperand` should be cached too. I tested it on the small comdb2 snapshot, where it only saves one second of work when running a second IR query, but the savings should grow when snapshots are larger and when there are more IR queries in a suite. Tuple numbering is mildly quadratic, so it should be good to avoid repeating it. Adding these annotations adds three cached stages to the existing four cached stages of the IR. The new cached stages are small and do not appear to repeat any work from the other stages, so I see no advantage to merging them with the existing stages.
1 parent 46d7792 commit 9ee8a89

File tree

3 files changed

+3
-0
lines changed

3 files changed

+3
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import semmle.code.cpp.ir.implementation.MemoryAccessKind
66
import semmle.code.cpp.ir.internal.Overlap
77
private import semmle.code.cpp.ir.internal.OperandTag
88

9+
cached
910
private newtype TOperand =
1011
TRegisterOperand(Instruction useInstr, RegisterOperandTag tag, Instruction defInstr) {
1112
defInstr = Construction::getRegisterOperandDefinition(useInstr, tag)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import semmle.code.cpp.ir.implementation.MemoryAccessKind
66
import semmle.code.cpp.ir.internal.Overlap
77
private import semmle.code.cpp.ir.internal.OperandTag
88

9+
cached
910
private newtype TOperand =
1011
TRegisterOperand(Instruction useInstr, RegisterOperandTag tag, Instruction defInstr) {
1112
defInstr = Construction::getRegisterOperandDefinition(useInstr, tag)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import semmle.code.cpp.ir.implementation.MemoryAccessKind
66
import semmle.code.cpp.ir.internal.Overlap
77
private import semmle.code.cpp.ir.internal.OperandTag
88

9+
cached
910
private newtype TOperand =
1011
TRegisterOperand(Instruction useInstr, RegisterOperandTag tag, Instruction defInstr) {
1112
defInstr = Construction::getRegisterOperandDefinition(useInstr, tag)

0 commit comments

Comments
 (0)