Skip to content

Commit 8db7ece

Browse files
committed
C++: Fill in trivial parts of SSA.
1 parent 2c4bf13 commit 8db7ece

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

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

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ private module Cached {
4545
}
4646

4747
class TStageInstruction =
48-
TRawInstruction or TPhiInstruction or TChiInstruction or TUnreachedInstruction;
48+
TRawInstruction or TPhiInstruction or TChiInstruction or TUnreachedInstruction or
49+
TInitializeGroupInstruction;
4950

5051
/**
5152
* If `oldInstruction` is a `Phi` instruction that has exactly one reachable predecessor block,
@@ -78,6 +79,8 @@ private module Cached {
7879
or
7980
instr instanceof TChiInstruction
8081
or
82+
instr instanceof TInitializeGroupInstruction
83+
or
8184
instr instanceof TUnreachedInstruction
8285
}
8386

@@ -123,7 +126,8 @@ private module Cached {
123126
predicate hasModeledMemoryResult(Instruction instruction) {
124127
canModelResultForOldInstruction(getOldInstruction(instruction)) or
125128
instruction instanceof PhiInstruction or // Phis always have modeled results
126-
instruction instanceof ChiInstruction // Chis always have modeled results
129+
instruction instanceof ChiInstruction or // Chis always have modeled results
130+
instruction instanceof InitializeGroupInstruction // Group initializers always have modeled results
127131
}
128132

129133
cached
@@ -414,6 +418,11 @@ private module Cached {
414418
exists(IRFunctionBase irFunc |
415419
instr = unreachedInstruction(irFunc) and result = irFunc.getFunction()
416420
)
421+
or
422+
exists(Alias::VariableGroup vg |
423+
instr = initializeGroup(vg) and
424+
result = vg.getIRFunction().getFunction()
425+
)
417426
}
418427

419428
cached
@@ -431,6 +440,11 @@ private module Cached {
431440
result = vvar.getType()
432441
)
433442
or
443+
exists(Alias::VariableGroup vg |
444+
instr = initializeGroup(vg) and
445+
result = vg.getType()
446+
)
447+
or
434448
instr = reusedPhiInstruction(_) and
435449
result = instr.(OldInstruction).getResultLanguageType()
436450
or
@@ -456,6 +470,8 @@ private module Cached {
456470
or
457471
instr = chiInstruction(_) and opcode instanceof Opcode::Chi
458472
or
473+
instr = initializeGroup(_) and opcode instanceof Opcode::InitializeGroup
474+
or
459475
instr = unreachedInstruction(_) and opcode instanceof Opcode::Unreached
460476
}
461477

@@ -472,6 +488,11 @@ private module Cached {
472488
instr = chiInstruction(primaryInstr) and result = primaryInstr.getEnclosingIRFunction()
473489
)
474490
or
491+
exists(Alias::VariableGroup vg |
492+
instr = initializeGroup(vg) and
493+
result = vg.getIRFunction()
494+
)
495+
or
475496
instr = unreachedInstruction(result)
476497
}
477498

@@ -1066,4 +1087,6 @@ module Ssa {
10661087
predicate hasChiInstruction = Cached::hasChiInstructionCached/1;
10671088

10681089
predicate hasUnreachedInstruction = Cached::hasUnreachedInstructionCached/1;
1090+
1091+
class VariableGroup = Alias::VariableGroup;
10691092
}

0 commit comments

Comments
 (0)