C++: Improve 'toString' on the 'InitializeGroup' instruction.

This commit is contained in:
Mathias Vorreiter Pedersen
2024-07-02 14:32:08 +01:00
parent b185c67d4f
commit c54dc49891
4 changed files with 25 additions and 0 deletions

View File

@@ -2167,6 +2167,18 @@ class ChiInstruction extends Instruction {
*/
class InitializeGroupInstruction extends Instruction {
InitializeGroupInstruction() { this.getOpcode() instanceof Opcode::InitializeGroup }
/**
* Gets an `IRVariable` whose memory is initialized by this instruction, if any.
* Note: Allocations that are not represented as `IRVariable`s (such as
* dynamic allocations) are not returned by this predicate even if this
* instruction initializes such memory.
*/
final IRVariable getAnIRVariable() { result = Construction::getAnInitializeGroupVariable(this) }
final override string getImmediateString() {
result = strictconcat(this.getAnIRVariable().toString(), ",")
}
}
/**

View File

@@ -263,6 +263,14 @@ private module Cached {
)
}
cached
IRVariable getAnInitializeGroupVariable(InitializeGroupInstruction init) {
exists(Alias::VariableGroup vg |
init = initializeGroup(vg) and
result = vg.getAnAllocation().getABaseInstruction().(VariableInstruction).getIRVariable()
)
}
/**
* Holds if `instr` is part of a cycle in the operand graph that doesn't go
* through a phi instruction and therefore should be impossible.

View File

@@ -407,6 +407,8 @@ predicate hasUnreachedInstruction(IRFunction func) {
)
}
IRVariable getAnInitializeGroupVariable(InitializeGroupInstruction instr) { none() }
import CachedForDebugging
cached

View File

@@ -263,6 +263,9 @@ private module Cached {
)
}
cached
IRVariable getAnInitializeGroupVariable(InitializeGroupInstruction instr) { none() }
/**
* Holds if `instr` is part of a cycle in the operand graph that doesn't go
* through a phi instruction and therefore should be impossible.