Skip to content

Commit 8896d3b

Browse files
Merge pull request #856 from jbj/ir-getInstructionOperandDefinition
C++: Speed up `getInstructionOperandDefinition`
2 parents be2a480 + 947634f commit 8896d3b

File tree

5 files changed

+25
-8
lines changed

5 files changed

+25
-8
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ class FunctionIR extends TFunctionIR {
5656
result.getFunctionIR() = this
5757
}
5858

59+
pragma[noinline]
60+
final UnmodeledUseInstruction getUnmodeledUseInstruction() {
61+
result.getFunctionIR() = this
62+
}
63+
5964
/**
6065
* Gets the single return instruction for this function.
6166
*/

cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/internal/SSAConstruction.qll

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,11 @@ cached private module Cached {
192192
instruction.getTag() = ChiTag(getOldInstruction(result)) and
193193
tag instanceof ChiPartialOperandTag
194194
or
195-
instruction instanceof UnmodeledUseInstruction and
196-
tag instanceof UnmodeledUseOperandTag and
197-
result instanceof UnmodeledDefinitionInstruction and
198-
instruction.getFunction() = result.getFunction()
195+
exists(FunctionIR f |
196+
tag instanceof UnmodeledUseOperandTag and
197+
result = f.getUnmodeledDefinitionInstruction() and
198+
instruction = f.getUnmodeledUseInstruction()
199+
)
199200
or
200201
tag instanceof ChiTotalOperandTag and
201202
result = getChiInstructionTotalOperand(instruction)

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ class FunctionIR extends TFunctionIR {
5656
result.getFunctionIR() = this
5757
}
5858

59+
pragma[noinline]
60+
final UnmodeledUseInstruction getUnmodeledUseInstruction() {
61+
result.getFunctionIR() = this
62+
}
63+
5964
/**
6065
* Gets the single return instruction for this function.
6166
*/

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ class FunctionIR extends TFunctionIR {
5656
result.getFunctionIR() = this
5757
}
5858

59+
pragma[noinline]
60+
final UnmodeledUseInstruction getUnmodeledUseInstruction() {
61+
result.getFunctionIR() = this
62+
}
63+
5964
/**
6065
* Gets the single return instruction for this function.
6166
*/

cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/SSAConstruction.qll

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,11 @@ cached private module Cached {
192192
instruction.getTag() = ChiTag(getOldInstruction(result)) and
193193
tag instanceof ChiPartialOperandTag
194194
or
195-
instruction instanceof UnmodeledUseInstruction and
196-
tag instanceof UnmodeledUseOperandTag and
197-
result instanceof UnmodeledDefinitionInstruction and
198-
instruction.getFunction() = result.getFunction()
195+
exists(FunctionIR f |
196+
tag instanceof UnmodeledUseOperandTag and
197+
result = f.getUnmodeledDefinitionInstruction() and
198+
instruction = f.getUnmodeledUseInstruction()
199+
)
199200
or
200201
tag instanceof ChiTotalOperandTag and
201202
result = getChiInstructionTotalOperand(instruction)

0 commit comments

Comments
 (0)