Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8b8a8ca

Browse files
committed
C++/C#: Sync identical files
1 parent 4a7b865 commit 8b8a8ca

4 files changed

Lines changed: 28 additions & 6 deletions

File tree

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,12 @@ newtype TValueNumber =
6161
*/
6262
class CongruentCopyInstruction extends CopyInstruction {
6363
CongruentCopyInstruction() {
64-
strictcount(this.getSourceValueOperand().getDefinitionOverlap()) = 1 and
6564
this.getSourceValueOperand().getDefinitionOverlap() instanceof MustExactlyOverlap
6665
}
6766
}
6867

6968
class LoadTotalOverlapInstruction extends LoadInstruction {
7069
LoadTotalOverlapInstruction() {
71-
strictcount(this.getSourceValueOperand().getDefinitionOverlap()) = 1 and
7270
this.getSourceValueOperand().getDefinitionOverlap() instanceof MustTotallyOverlap
7371
}
7472
}

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,12 @@ newtype TValueNumber =
6161
*/
6262
class CongruentCopyInstruction extends CopyInstruction {
6363
CongruentCopyInstruction() {
64-
strictcount(this.getSourceValueOperand().getDefinitionOverlap()) = 1 and
6564
this.getSourceValueOperand().getDefinitionOverlap() instanceof MustExactlyOverlap
6665
}
6766
}
6867

6968
class LoadTotalOverlapInstruction extends LoadInstruction {
7069
LoadTotalOverlapInstruction() {
71-
strictcount(this.getSourceValueOperand().getDefinitionOverlap()) = 1 and
7270
this.getSourceValueOperand().getDefinitionOverlap() instanceof MustTotallyOverlap
7371
}
7472
}

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ private module Cached {
9696
}
9797

9898
cached
99-
Instruction getMemoryOperandDefinition(
99+
private Instruction getMemoryOperandDefinition0(
100100
Instruction instruction, MemoryOperandTag tag, Overlap overlap
101101
) {
102102
exists(OldInstruction oldInstruction, OldIR::NonPhiMemoryOperand oldOperand |
@@ -142,6 +142,19 @@ private module Cached {
142142
overlap instanceof MustExactlyOverlap
143143
}
144144

145+
cached
146+
Instruction getMemoryOperandDefinition(
147+
Instruction instruction, MemoryOperandTag tag, Overlap overlap
148+
) {
149+
// getMemoryOperandDefinition0 currently has a bug where it can match with multiple overlaps.
150+
// This predicate ensures that the chosen overlap is the most conservative if there's any doubt.
151+
result = getMemoryOperandDefinition0(instruction, tag, overlap) and
152+
not (
153+
overlap instanceof MustExactlyOverlap and
154+
exists(MustTotallyOverlap o | exists(getMemoryOperandDefinition0(instruction, tag, o)))
155+
)
156+
}
157+
145158
/**
146159
* Holds if `instr` is part of a cycle in the operand graph that doesn't go
147160
* through a phi instruction and therefore should be impossible.

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ private module Cached {
9696
}
9797

9898
cached
99-
Instruction getMemoryOperandDefinition(
99+
private Instruction getMemoryOperandDefinition0(
100100
Instruction instruction, MemoryOperandTag tag, Overlap overlap
101101
) {
102102
exists(OldInstruction oldInstruction, OldIR::NonPhiMemoryOperand oldOperand |
@@ -142,6 +142,19 @@ private module Cached {
142142
overlap instanceof MustExactlyOverlap
143143
}
144144

145+
cached
146+
Instruction getMemoryOperandDefinition(
147+
Instruction instruction, MemoryOperandTag tag, Overlap overlap
148+
) {
149+
// getMemoryOperandDefinition0 currently has a bug where it can match with multiple overlaps.
150+
// This predicate ensures that the chosen overlap is the most conservative if there's any doubt.
151+
result = getMemoryOperandDefinition0(instruction, tag, overlap) and
152+
not (
153+
overlap instanceof MustExactlyOverlap and
154+
exists(MustTotallyOverlap o | exists(getMemoryOperandDefinition0(instruction, tag, o)))
155+
)
156+
}
157+
145158
/**
146159
* Holds if `instr` is part of a cycle in the operand graph that doesn't go
147160
* through a phi instruction and therefore should be impossible.

0 commit comments

Comments
 (0)