[LLVMdev] Recalculating live intervals

Fernando Magno Quintao Pereira fernando at CS.UCLA.EDU
Mon Aug 21 14:25:18 PDT 2006


> I'm not sure about one thing: you assign stack slot to each new register you
> replace the spilled one with. And then you need to allocate physical
> registers to them. Is it possible to assign physical register to the virtual
> one which has a stack slot already?
>

Yes. The stack slot is the place where the value will be stored in memory,
but, when that value is effectively used in the code, you must load it
into a physical register. Assume that reg_v is mapped to stack slot x, and
there is an instruction such as add reg_1 := reg_v reg_2, where reg_1 is
mapped to phys_1, reg_v is mapped to phys_v, and reg_2 is mapped to
phys_2. Your final code will be like:

load phys_v, x
add phys_1 := phys_v, phys_2

In order to insert load/store instructions, you can use the VirtRegMap
class. The spiller, that is implemented in VirtRegMap.cpp will do that.
For an example, see RegAllocLinearscan.cpp. Another way is to insert
the load/store instructions yourself. This is done in RegAllocLocal.cpp,
for example.

Best,

Fernando



More information about the llvm-dev mailing list