Skip to content

Commit a0bfbda

Browse files
committed
C++: Improve performance by not calling getDef, but instead refer to isDefinitionInexact. This gives roughly the same tuple numbers we had with only instruction nodes.
1 parent 8c6753a commit a0bfbda

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -521,9 +521,9 @@ private predicate getFieldSizeOfClass(Class c, Type type, int size) {
521521

522522
cached
523523
private predicate simpleInstructionLocalFlowStep(Operand opFrom, Instruction iTo) {
524-
iTo.(CopyInstruction).getSourceValue() = opFrom.getDef()
524+
iTo.(CopyInstruction).getSourceValueOperand() = opFrom and not opFrom.isDefinitionInexact()
525525
or
526-
iTo.(PhiInstruction).getAnInput() = opFrom.getDef()
526+
iTo.(PhiInstruction).getAnInputOperand() = opFrom and not opFrom.isDefinitionInexact()
527527
or
528528
// A read side effect is almost never exact since we don't know exactly how
529529
// much memory the callee will read.
@@ -542,7 +542,7 @@ private predicate simpleInstructionLocalFlowStep(Operand opFrom, Instruction iTo
542542
// leads to a phi node.
543543
exists(InitializeIndirectionInstruction init |
544544
opFrom.getAnyDef() = init and
545-
iTo.(LoadInstruction).getSourceValueOperand().getAnyDef() = init and
545+
iTo.(LoadInstruction).getSourceValueOperand() = opFrom and
546546
// Check that the types match. Otherwise we can get flow from an object to
547547
// its fields, which leads to field conflation when there's flow from other
548548
// fields to the object elsewhere.
@@ -551,11 +551,13 @@ private predicate simpleInstructionLocalFlowStep(Operand opFrom, Instruction iTo
551551
)
552552
or
553553
// Treat all conversions as flow, even conversions between different numeric types.
554-
iTo.(ConvertInstruction).getUnary() = opFrom.getDef()
554+
iTo.(ConvertInstruction).getUnaryOperand() = opFrom and not opFrom.isDefinitionInexact()
555555
or
556-
iTo.(CheckedConvertOrNullInstruction).getUnary() = opFrom.getDef()
556+
iTo.(CheckedConvertOrNullInstruction).getUnaryOperand() = opFrom and
557+
not opFrom.isDefinitionInexact()
557558
or
558-
iTo.(InheritanceConversionInstruction).getUnary() = opFrom.getDef()
559+
iTo.(InheritanceConversionInstruction).getUnaryOperand() = opFrom and
560+
not opFrom.isDefinitionInexact()
559561
or
560562
// A chi instruction represents a point where a new value (the _partial_
561563
// operand) may overwrite an old value (the _total_ operand), but the alias

0 commit comments

Comments
 (0)