Skip to content

Commit ad5a16e

Browse files
Merge pull request #1568 from jbj/ir-valuenumbering-copy
C++ IR: Don't propagate GVN through non-exact Copy
2 parents d497fd2 + da13dc6 commit ad5a16e

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/gvn/ValueNumbering.qll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ private predicate numberableInstruction(Instruction instr) {
124124
instr instanceof StringConstantInstruction or
125125
instr instanceof FieldAddressInstruction or
126126
instr instanceof BinaryInstruction or
127-
instr instanceof UnaryInstruction or
127+
(instr instanceof UnaryInstruction and not instr instanceof CopyInstruction) or
128128
instr instanceof PointerArithmeticInstruction or
129129
instr instanceof CongruentCopyInstruction
130130
}
@@ -191,6 +191,7 @@ private predicate unaryValueNumber(UnaryInstruction instr, IRFunction irFunc, Op
191191
Type type, ValueNumber operand) {
192192
instr.getEnclosingIRFunction() = irFunc and
193193
(not instr instanceof InheritanceConversionInstruction) and
194+
(not instr instanceof CopyInstruction) and
194195
instr.getOpcode() = opcode and
195196
instr.getResultType() = type and
196197
valueNumber(instr.getUnary()) = operand

cpp/ql/src/semmle/code/cpp/ir/implementation/raw/gvn/ValueNumbering.qll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ private predicate numberableInstruction(Instruction instr) {
124124
instr instanceof StringConstantInstruction or
125125
instr instanceof FieldAddressInstruction or
126126
instr instanceof BinaryInstruction or
127-
instr instanceof UnaryInstruction or
127+
(instr instanceof UnaryInstruction and not instr instanceof CopyInstruction) or
128128
instr instanceof PointerArithmeticInstruction or
129129
instr instanceof CongruentCopyInstruction
130130
}
@@ -191,6 +191,7 @@ private predicate unaryValueNumber(UnaryInstruction instr, IRFunction irFunc, Op
191191
Type type, ValueNumber operand) {
192192
instr.getEnclosingIRFunction() = irFunc and
193193
(not instr instanceof InheritanceConversionInstruction) and
194+
(not instr instanceof CopyInstruction) and
194195
instr.getOpcode() = opcode and
195196
instr.getResultType() = type and
196197
valueNumber(instr.getUnary()) = operand

cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/gvn/ValueNumbering.qll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ private predicate numberableInstruction(Instruction instr) {
124124
instr instanceof StringConstantInstruction or
125125
instr instanceof FieldAddressInstruction or
126126
instr instanceof BinaryInstruction or
127-
instr instanceof UnaryInstruction or
127+
(instr instanceof UnaryInstruction and not instr instanceof CopyInstruction) or
128128
instr instanceof PointerArithmeticInstruction or
129129
instr instanceof CongruentCopyInstruction
130130
}
@@ -191,6 +191,7 @@ private predicate unaryValueNumber(UnaryInstruction instr, IRFunction irFunc, Op
191191
Type type, ValueNumber operand) {
192192
instr.getEnclosingIRFunction() = irFunc and
193193
(not instr instanceof InheritanceConversionInstruction) and
194+
(not instr instanceof CopyInstruction) and
194195
instr.getOpcode() = opcode and
195196
instr.getResultType() = type and
196197
valueNumber(instr.getUnary()) = operand

0 commit comments

Comments
 (0)