Skip to content

Commit 200d947

Browse files
committed
C++: Add isPartialUpdate member predicate to ChiInstructions.
1 parent fe07630 commit 200d947

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/Instruction.qll

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2055,6 +2055,13 @@ class ChiInstruction extends Instruction {
20552055
final predicate getUpdatedInterval(int startBit, int endBit) {
20562056
Construction::getIntervalUpdatedByChi(this, startBit, endBit)
20572057
}
2058+
2059+
/**
2060+
* Holds if the `ChiPartialOperand` totally, but not exactly, overlaps with the `ChiTotalOperand`.
2061+
* This means that the `ChiPartialOperand` will not override the entire memory associated with the
2062+
* `ChiTotalOperand`.
2063+
*/
2064+
final predicate isPartialUpdate() { Construction::chiOnlyPartiallyUpdatesLocation(this) }
20582065
}
20592066

20602067
/**

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,22 @@ private module Cached {
178178
)
179179
}
180180

181+
/**
182+
* Holds if the `ChiPartialOperand` totally, but not exactly, overlaps with the `ChiTotalOperand`.
183+
* This means that the `ChiPartialOperand` will not override the entire memory associated with the
184+
* `ChiTotalOperand`.
185+
*/
186+
cached
187+
predicate chiOnlyPartiallyUpdatesLocation(ChiInstruction chi) {
188+
exists(Alias::MemoryLocation location, OldInstruction oldInstruction |
189+
oldInstruction = getOldInstruction(chi.getPartial()) and
190+
location = Alias::getResultMemoryLocation(oldInstruction)
191+
|
192+
Alias::getStartBitOffset(location) != 0 or
193+
Alias::getEndBitOffset(location) != 8 * location.getType().getByteSize()
194+
)
195+
}
196+
181197
/**
182198
* Holds if `instr` is part of a cycle in the operand graph that doesn't go
183199
* through a phi instruction and therefore should be impossible.

0 commit comments

Comments
 (0)