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

Skip to content

Commit d91bc4b

Browse files
author
Robert Marsh
committed
C++: pull out hasMemoryOperandDefinition (slow)
1 parent c7e62b4 commit d91bc4b

1 file changed

Lines changed: 17 additions & 11 deletions

File tree

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

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

78+
private predicate hasMemoryOperandDefinition (OldInstruction oldInstruction, OldIR::NonPhiMemoryOperand oldOperand,
79+
Overlap overlap, Instruction instr) {
80+
oldOperand = oldInstruction.getAnOperand() and
81+
exists(
82+
OldBlock useBlock, int useRank, Alias::MemoryLocation useLocation,
83+
Alias::MemoryLocation defLocation, OldBlock defBlock, int defRank, int defOffset
84+
|
85+
useLocation = Alias::getOperandMemoryLocation(oldOperand) and
86+
hasDefinitionAtRank(useLocation, defLocation, defBlock, defRank, defOffset) and
87+
hasUseAtRank(useLocation, useBlock, useRank, oldInstruction) and
88+
definitionReachesUse(useLocation, defBlock, defRank, useBlock, useRank) and
89+
overlap = Alias::getOverlap(defLocation, useLocation) and
90+
instr = getDefinitionOrChiInstruction(defBlock, defOffset, defLocation, _)
91+
)
92+
}
93+
7894
cached
7995
Instruction getMemoryOperandDefinition(
8096
Instruction instruction, MemoryOperandTag tag, Overlap overlap
@@ -87,17 +103,7 @@ private module Cached {
87103
(
88104
if exists(Alias::getOperandMemoryLocation(oldOperand))
89105
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-
)
106+
hasMemoryOperandDefinition(oldInstruction, oldOperand, overlap, result)
101107
else (
102108
result = instruction.getEnclosingIRFunction().getUnmodeledDefinitionInstruction() and
103109
overlap instanceof MustTotallyOverlap

0 commit comments

Comments
 (0)