Dear LLVMers, I wish someone could help me to clarify a register allocation question. I will use X86 in this example, but it really does not matter too much. Imagine that I have a virtual v stored in register AL, and I am about to cross a function call, that effectively overwrites AL. Well, I have, say, register ESI free, but as it happens, ESI is bigger than AL. It should be technically possible to move the contents of AL into ESI, to avoid spilling 'v', but I don't know if that is possible in LLVM. Basically, ESI is not in the class of 'v', and it has no 8 bit alias. Is this a problem (the move can't be done), or am I missing something? all the best, Fernando
On Tue, 12 Jun 2007, Fernando Magno Quintao Pereira wrote:> Imagine that I have a virtual v stored in register AL, and I am about > to cross a function call, that effectively overwrites AL. Well, I have, > say, register ESI free, but as it happens, ESI is bigger than AL. It > should be technically possible to move the contents of AL into ESI, to > avoid spilling 'v', but I don't know if that is possible in LLVM. > Basically, ESI is not in the class of 'v', and it has no 8 bit alias. Is > this a problem (the move can't be done), or am I missing something?Very interesting idea. Yes, this is doable. On X86 you would copy EAX to ESI, which implicitly saves AL because it's a superclass of AL. MRegisterInfo has information about super and subclass registers, Evan can tell you more. -Chris -- http://nondot.org/sabre/ http://llvm.org/
The short answer is this is not currently done. LLVM register allocator does not currently use a move to a different register class in lieu of spills. This is definitely something we should do in the future. Can you file a bugzilla enhancement request? Thanks, Evan On Jun 13, 2007, at 11:09 AM, Chris Lattner wrote:> On Tue, 12 Jun 2007, Fernando Magno Quintao Pereira wrote: >> Imagine that I have a virtual v stored in register AL, and I >> am about >> to cross a function call, that effectively overwrites AL. Well, I >> have, >> say, register ESI free, but as it happens, ESI is bigger than AL. It >> should be technically possible to move the contents of AL into >> ESI, to >> avoid spilling 'v', but I don't know if that is possible in LLVM. >> Basically, ESI is not in the class of 'v', and it has no 8 bit >> alias. Is >> this a problem (the move can't be done), or am I missing something? > > Very interesting idea. Yes, this is doable. On X86 you would copy > EAX > to ESI, which implicitly saves AL because it's a superclass of AL. > MRegisterInfo has information about super and subclass registers, > Evan can > tell you more. > > -Chris > > -- > http://nondot.org/sabre/ > http://llvm.org/ > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev