Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e62b884

Browse files
author
Dave Bartolomeo
committed
C++/C#: Cache Instruction.getResultIRType()
Most of the predicates on `Instruction` are thin wrappers around cached predicates in the `IRConstruction` or `SSAConstruction` modules. However, `getResultIRType()` has to join `Construction::getInstructionResultType()` with `LanguageType::getIRType()`. `getResultIRType()` is called frequently both within the IR code and by IR consumers, and that's a big join to have to repeat in multiple stages. I looked at most of the other predicates in `Instruction.qll`, and didn't see any other predicates that met all of the criteria of "large, commonly called, and not already inline".
1 parent c708ed1 commit e62b884

5 files changed

Lines changed: 5 additions & 0 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ class Instruction extends Construction::TStageInstruction {
218218
* Gets the type of the result produced by this instruction. If the instruction does not produce
219219
* a result, its result type will be `IRVoidType`.
220220
*/
221+
cached
221222
final IRType getResultIRType() { result = getResultLanguageType().getIRType() }
222223

223224
/**

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ class Instruction extends Construction::TStageInstruction {
218218
* Gets the type of the result produced by this instruction. If the instruction does not produce
219219
* a result, its result type will be `IRVoidType`.
220220
*/
221+
cached
221222
final IRType getResultIRType() { result = getResultLanguageType().getIRType() }
222223

223224
/**

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ class Instruction extends Construction::TStageInstruction {
218218
* Gets the type of the result produced by this instruction. If the instruction does not produce
219219
* a result, its result type will be `IRVoidType`.
220220
*/
221+
cached
221222
final IRType getResultIRType() { result = getResultLanguageType().getIRType() }
222223

223224
/**

csharp/ql/src/semmle/code/csharp/ir/implementation/raw/Instruction.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ class Instruction extends Construction::TStageInstruction {
218218
* Gets the type of the result produced by this instruction. If the instruction does not produce
219219
* a result, its result type will be `IRVoidType`.
220220
*/
221+
cached
221222
final IRType getResultIRType() { result = getResultLanguageType().getIRType() }
222223

223224
/**

csharp/ql/src/semmle/code/csharp/ir/implementation/unaliased_ssa/Instruction.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ class Instruction extends Construction::TStageInstruction {
218218
* Gets the type of the result produced by this instruction. If the instruction does not produce
219219
* a result, its result type will be `IRVoidType`.
220220
*/
221+
cached
221222
final IRType getResultIRType() { result = getResultLanguageType().getIRType() }
222223

223224
/**

0 commit comments

Comments
 (0)