From 0f2c7005fcc21a6a996fc3d65d020c4c723a6b20 Mon Sep 17 00:00:00 2001 From: Jonas Jensen Date: Tue, 15 Jan 2019 16:01:54 +0100 Subject: [PATCH] C++: Sync files that should be identical These files had come out of sync due to 89148a9ec7 and 8c9c316e1b. I synced the files by replaying the changes that those commits made in `aliased_ssa/` to the two other copies. --- .../code/cpp/ir/implementation/raw/Instruction.qll | 3 +++ .../ir/implementation/raw/gvn/ValueNumbering.qll | 13 ++++++++++++- .../ir/implementation/unaliased_ssa/Instruction.qll | 3 +++ .../unaliased_ssa/gvn/ValueNumbering.qll | 13 ++++++++++++- 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/cpp/ql/src/semmle/code/cpp/ir/implementation/raw/Instruction.qll b/cpp/ql/src/semmle/code/cpp/ir/implementation/raw/Instruction.qll index 449d7544a04b..dcad960d8dfd 100644 --- a/cpp/ql/src/semmle/code/cpp/ir/implementation/raw/Instruction.qll +++ b/cpp/ql/src/semmle/code/cpp/ir/implementation/raw/Instruction.qll @@ -751,6 +751,9 @@ class BinaryInstruction extends Instruction { result = getAnOperand().(RightOperand).getDefinitionInstruction() } + /** + * Holds if this instruction's operands are `op1` and `op2`, in either order. + */ final predicate hasOperands(Operand op1, Operand op2) { op1 = getAnOperand().(LeftOperand) and op2 = getAnOperand().(RightOperand) or diff --git a/cpp/ql/src/semmle/code/cpp/ir/implementation/raw/gvn/ValueNumbering.qll b/cpp/ql/src/semmle/code/cpp/ir/implementation/raw/gvn/ValueNumbering.qll index d5c6752479eb..c03ddf991626 100644 --- a/cpp/ql/src/semmle/code/cpp/ir/implementation/raw/gvn/ValueNumbering.qll +++ b/cpp/ql/src/semmle/code/cpp/ir/implementation/raw/gvn/ValueNumbering.qll @@ -83,6 +83,10 @@ class ValueNumber extends TValueNumber { instr order by instr.getBlock().getDisplayIndex(), instr.getDisplayIndexInBlock() ) } + + final Operand getAUse() { + this = valueNumber(result.getDefinitionInstruction()) + } } /** @@ -212,7 +216,7 @@ private predicate uniqueValueNumber(Instruction instr, FunctionIR funcIR) { /** * Gets the value number assigned to `instr`, if any. Returns at most one result. */ -ValueNumber valueNumber(Instruction instr) { +cached ValueNumber valueNumber(Instruction instr) { result = nonUniqueValueNumber(instr) or exists(FunctionIR funcIR | uniqueValueNumber(instr, funcIR) and @@ -220,6 +224,13 @@ ValueNumber valueNumber(Instruction instr) { ) } +/** + * Gets the value number assigned to `instr`, if any. Returns at most one result. + */ +ValueNumber valueNumberOfOperand(Operand op) { + result = valueNumber(op.getDefinitionInstruction()) +} + /** * Gets the value number assigned to `instr`, if any, unless that instruction is assigned a unique * value number. diff --git a/cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/Instruction.qll b/cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/Instruction.qll index 449d7544a04b..dcad960d8dfd 100644 --- a/cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/Instruction.qll +++ b/cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/Instruction.qll @@ -751,6 +751,9 @@ class BinaryInstruction extends Instruction { result = getAnOperand().(RightOperand).getDefinitionInstruction() } + /** + * Holds if this instruction's operands are `op1` and `op2`, in either order. + */ final predicate hasOperands(Operand op1, Operand op2) { op1 = getAnOperand().(LeftOperand) and op2 = getAnOperand().(RightOperand) or diff --git a/cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/gvn/ValueNumbering.qll b/cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/gvn/ValueNumbering.qll index d5c6752479eb..c03ddf991626 100644 --- a/cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/gvn/ValueNumbering.qll +++ b/cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/gvn/ValueNumbering.qll @@ -83,6 +83,10 @@ class ValueNumber extends TValueNumber { instr order by instr.getBlock().getDisplayIndex(), instr.getDisplayIndexInBlock() ) } + + final Operand getAUse() { + this = valueNumber(result.getDefinitionInstruction()) + } } /** @@ -212,7 +216,7 @@ private predicate uniqueValueNumber(Instruction instr, FunctionIR funcIR) { /** * Gets the value number assigned to `instr`, if any. Returns at most one result. */ -ValueNumber valueNumber(Instruction instr) { +cached ValueNumber valueNumber(Instruction instr) { result = nonUniqueValueNumber(instr) or exists(FunctionIR funcIR | uniqueValueNumber(instr, funcIR) and @@ -220,6 +224,13 @@ ValueNumber valueNumber(Instruction instr) { ) } +/** + * Gets the value number assigned to `instr`, if any. Returns at most one result. + */ +ValueNumber valueNumberOfOperand(Operand op) { + result = valueNumber(op.getDefinitionInstruction()) +} + /** * Gets the value number assigned to `instr`, if any, unless that instruction is assigned a unique * value number.