Skip to content

Commit b06902a

Browse files
committed
C++: Share more indirect operands and instructions.
1 parent e73745d commit b06902a

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/SsaInternalsCommon.qll

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -630,10 +630,18 @@ private module Cached {
630630
Operand operand, int indirectionIndex, Operand operandRepr, int indirectionIndexRepr
631631
) {
632632
indirectionIndex = [1 .. countIndirectionsForCppType(getLanguageType(operand))] and
633-
exists(Instruction load |
634-
isDereference(load, operand, false) and
635-
operandRepr = unique( | | getAUse(load)) and
636-
indirectionIndexRepr = indirectionIndex - 1
633+
(
634+
exists(Instruction load |
635+
isDereference(load, operand, false) and
636+
operandRepr = unique( | | getAUse(load)) and
637+
indirectionIndexRepr = indirectionIndex - 1
638+
)
639+
or
640+
exists(CopyValueInstruction copy |
641+
copy.getSourceValueOperand() = operand and
642+
operandRepr = unique( | | getAUse(copy)) and
643+
indirectionIndexRepr = indirectionIndex
644+
)
637645
)
638646
}
639647

@@ -649,11 +657,19 @@ private module Cached {
649657
Instruction instr, int indirectionIndex, Instruction instrRepr, int indirectionIndexRepr
650658
) {
651659
indirectionIndex = [1 .. countIndirectionsForCppType(getResultLanguageType(instr))] and
652-
exists(Instruction load, Operand address |
653-
address = unique( | | getAUse(instr)) and
654-
isDereference(load, address, false) and
655-
instrRepr = load and
656-
indirectionIndexRepr = indirectionIndex - 1
660+
(
661+
exists(Instruction load, Operand address |
662+
address = unique( | | getAUse(instr)) and
663+
isDereference(load, address, false) and
664+
instrRepr = load and
665+
indirectionIndexRepr = indirectionIndex - 1
666+
)
667+
or
668+
exists(CopyValueInstruction copy |
669+
copy.getSourceValueOperand() = unique( | | getAUse(instr)) and
670+
instrRepr = copy and
671+
indirectionIndexRepr = indirectionIndex
672+
)
657673
)
658674
}
659675

0 commit comments

Comments
 (0)