llvm::DemoteRegToStack

Demote an instruction's virtual register to a stack slot.

Synopsis

Declared in <llvm/Transforms/Utils/Local.h>

AllocaInst*
DemoteRegToStack(
    Instruction& X,
    bool VolatileLoads = false,
    std::optional<BasicBlock::iterator> AllocaPoint = std::nullopt);

Description

This function takes a virtual register computed by an Instruction and replaces it with a slot in the stack frame, allocated via alloca. This allows the CFG to be changed around without fear of invalidating the SSA information for the value. It returns the pointer to the alloca inserted to create a stack slot for X.

Return Value

Pointer to the alloca inserted for the stack slot.

Parameters

NameDescription
XInstruction whose value is demoted to the stack.
VolatileLoadsWhether loads of the stack slot should be volatile.
AllocaPointOptional insertion point for the alloca.