An instruction representing the effect that a write to a memory may have on potential aliases of that memory.
ChiInstruction is inserted immediately after an instruction that writes to memory. The
ChiInstruction has two operands. The first operand, given by
the previous state of all of the memory that might be alised by the memory write. The second
operand, given by
getPartialOperand(), represents the memory that was actually modified by the
memory write. The result of the
ChiInstruction represents the same memory as
getTotalOperand(), updated to include the changes due to the value that was actually stored by
the memory write.
As an example, suppose that variable
q are pointers that may or may not point to the
*p = 5; x = *q;
The IR would look like:
r1_1 = VariableAddress[p] r1_2 = Load r1_1, m0_0 // Load the value of `p` r1_3 = Constant m1_4 = Store r1_2, r1_3 // Store to `*p` m1_5 = ^Chi m0_1, m1_4 // Side effect of the previous Store on aliased memory r1_6 = VariableAddress[x] r1_7 = VariableAddress[q] r1_8 = Load r1_7, m0_2 // Load the value of `q` r1_9 = Load r1_8, m1_5 // Load the value of `*q` m1_10 = Store r1_6, r1_9 // Store to x
Chi instruction after the store to
*p. The indicates that the previous contents of
aliased memory (
m0_1) are merged with the new value written by the store (
m1_4), producing a
new version of aliased memory (
m1_5). On the subsequent load from
*q, the source operand of
m1_5, indicating that the store to
*p may (or may not) have updated the memory
pointed to by
For more information about how
Chi instructions are used to model memory side effects, see
Gets the operand that represents the new value written by the memory write.
Gets the kind of memory access performed by this instruction’s result. Holds only for instructions with a memory result.
Gets the operand that represents the previous state of all memory that might be aliased by the memory write.
Gets all direct predecessors of this instruction.
Gets the AST that caused this instruction to be generated.
Gets all direct successors of this instruction.
Gets all direct uses of the result of this instruction.
Gets all of this instruction’s operands.
Gets the basic block that contains this instruction.
Gets the zero-based index of this instruction within its block. This is used by debugging and printing code only.
Gets a string showing the result, opcode, and operands of the instruction, equivalent to what would be printed by PrintIR.ql. For example:
Gets the function that contains this instruction.
Gets the FunctionIR object that contains the IR for this instruction.
Gets a string describing the immediate value of this instruction, if any.
Gets the location of the source code for this instruction.
Gets the opcode that specifies the operation performed by this instruction.
Gets a string describing the operands of this instruction, suitable for display in IR dumps.
Gets a string describing the operation of this instruction. This includes the opcode and the immediate value, if any. For example:
Gets a predecessor of this instruction such that the predecessor reaches this instruction along the control flow edge specified by
Gets a human-readable string that uniquely identifies this instruction within the function. This string is used to refer to this instruction when printing IR dumps.
Gets the size of the result produced by this instruction, in bytes. If the result does not have a known constant size, this predicate does not hold.
Gets a string describing the result of this instruction, suitable for display in IR dumps. This consists of the result ID plus the type of the result.
Gets the type of the result produced by this instruction. If the instruction does not produce a result, its result type will be
Gets the successor of this instruction along the control flow edge specified by
Gets the unconverted
Gets a string identifier for this function that is unique among all instructions in the same function.
Holds if this instruction produces a memory result.
Holds if the result produced by this instruction is a glvalue. If this holds, the result of the instruction represents the address of a location, and the type of the location is given by
Holds if the result of this instruction is precisely modeled in SSA. Always holds for a register result. For a memory result, a modeled result is connected to its actual uses. An unmodeled result is connected to the