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

Skip to content

Commit bd98427

Browse files
author
Robert Marsh
committed
C++: sync files
1 parent bbf191e commit bd98427

2 files changed

Lines changed: 42 additions & 24 deletions

File tree

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

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,26 @@ private module Cached {
7575
)
7676
}
7777

78+
pragma[noopt]
79+
private predicate hasMemoryOperandDefinition(
80+
OldInstruction oldInstruction, OldIR::NonPhiMemoryOperand oldOperand, Overlap overlap,
81+
Instruction instr
82+
) {
83+
oldOperand = oldInstruction.getAnOperand() and
84+
oldOperand instanceof OldIR::NonPhiMemoryOperand and
85+
exists(
86+
OldBlock useBlock, int useRank, Alias::MemoryLocation useLocation,
87+
Alias::MemoryLocation defLocation, OldBlock defBlock, int defRank, int defOffset
88+
|
89+
useLocation = Alias::getOperandMemoryLocation(oldOperand) and
90+
hasUseAtRank(useLocation, useBlock, useRank, oldInstruction) and
91+
definitionReachesUse(useLocation, defBlock, defRank, useBlock, useRank) and
92+
hasDefinitionAtRank(useLocation, defLocation, defBlock, defRank, defOffset) and
93+
instr = getDefinitionOrChiInstruction(defBlock, defOffset, defLocation, _) and
94+
overlap = Alias::getOverlap(defLocation, useLocation)
95+
)
96+
}
97+
7898
cached
7999
Instruction getMemoryOperandDefinition(
80100
Instruction instruction, MemoryOperandTag tag, Overlap overlap
@@ -86,18 +106,7 @@ private module Cached {
86106
(
87107
(
88108
if exists(Alias::getOperandMemoryLocation(oldOperand))
89-
then
90-
exists(
91-
OldBlock useBlock, int useRank, Alias::MemoryLocation useLocation,
92-
Alias::MemoryLocation defLocation, OldBlock defBlock, int defRank, int defOffset
93-
|
94-
useLocation = Alias::getOperandMemoryLocation(oldOperand) and
95-
hasDefinitionAtRank(useLocation, defLocation, defBlock, defRank, defOffset) and
96-
hasUseAtRank(useLocation, useBlock, useRank, oldInstruction) and
97-
definitionReachesUse(useLocation, defBlock, defRank, useBlock, useRank) and
98-
overlap = Alias::getOverlap(defLocation, useLocation) and
99-
result = getDefinitionOrChiInstruction(defBlock, defOffset, defLocation, _)
100-
)
109+
then hasMemoryOperandDefinition(oldInstruction, oldOperand, overlap, result)
101110
else (
102111
result = instruction.getEnclosingIRFunction().getUnmodeledDefinitionInstruction() and
103112
overlap instanceof MustTotallyOverlap

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

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,26 @@ private module Cached {
7575
)
7676
}
7777

78+
pragma[noopt]
79+
private predicate hasMemoryOperandDefinition(
80+
OldInstruction oldInstruction, OldIR::NonPhiMemoryOperand oldOperand, Overlap overlap,
81+
Instruction instr
82+
) {
83+
oldOperand = oldInstruction.getAnOperand() and
84+
oldOperand instanceof OldIR::NonPhiMemoryOperand and
85+
exists(
86+
OldBlock useBlock, int useRank, Alias::MemoryLocation useLocation,
87+
Alias::MemoryLocation defLocation, OldBlock defBlock, int defRank, int defOffset
88+
|
89+
useLocation = Alias::getOperandMemoryLocation(oldOperand) and
90+
hasUseAtRank(useLocation, useBlock, useRank, oldInstruction) and
91+
definitionReachesUse(useLocation, defBlock, defRank, useBlock, useRank) and
92+
hasDefinitionAtRank(useLocation, defLocation, defBlock, defRank, defOffset) and
93+
instr = getDefinitionOrChiInstruction(defBlock, defOffset, defLocation, _) and
94+
overlap = Alias::getOverlap(defLocation, useLocation)
95+
)
96+
}
97+
7898
cached
7999
Instruction getMemoryOperandDefinition(
80100
Instruction instruction, MemoryOperandTag tag, Overlap overlap
@@ -86,18 +106,7 @@ private module Cached {
86106
(
87107
(
88108
if exists(Alias::getOperandMemoryLocation(oldOperand))
89-
then
90-
exists(
91-
OldBlock useBlock, int useRank, Alias::MemoryLocation useLocation,
92-
Alias::MemoryLocation defLocation, OldBlock defBlock, int defRank, int defOffset
93-
|
94-
useLocation = Alias::getOperandMemoryLocation(oldOperand) and
95-
hasDefinitionAtRank(useLocation, defLocation, defBlock, defRank, defOffset) and
96-
hasUseAtRank(useLocation, useBlock, useRank, oldInstruction) and
97-
definitionReachesUse(useLocation, defBlock, defRank, useBlock, useRank) and
98-
overlap = Alias::getOverlap(defLocation, useLocation) and
99-
result = getDefinitionOrChiInstruction(defBlock, defOffset, defLocation, _)
100-
)
109+
then hasMemoryOperandDefinition(oldInstruction, oldOperand, overlap, result)
101110
else (
102111
result = instruction.getEnclosingIRFunction().getUnmodeledDefinitionInstruction() and
103112
overlap instanceof MustTotallyOverlap

0 commit comments

Comments
 (0)