C++: Replace 'InitializeGroup' with 'UninitializedGroup'.

This commit is contained in:
Mathias Vorreiter Pedersen
2024-07-16 16:16:50 +01:00
parent 4893785c68
commit 950d70ffed
9 changed files with 100 additions and 92 deletions

View File

@@ -41,7 +41,7 @@ predicate ignoreInstruction(Instruction instr) {
instr instanceof AliasedUseInstruction or instr instanceof AliasedUseInstruction or
instr instanceof InitializeNonLocalInstruction or instr instanceof InitializeNonLocalInstruction or
instr instanceof ReturnIndirectionInstruction or instr instanceof ReturnIndirectionInstruction or
instr instanceof InitializeGroupInstruction instr instanceof UninitializedGroupInstruction
) )
} }

View File

@@ -102,7 +102,7 @@ class ChiPartialMemoryAccess extends MemoryAccessKind, TChiPartialMemoryAccess {
} }
/** /**
* The result of an `InitializeGroup` instruction, which initializes a set of * The result of an `UninitializedGroup` instruction, which initializes a set of
* allocations that are each assigned the same virtual variable. * allocations that are each assigned the same virtual variable.
*/ */
class GroupedMemoryAccess extends MemoryAccessKind, TGroupedMemoryAccess { class GroupedMemoryAccess extends MemoryAccessKind, TGroupedMemoryAccess {

View File

@@ -89,7 +89,7 @@ private newtype TOpcode =
TSizedBufferMayWriteSideEffect() or TSizedBufferMayWriteSideEffect() or
TInitializeDynamicAllocation() or TInitializeDynamicAllocation() or
TChi() or TChi() or
TInitializeGroup() or TUninitializedGroup() or
TInlineAsm() or TInlineAsm() or
TUnreached() or TUnreached() or
TNewObj() TNewObj()
@@ -1239,12 +1239,12 @@ module Opcode {
} }
/** /**
* The `Opcode` for a `InitializeGroup`. * The `Opcode` for a `UninitializedGroup`.
* *
* See the `InitializeGroupInstruction` documentation for more details. * See the `UninitializedGroupInstruction` documentation for more details.
*/ */
class InitializeGroup extends Opcode, TInitializeGroup { class UninitializedGroup extends Opcode, TUninitializedGroup {
final override string toString() { result = "InitializeGroup" } final override string toString() { result = "UninitializedGroup" }
override GroupedMemoryAccess getWriteMemoryAccess() { any() } override GroupedMemoryAccess getWriteMemoryAccess() { any() }
} }

View File

@@ -2162,11 +2162,11 @@ class ChiInstruction extends Instruction {
* *
* Since both the address of `a` and `b` reach `p` at `*p = 5` the IR alias * Since both the address of `a` and `b` reach `p` at `*p = 5` the IR alias
* analysis will create a region that contains both `a` and `b`. The region * analysis will create a region that contains both `a` and `b`. The region
* containing both `a` and `b` are initialized by an `InitializeGroup` * containing both `a` and `b` are initialized by an `UninitializedGroup`
* instruction in the entry block of the enclosing function. * instruction in the entry block of the enclosing function.
*/ */
class InitializeGroupInstruction extends Instruction { class UninitializedGroupInstruction extends Instruction {
InitializeGroupInstruction() { this.getOpcode() instanceof Opcode::InitializeGroup } UninitializedGroupInstruction() { this.getOpcode() instanceof Opcode::UninitializedGroup }
/** /**
* Gets an `IRVariable` whose memory is initialized by this instruction, if any. * Gets an `IRVariable` whose memory is initialized by this instruction, if any.
@@ -2174,7 +2174,9 @@ class InitializeGroupInstruction extends Instruction {
* dynamic allocations) are not returned by this predicate even if this * dynamic allocations) are not returned by this predicate even if this
* instruction initializes such memory. * instruction initializes such memory.
*/ */
final IRVariable getAnIRVariable() { result = Construction::getAnInitializeGroupVariable(this) } final IRVariable getAnIRVariable() {
result = Construction::getAnUninitializedGroupVariable(this)
}
final override string getImmediateString() { final override string getImmediateString() {
result = strictconcat(this.getAnIRVariable().toString(), ",") result = strictconcat(this.getAnIRVariable().toString(), ",")

View File

@@ -179,7 +179,7 @@ class VariableGroup extends AllocationSet::EquivalenceClass {
* getInitializationOrder() = 2 * getInitializationOrder() = 2
* ``` * ```
* then this set will be initialized as the second (third) set in the * then this set will be initialized as the second (third) set in the
* enclosing function. In order words, the third `InitializeGroup` * enclosing function. In order words, the third `UninitializedGroup`
* instruction in the entry block of the enclosing function will initialize * instruction in the entry block of the enclosing function will initialize
* this set of allocations. * this set of allocations.
*/ */

View File

@@ -17,32 +17,34 @@ import Cached
/** /**
* Holds if `instruction` is the first instruction that may be followed by * Holds if `instruction` is the first instruction that may be followed by
* an `InitializeGroup` instruction, and the enclosing function of * an `UninitializedGroup` instruction, and the enclosing function of
* `instruction` is `func`. * `instruction` is `func`.
*/ */
private predicate isFirstInstructionBeforeInitializeGroup(Instruction instruction, IRFunction func) { private predicate isFirstInstructionBeforeUninitializedGroup(
Instruction instruction, IRFunction func
) {
instruction = getChi(any(OldIR::InitializeNonLocalInstruction init)) and instruction = getChi(any(OldIR::InitializeNonLocalInstruction init)) and
func = instruction.getEnclosingIRFunction() func = instruction.getEnclosingIRFunction()
} }
/** Gets the `i`'th `InitializeGroup` instruction in `func`. */ /** Gets the `i`'th `UninitializedGroup` instruction in `func`. */
private InitializeGroupInstruction getInitGroupInstruction(int i, IRFunction func) { private UninitializedGroupInstruction getInitGroupInstruction(int i, IRFunction func) {
exists(Alias::VariableGroup vg | exists(Alias::VariableGroup vg |
vg.getIRFunction() = func and vg.getIRFunction() = func and
vg.getInitializationOrder() = i and vg.getInitializationOrder() = i and
result = initializeGroup(vg) result = uninitializedGroup(vg)
) )
} }
/** /**
* Holds if `instruction` is the last instruction in the chain of `InitializeGroup` * Holds if `instruction` is the last instruction in the chain of `UninitializedGroup`
* instructions in `func`. The chain of instructions may be empty in which case * instructions in `func`. The chain of instructions may be empty in which case
* `instruction` satisfies * `instruction` satisfies
* ``` * ```
* isFirstInstructionBeforeInitializeGroup(instruction, func) * isFirstInstructionBeforeUninitializedGroup(instruction, func)
* ``` * ```
*/ */
predicate isLastInstructionForInitializeGroups(Instruction instruction, IRFunction func) { predicate isLastInstructionForUninitializedGroups(Instruction instruction, IRFunction func) {
exists(int i | exists(int i |
instruction = getInitGroupInstruction(i, func) and instruction = getInitGroupInstruction(i, func) and
not exists(getChi(instruction)) and not exists(getChi(instruction)) and
@@ -54,7 +56,7 @@ predicate isLastInstructionForInitializeGroups(Instruction instruction, IRFuncti
not exists(getInitGroupInstruction(i + 1, func)) not exists(getInitGroupInstruction(i + 1, func))
) )
or or
isFirstInstructionBeforeInitializeGroup(instruction, func) and isFirstInstructionBeforeUninitializedGroup(instruction, func) and
not exists(getInitGroupInstruction(0, func)) not exists(getInitGroupInstruction(0, func))
} }
@@ -76,8 +78,8 @@ private module Cached {
} }
cached cached
predicate hasChiNodeAfterInitializeGroup(InitializeGroupInstruction initGroup) { predicate hasChiNodeAfterUninitializedGroup(UninitializedGroupInstruction initGroup) {
hasChiNodeAfterInitializeGroup(_, initGroup) hasChiNodeAfterUninitializedGroup(_, initGroup)
} }
cached cached
@@ -94,7 +96,7 @@ private module Cached {
class TStageInstruction = class TStageInstruction =
TRawInstruction or TPhiInstruction or TChiInstruction or TUnreachedInstruction or TRawInstruction or TPhiInstruction or TChiInstruction or TUnreachedInstruction or
TInitializeGroupInstruction; TUninitializedGroupInstruction;
/** /**
* If `oldInstruction` is a `Phi` instruction that has exactly one reachable predecessor block, * If `oldInstruction` is a `Phi` instruction that has exactly one reachable predecessor block,
@@ -127,7 +129,7 @@ private module Cached {
or or
instr instanceof TChiInstruction instr instanceof TChiInstruction
or or
instr instanceof TInitializeGroupInstruction instr instanceof TUninitializedGroupInstruction
or or
instr instanceof TUnreachedInstruction instr instanceof TUnreachedInstruction
} }
@@ -175,7 +177,7 @@ private module Cached {
canModelResultForOldInstruction(getOldInstruction(instruction)) or canModelResultForOldInstruction(getOldInstruction(instruction)) or
instruction instanceof PhiInstruction or // Phis always have modeled results instruction instanceof PhiInstruction or // Phis always have modeled results
instruction instanceof ChiInstruction or // Chis always have modeled results instruction instanceof ChiInstruction or // Chis always have modeled results
instruction instanceof InitializeGroupInstruction // Group initializers always have modeled results instruction instanceof UninitializedGroupInstruction // Group initializers always have modeled results
} }
cached cached
@@ -191,11 +193,11 @@ private module Cached {
Alias::getResultMemoryLocation(input).getVirtualVariable() instanceof Alias::getResultMemoryLocation(input).getVirtualVariable() instanceof
Alias::AliasedVirtualVariable Alias::AliasedVirtualVariable
or or
// A chi following an `InitializeGroupInstruction` only happens when the virtual // A chi following an `UninitializedGroupInstruction` only happens when the virtual
// variable of the grouped memory location is `{AllAliasedMemory}`. // variable of the grouped memory location is `{AllAliasedMemory}`.
exists(Alias::GroupedMemoryLocation gml | exists(Alias::GroupedMemoryLocation gml |
instruction = getChi(input) and instruction = getChi(input) and
input = initializeGroup(gml.getGroup()) and input = uninitializedGroup(gml.getGroup()) and
gml.getVirtualVariable() instanceof Alias::AliasedVirtualVariable gml.getVirtualVariable() instanceof Alias::AliasedVirtualVariable
) )
) )
@@ -269,7 +271,7 @@ private module Cached {
( (
instruction = getChi(getOldInstruction(result)) instruction = getChi(getOldInstruction(result))
or or
instruction = getChi(result.(InitializeGroupInstruction)) instruction = getChi(result.(UninitializedGroupInstruction))
) and ) and
tag instanceof ChiPartialOperandTag and tag instanceof ChiPartialOperandTag and
overlap instanceof MustExactlyOverlap overlap instanceof MustExactlyOverlap
@@ -329,9 +331,9 @@ private module Cached {
} }
cached cached
IRVariable getAnInitializeGroupVariable(InitializeGroupInstruction init) { IRVariable getAnUninitializedGroupVariable(UninitializedGroupInstruction init) {
exists(Alias::VariableGroup vg | exists(Alias::VariableGroup vg |
init = initializeGroup(vg) and init = uninitializedGroup(vg) and
result = vg.getAnAllocation().getABaseInstruction().(VariableInstruction).getIRVariable() result = vg.getAnAllocation().getABaseInstruction().(VariableInstruction).getIRVariable()
) )
} }
@@ -389,12 +391,13 @@ private module Cached {
result = getNewPhiOperandDefinitionFromOldSsa(instr, newPredecessorBlock, overlap) result = getNewPhiOperandDefinitionFromOldSsa(instr, newPredecessorBlock, overlap)
} }
private ChiInstruction getChiAfterInitializeGroup(int i, IRFunction func) { private ChiInstruction getChiAfterUninitializedGroup(int i, IRFunction func) {
result = result =
rank[i + 1](VariableGroup vg, InitializeGroupInstruction initGroup, ChiInstruction chi, int r | rank[i + 1](VariableGroup vg, UninitializedGroupInstruction initGroup, ChiInstruction chi,
int r |
initGroup.getEnclosingIRFunction() = func and initGroup.getEnclosingIRFunction() = func and
chi = getChi(initGroup) and chi = getChi(initGroup) and
initGroup = initializeGroup(vg) and initGroup = uninitializedGroup(vg) and
r = vg.getInitializationOrder() r = vg.getInitializationOrder()
| |
chi order by r chi order by r
@@ -415,16 +418,16 @@ private module Cached {
result = getDefinitionOrChiInstruction(defBlock, defOffset, vvar, _) result = getDefinitionOrChiInstruction(defBlock, defOffset, vvar, _)
) )
or or
exists(InitializeGroupInstruction initGroup, IRFunction func | exists(UninitializedGroupInstruction initGroup, IRFunction func |
chiInstr = getChi(initGroup) and chiInstr = getChi(initGroup) and
func = initGroup.getEnclosingIRFunction() func = initGroup.getEnclosingIRFunction()
| |
chiInstr = getChiAfterInitializeGroup(0, func) and chiInstr = getChiAfterUninitializedGroup(0, func) and
isFirstInstructionBeforeInitializeGroup(result, func) isFirstInstructionBeforeUninitializedGroup(result, func)
or or
exists(int i | exists(int i |
chiInstr = getChiAfterInitializeGroup(i + 1, func) and chiInstr = getChiAfterUninitializedGroup(i + 1, func) and
result = getChiAfterInitializeGroup(i, func) result = getChiAfterUninitializedGroup(i, func)
) )
) )
} }
@@ -442,28 +445,28 @@ private module Cached {
) )
} }
private InitializeGroupInstruction firstInstructionToInitializeGroup( private UninitializedGroupInstruction firstInstructionToUninitializedGroup(
Instruction instruction, EdgeKind kind Instruction instruction, EdgeKind kind
) { ) {
exists(IRFunction func | exists(IRFunction func |
isFirstInstructionBeforeInitializeGroup(instruction, func) and isFirstInstructionBeforeUninitializedGroup(instruction, func) and
result = getInitGroupInstruction(0, func) and result = getInitGroupInstruction(0, func) and
kind instanceof GotoEdge kind instanceof GotoEdge
) )
} }
private Instruction getNextInitializeGroupInstruction(Instruction instruction, EdgeKind kind) { private Instruction getNextUninitializedGroupInstruction(Instruction instruction, EdgeKind kind) {
exists(int i, IRFunction func | exists(int i, IRFunction func |
func = instruction.getEnclosingIRFunction() and func = instruction.getEnclosingIRFunction() and
instruction = getInitGroupInstruction(i, func) and instruction = getInitGroupInstruction(i, func) and
kind instanceof GotoEdge kind instanceof GotoEdge
| |
if hasChiNodeAfterInitializeGroup(_, instruction) if hasChiNodeAfterUninitializedGroup(_, instruction)
then result = getChi(instruction) then result = getChi(instruction)
else result = getInitGroupInstruction(i + 1, func) else result = getInitGroupInstruction(i + 1, func)
) )
or or
exists(int i, IRFunction func, InitializeGroupInstruction initGroup | exists(int i, IRFunction func, UninitializedGroupInstruction initGroup |
func = instruction.getEnclosingIRFunction() and func = instruction.getEnclosingIRFunction() and
instruction = getChi(initGroup) and instruction = getChi(initGroup) and
initGroup = getInitGroupInstruction(i, func) and initGroup = getInitGroupInstruction(i, func) and
@@ -473,7 +476,7 @@ private module Cached {
) )
} }
private Instruction getInstructionSuccessorAfterInitializeGroup0( private Instruction getInstructionSuccessorAfterUninitializedGroup0(
Instruction instruction, EdgeKind kind Instruction instruction, EdgeKind kind
) { ) {
if hasChiNode(_, getOldInstruction(instruction)) if hasChiNode(_, getOldInstruction(instruction))
@@ -495,13 +498,13 @@ private module Cached {
) )
} }
private Instruction getInstructionSuccessorAfterInitializeGroup( private Instruction getInstructionSuccessorAfterUninitializedGroup(
Instruction instruction, EdgeKind kind Instruction instruction, EdgeKind kind
) { ) {
exists(IRFunction func, Instruction firstBeforeInitializeGroup | exists(IRFunction func, Instruction firstBeforeUninitializedGroup |
isLastInstructionForInitializeGroups(instruction, func) and isLastInstructionForUninitializedGroups(instruction, func) and
isFirstInstructionBeforeInitializeGroup(firstBeforeInitializeGroup, func) and isFirstInstructionBeforeUninitializedGroup(firstBeforeUninitializedGroup, func) and
result = getInstructionSuccessorAfterInitializeGroup0(firstBeforeInitializeGroup, kind) result = getInstructionSuccessorAfterUninitializedGroup0(firstBeforeUninitializedGroup, kind)
) )
} }
@@ -510,18 +513,18 @@ private module Cached {
* that node is its successor in the new successor relation, and the Chi node's successors are * that node is its successor in the new successor relation, and the Chi node's successors are
* the new instructions generated from the successors of the old instruction. * the new instructions generated from the successors of the old instruction.
* *
* Furthermore, the entry block is augmented with `InitializeGroup` instructions. * Furthermore, the entry block is augmented with `UninitializedGroup` instructions.
*/ */
cached cached
Instruction getInstructionSuccessor(Instruction instruction, EdgeKind kind) { Instruction getInstructionSuccessor(Instruction instruction, EdgeKind kind) {
result = firstInstructionToInitializeGroup(instruction, kind) result = firstInstructionToUninitializedGroup(instruction, kind)
or or
result = getNextInitializeGroupInstruction(instruction, kind) result = getNextUninitializedGroupInstruction(instruction, kind)
or or
result = getInstructionSuccessorAfterInitializeGroup(instruction, kind) result = getInstructionSuccessorAfterUninitializedGroup(instruction, kind)
or or
not isFirstInstructionBeforeInitializeGroup(instruction, _) and not isFirstInstructionBeforeUninitializedGroup(instruction, _) and
result = getInstructionSuccessorAfterInitializeGroup0(instruction, kind) result = getInstructionSuccessorAfterUninitializedGroup0(instruction, kind)
} }
cached cached
@@ -561,11 +564,11 @@ private module Cached {
) )
or or
exists(Alias::VariableGroup vg | exists(Alias::VariableGroup vg |
instr = initializeGroup(vg) and instr = uninitializedGroup(vg) and
result = vg.getIRFunction().getFunction() result = vg.getIRFunction().getFunction()
) )
or or
exists(InitializeGroupInstruction initGroup | exists(UninitializedGroupInstruction initGroup |
instr = chiInstruction(initGroup) and instr = chiInstruction(initGroup) and
result = getInstructionAst(initGroup) result = getInstructionAst(initGroup)
) )
@@ -585,11 +588,11 @@ private module Cached {
| |
hasChiNode(vvar, primaryInstr) hasChiNode(vvar, primaryInstr)
or or
hasChiNodeAfterInitializeGroup(vvar, primaryInstr) hasChiNodeAfterUninitializedGroup(vvar, primaryInstr)
) )
or or
exists(Alias::VariableGroup vg | exists(Alias::VariableGroup vg |
instr = initializeGroup(vg) and instr = uninitializedGroup(vg) and
result = vg.getType() result = vg.getType()
) )
or or
@@ -618,7 +621,7 @@ private module Cached {
or or
instr = chiInstruction(_) and opcode instanceof Opcode::Chi instr = chiInstruction(_) and opcode instanceof Opcode::Chi
or or
instr = initializeGroup(_) and opcode instanceof Opcode::InitializeGroup instr = uninitializedGroup(_) and opcode instanceof Opcode::UninitializedGroup
or or
instr = unreachedInstruction(_) and opcode instanceof Opcode::Unreached instr = unreachedInstruction(_) and opcode instanceof Opcode::Unreached
} }
@@ -637,7 +640,7 @@ private module Cached {
) )
or or
exists(Alias::VariableGroup vg | exists(Alias::VariableGroup vg |
instr = initializeGroup(vg) and instr = uninitializedGroup(vg) and
result = vg.getIRFunction() result = vg.getIRFunction()
) )
or or
@@ -656,7 +659,7 @@ private module Cached {
result = getNewInstruction(oldInstruction) result = getNewInstruction(oldInstruction)
) )
or or
instruction = getChi(result.(InitializeGroupInstruction)) instruction = getChi(result.(UninitializedGroupInstruction))
} }
} }
@@ -685,11 +688,11 @@ private predicate hasChiNode(Alias::VirtualVariable vvar, OldInstruction def) {
) )
} }
private predicate hasChiNodeAfterInitializeGroup( private predicate hasChiNodeAfterUninitializedGroup(
Alias::AliasedVirtualVariable vvar, InitializeGroupInstruction initGroup Alias::AliasedVirtualVariable vvar, UninitializedGroupInstruction initGroup
) { ) {
exists(Alias::GroupedMemoryLocation defLocation | exists(Alias::GroupedMemoryLocation defLocation |
initGroup = initializeGroup(defLocation.getGroup()) and initGroup = uninitializedGroup(defLocation.getGroup()) and
defLocation.getVirtualVariable() = vvar and defLocation.getVirtualVariable() = vvar and
Alias::getOverlap(defLocation, vvar) instanceof MayPartiallyOverlap Alias::getOverlap(defLocation, vvar) instanceof MayPartiallyOverlap
) )
@@ -907,7 +910,7 @@ module DefUse {
actualDefLocation = defLocation actualDefLocation = defLocation
or or
exists( exists(
Alias::VariableGroup vg, int index, InitializeGroupInstruction initGroup, Alias::VariableGroup vg, int index, UninitializedGroupInstruction initGroup,
Alias::GroupedMemoryLocation gml Alias::GroupedMemoryLocation gml
| |
// Add 3 to account for the function prologue: // Add 3 to account for the function prologue:
@@ -919,7 +922,7 @@ module DefUse {
gml.isSome() and gml.isSome() and
gml.getGroup() = vg and gml.getGroup() = vg and
vg.getIRFunction().getEntryBlock() = defBlock and vg.getIRFunction().getEntryBlock() = defBlock and
initGroup = initializeGroup(vg) and initGroup = uninitializedGroup(vg) and
(defLocation = gml or defLocation = gml.getVirtualVariable()) (defLocation = gml or defLocation = gml.getVirtualVariable())
| |
result = initGroup and result = initGroup and
@@ -934,8 +937,8 @@ module DefUse {
private ChiInstruction remapGetDefinitionOrChiInstruction(Instruction oldResult) { private ChiInstruction remapGetDefinitionOrChiInstruction(Instruction oldResult) {
exists(IRFunction func | exists(IRFunction func |
isFirstInstructionBeforeInitializeGroup(oldResult, func) and isFirstInstructionBeforeUninitializedGroup(oldResult, func) and
isLastInstructionForInitializeGroups(result, func) isLastInstructionForUninitializedGroups(result, func)
) )
} }
@@ -1097,14 +1100,14 @@ module DefUse {
else offset = getNonChiOffset(index, block) // The use will be connected to the definition on the original instruction. else offset = getNonChiOffset(index, block) // The use will be connected to the definition on the original instruction.
) )
or or
exists(InitializeGroupInstruction initGroup, int index, Overlap overlap, VariableGroup vg | exists(UninitializedGroupInstruction initGroup, int index, Overlap overlap, VariableGroup vg |
initGroup.getEnclosingIRFunction().getEntryBlock() = getNewBlock(block) and initGroup.getEnclosingIRFunction().getEntryBlock() = getNewBlock(block) and
vg = defLocation.(Alias::GroupedMemoryLocation).getGroup() and vg = defLocation.(Alias::GroupedMemoryLocation).getGroup() and
// EnterFunction + AliasedDefinition + InitializeNonLocal + index // EnterFunction + AliasedDefinition + InitializeNonLocal + index
index = 3 + vg.getInitializationOrder() and index = 3 + vg.getInitializationOrder() and
initGroup = initializeGroup(vg) and initGroup = uninitializedGroup(vg) and
overlap = Alias::getOverlap(defLocation, useLocation) and overlap = Alias::getOverlap(defLocation, useLocation) and
if overlap instanceof MayPartiallyOverlap and hasChiNodeAfterInitializeGroup(initGroup) if overlap instanceof MayPartiallyOverlap and hasChiNodeAfterUninitializedGroup(initGroup)
then offset = 2 * index + 1 // The use will be connected to the definition on the `Chi` instruction. then offset = 2 * index + 1 // The use will be connected to the definition on the `Chi` instruction.
else offset = 2 * index // The use will be connected to the definition on the original instruction. else offset = 2 * index // The use will be connected to the definition on the original instruction.
) )
@@ -1321,7 +1324,7 @@ module Ssa {
predicate hasChiInstruction = Cached::hasChiInstructionCached/1; predicate hasChiInstruction = Cached::hasChiInstructionCached/1;
predicate hasChiNodeAfterInitializeGroup = Cached::hasChiNodeAfterInitializeGroup/1; predicate hasChiNodeAfterUninitializedGroup = Cached::hasChiNodeAfterUninitializedGroup/1;
predicate hasUnreachedInstruction = Cached::hasUnreachedInstructionCached/1; predicate hasUnreachedInstruction = Cached::hasUnreachedInstructionCached/1;

View File

@@ -31,7 +31,7 @@ newtype TInstruction =
TUnaliasedSsaUnreachedInstruction(IRFunctionBase irFunc) { TUnaliasedSsaUnreachedInstruction(IRFunctionBase irFunc) {
UnaliasedSsa::Ssa::hasUnreachedInstruction(irFunc) UnaliasedSsa::Ssa::hasUnreachedInstruction(irFunc)
} or } or
TUnaliasedSsaInitializeGroupInstruction(UnaliasedSsa::Ssa::VariableGroup vg) or TUnaliasedSsaUninitializedGroupInstruction(UnaliasedSsa::Ssa::VariableGroup vg) or
TAliasedSsaPhiInstruction( TAliasedSsaPhiInstruction(
TRawInstruction blockStartInstr, AliasedSsa::Ssa::MemoryLocation memoryLocation TRawInstruction blockStartInstr, AliasedSsa::Ssa::MemoryLocation memoryLocation
) { ) {
@@ -43,9 +43,11 @@ newtype TInstruction =
TAliasedSsaUnreachedInstruction(IRFunctionBase irFunc) { TAliasedSsaUnreachedInstruction(IRFunctionBase irFunc) {
AliasedSsa::Ssa::hasUnreachedInstruction(irFunc) AliasedSsa::Ssa::hasUnreachedInstruction(irFunc)
} or } or
TAliasedSsaInitializeGroupInstruction(AliasedSsa::Ssa::VariableGroup vg) or TAliasedSsaUninitializedGroupInstruction(AliasedSsa::Ssa::VariableGroup vg) or
TAliasedSsaChiAfterInitializeGroupInstruction(TAliasedSsaInitializeGroupInstruction initGroup) { TAliasedSsaChiAfterUninitializedGroupInstruction(
AliasedSsa::Ssa::hasChiNodeAfterInitializeGroup(initGroup) TAliasedSsaUninitializedGroupInstruction initGroup
) {
AliasedSsa::Ssa::hasChiNodeAfterUninitializedGroup(initGroup)
} }
/** /**
@@ -67,11 +69,11 @@ module UnaliasedSsaInstructions {
class TChiInstruction = TUnaliasedSsaChiInstruction; class TChiInstruction = TUnaliasedSsaChiInstruction;
class TInitializeGroupInstruction = TUnaliasedSsaInitializeGroupInstruction; class TUninitializedGroupInstruction = TUnaliasedSsaUninitializedGroupInstruction;
class TRawOrInitializeGroupInstruction = TRawInstruction or TInitializeGroupInstruction; class TRawOrUninitializedGroupInstruction = TRawInstruction or TUninitializedGroupInstruction;
TChiInstruction chiInstruction(TRawOrInitializeGroupInstruction primaryInstruction) { TChiInstruction chiInstruction(TRawOrUninitializedGroupInstruction primaryInstruction) {
result = TUnaliasedSsaChiInstruction(primaryInstruction) result = TUnaliasedSsaChiInstruction(primaryInstruction)
} }
@@ -83,9 +85,9 @@ module UnaliasedSsaInstructions {
class VariableGroup = UnaliasedSsa::Ssa::VariableGroup; class VariableGroup = UnaliasedSsa::Ssa::VariableGroup;
// This really should just be `TUnaliasedSsaInitializeGroupInstruction`, but that makes the // This really should just be `TUnaliasedSsaUninitializedGroupInstruction`, but that makes the
// compiler realize that certain expressions in `SSAConstruction` are unsatisfiable. // compiler realize that certain expressions in `SSAConstruction` are unsatisfiable.
TRawOrInitializeGroupInstruction initializeGroup(VariableGroup vg) { none() } TRawOrUninitializedGroupInstruction uninitializedGroup(VariableGroup vg) { none() }
} }
/** /**
@@ -108,14 +110,15 @@ module AliasedSsaInstructions {
} }
class TChiInstruction = class TChiInstruction =
TAliasedSsaChiInstruction or TAliasedSsaChiAfterInitializeGroupInstruction; TAliasedSsaChiInstruction or TAliasedSsaChiAfterUninitializedGroupInstruction;
class TRawOrInitialzieGroupInstruction = TRawInstruction or TAliasedSsaInitializeGroupInstruction; class TRawOrInitialzieGroupInstruction =
TRawInstruction or TAliasedSsaUninitializedGroupInstruction;
TChiInstruction chiInstruction(TRawOrInitialzieGroupInstruction primaryInstruction) { TChiInstruction chiInstruction(TRawOrInitialzieGroupInstruction primaryInstruction) {
result = TAliasedSsaChiInstruction(primaryInstruction) result = TAliasedSsaChiInstruction(primaryInstruction)
or or
result = TAliasedSsaChiAfterInitializeGroupInstruction(primaryInstruction) result = TAliasedSsaChiAfterUninitializedGroupInstruction(primaryInstruction)
} }
class TUnreachedInstruction = TAliasedSsaUnreachedInstruction; class TUnreachedInstruction = TAliasedSsaUnreachedInstruction;
@@ -126,9 +129,9 @@ module AliasedSsaInstructions {
class VariableGroup = AliasedSsa::Ssa::VariableGroup; class VariableGroup = AliasedSsa::Ssa::VariableGroup;
class TInitializeGroupInstruction = TAliasedSsaInitializeGroupInstruction; class TUninitializedGroupInstruction = TAliasedSsaUninitializedGroupInstruction;
TInitializeGroupInstruction initializeGroup(VariableGroup vg) { TUninitializedGroupInstruction uninitializedGroup(VariableGroup vg) {
result = TAliasedSsaInitializeGroupInstruction(vg) result = TAliasedSsaUninitializedGroupInstruction(vg)
} }
} }

View File

@@ -13,7 +13,7 @@ private import semmle.code.cpp.ir.internal.Overlap
*/ */
private module Internal { private module Internal {
private class TAliasedChiInstruction = private class TAliasedChiInstruction =
TAliasedSsaChiInstruction or TAliasedSsaChiAfterInitializeGroupInstruction; TAliasedSsaChiInstruction or TAliasedSsaChiAfterUninitializedGroupInstruction;
/** /**
* An IR operand. `TOperand` is shared across all phases of the IR. There are branches of this * An IR operand. `TOperand` is shared across all phases of the IR. There are branches of this
@@ -202,7 +202,7 @@ module AliasedSsaOperands {
} }
private class TChiInstruction = private class TChiInstruction =
TAliasedSsaChiInstruction or TAliasedSsaChiAfterInitializeGroupInstruction; TAliasedSsaChiInstruction or TAliasedSsaChiAfterUninitializedGroupInstruction;
/** /**
* Returns the Chi operand with the specified parameters. * Returns the Chi operand with the specified parameters.

View File

@@ -407,7 +407,7 @@ predicate hasUnreachedInstruction(IRFunction func) {
) )
} }
IRVariable getAnInitializeGroupVariable(InitializeGroupInstruction instr) { none() } IRVariable getAnUninitializedGroupVariable(UninitializedGroupInstruction instr) { none() }
import CachedForDebugging import CachedForDebugging