Skip to content

Commit c21d5a8

Browse files
committed
C++: Remove GroupedMemoryLocation
In the unaliased SSA it's empty, and the aliased SSA has now been removed.
1 parent 78e05c6 commit c21d5a8

File tree

2 files changed

+1
-86
lines changed

2 files changed

+1
-86
lines changed

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

Lines changed: 1 addition & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,6 @@ private module Cached {
7777
hasChiNode(_, primaryInstruction)
7878
}
7979

80-
cached
81-
predicate hasChiNodeAfterUninitializedGroup(UninitializedGroupInstruction initGroup) {
82-
hasChiNodeAfterUninitializedGroup(_, initGroup)
83-
}
84-
8580
cached
8681
predicate hasUnreachedInstructionCached(IRFunction irFunc) {
8782
exists(OldIR::Instruction oldInstruction |
@@ -191,13 +186,6 @@ private module Cached {
191186
exists(Instruction input | instruction = getChi(input) |
192187
Alias::getResultMemoryLocation(input).getVirtualVariable() instanceof
193188
Alias::AliasedVirtualVariable
194-
or
195-
// A chi following an `UninitializedGroupInstruction` only happens when the virtual
196-
// variable of the grouped memory location is `{AllAliasedMemory}`.
197-
exists(Alias::GroupedMemoryLocation gml |
198-
input = uninitializedGroup(gml.getGroup()) and
199-
gml.getVirtualVariable() instanceof Alias::AliasedVirtualVariable
200-
)
201189
)
202190
or
203191
// Phi instructions track locations, and therefore a phi instruction is
@@ -459,9 +447,7 @@ private module Cached {
459447
instruction = getInitGroupInstruction(i, func) and
460448
kind instanceof GotoEdge
461449
|
462-
if hasChiNodeAfterUninitializedGroup(_, instruction)
463-
then result = getChi(instruction)
464-
else result = getInitGroupInstruction(i + 1, func)
450+
result = getInitGroupInstruction(i + 1, func)
465451
)
466452
or
467453
exists(int i, IRFunction func, UninitializedGroupInstruction initGroup |
@@ -657,8 +643,6 @@ private module Cached {
657643
instr = chiInstruction(primaryInstr) and result = vvar.getType()
658644
|
659645
hasChiNode(vvar, primaryInstr)
660-
or
661-
hasChiNodeAfterUninitializedGroup(vvar, primaryInstr)
662646
)
663647
or
664648
exists(Alias::VariableGroup vg |
@@ -772,16 +756,6 @@ private predicate hasChiNode(Alias::VirtualVariable vvar, OldInstruction def) {
772756
)
773757
}
774758

775-
private predicate hasChiNodeAfterUninitializedGroup(
776-
Alias::AliasedVirtualVariable vvar, UninitializedGroupInstruction initGroup
777-
) {
778-
exists(Alias::GroupedMemoryLocation defLocation |
779-
initGroup = uninitializedGroup(defLocation.getGroup()) and
780-
defLocation.getVirtualVariable() = vvar and
781-
Alias::getOverlap(defLocation, vvar) instanceof MayPartiallyOverlap
782-
)
783-
}
784-
785759
private import PhiInsertion
786760

787761
/**
@@ -996,31 +970,6 @@ module DefUse {
996970
hasDefinition(_, defLocation, defBlock, defOffset) and
997971
result = getPhi(defBlock, defLocation) and
998972
actualDefLocation = defLocation
999-
or
1000-
exists(
1001-
Alias::VariableGroup vg, int index, UninitializedGroupInstruction initGroup,
1002-
Alias::GroupedMemoryLocation gml
1003-
|
1004-
// Add 3 to account for the function prologue:
1005-
// v1(void) = EnterFunction
1006-
// m1(unknown) = AliasedDefinition
1007-
// m2(unknown) = InitializeNonLocal
1008-
index = 3 + vg.getInitializationOrder() and
1009-
not gml.isMayAccess() and
1010-
gml.isSome() and
1011-
gml.getGroup() = vg and
1012-
vg.getIRFunction().getEntryBlock() = defBlock and
1013-
initGroup = uninitializedGroup(vg) and
1014-
(defLocation = gml or defLocation = gml.getVirtualVariable())
1015-
|
1016-
result = initGroup and
1017-
defOffset = 2 * index and
1018-
actualDefLocation = defLocation
1019-
or
1020-
result = getChi(initGroup) and
1021-
defOffset = 2 * index + 1 and
1022-
actualDefLocation = defLocation.getVirtualVariable()
1023-
)
1024973
}
1025974

1026975
private ChiInstruction remapGetDefinitionOrChiInstruction(Instruction oldResult) {
@@ -1187,18 +1136,6 @@ module DefUse {
11871136
then offset = getChiOffset(index, block) // The use will be connected to the definition on the `Chi` instruction.
11881137
else offset = getNonChiOffset(index, block) // The use will be connected to the definition on the original instruction.
11891138
)
1190-
or
1191-
exists(UninitializedGroupInstruction initGroup, int index, Overlap overlap, VariableGroup vg |
1192-
initGroup.getEnclosingIRFunction().getEntryBlock() = getNewBlock(block) and
1193-
vg = defLocation.(Alias::GroupedMemoryLocation).getGroup() and
1194-
// EnterFunction + AliasedDefinition + InitializeNonLocal + index
1195-
index = 3 + vg.getInitializationOrder() and
1196-
initGroup = uninitializedGroup(vg) and
1197-
overlap = Alias::getOverlap(defLocation, useLocation) and
1198-
if overlap instanceof MayPartiallyOverlap and hasChiNodeAfterUninitializedGroup(initGroup)
1199-
then offset = 2 * index + 1 // The use will be connected to the definition on the `Chi` instruction.
1200-
else offset = 2 * index // The use will be connected to the definition on the original instruction.
1201-
)
12021139
}
12031140

12041141
/**
@@ -1412,8 +1349,6 @@ module Ssa {
14121349

14131350
predicate hasChiInstruction = Cached::hasChiInstructionCached/1;
14141351

1415-
predicate hasChiNodeAfterUninitializedGroup = Cached::hasChiNodeAfterUninitializedGroup/1;
1416-
14171352
predicate hasUnreachedInstruction = Cached::hasUnreachedInstructionCached/1;
14181353

14191354
class VariableGroup = Alias::VariableGroup;

cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/SimpleSSA.qll

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -91,26 +91,6 @@ abstract class VariableGroup extends Unit {
9191
abstract int getInitializationOrder();
9292
}
9393

94-
class GroupedMemoryLocation extends MemoryLocation {
95-
VariableGroup vg;
96-
97-
GroupedMemoryLocation() { none() }
98-
99-
/** Gets an allocation of this memory location. */
100-
Allocation getAnAllocation() { result = vg.getAnAllocation() }
101-
102-
/** Gets the set of allocations associated with this memory location. */
103-
VariableGroup getGroup() { result = vg }
104-
105-
predicate isMayAccess() { none() }
106-
107-
/** Holds if this memory location represents all the enclosing allocations. */
108-
predicate isAll() { none() }
109-
110-
/** Holds if this memory location represents one or more of the enclosing allocations. */
111-
predicate isSome() { none() }
112-
}
113-
11494
/**
11595
* Represents a set of `MemoryLocation`s that cannot overlap with
11696
* `MemoryLocation`s outside of the set. The `VirtualVariable` will be

0 commit comments

Comments
 (0)