[LLVMdev] MachineSink and EFLAGS

Jakob Stoklund Olesen stoklund at 2pi.dk
Thu Jun 2 16:53:13 PDT 2011


On Jun 2, 2011, at 12:58 PM, Bill Wendling wrote:

> On Jun 2, 2011, at 3:53 AM, Galanov, Sergey wrote:
> 
>> Hi Bill.
>> 
>> Thank you very much! Now I see my understanding was incorrect :) A dependence from a single physreg-defining instruction (like CMP or TEST) is allowed to be shared in several instructions unless that register is not clobbered (and this is what we have with CMOV_FR64). Wouldn't it be safe then to not set the live-in flag in EmitLoweredSelect for instructions which are marked as defining EFLAGS (like the integer pseudo cmovs)?
>> 
> Hi Sergey,
> 
> I'm not certain what that would buy us. If I understand your suggestion correctly, not setting the EFLAGS as live-in to a basic block would mean that we'd have to execute the instruction to reset the EFLAGS register, right? That would mean more code, longer live ranges, etc.

To clarify, a physical register may be defined in one basic block and used in another. In that case, it must be marked as live-in in all basic blocks entered on any path between the def and the use.

This is effectively manual register allocation, and it should be avoided. It is necessary sometimes, though. Like in select lowering.

The machine code verifier has good checks for this. If it complains about missing live-in registers, miscompilations are possible.

/jakob




More information about the llvm-dev mailing list