[LLVMdev] Register Coalescer does not preserve TargetFlag

Jakob Stoklund Olesen
Mon, 06 Aug 2012 18:06:43 -0000

On Aug 6, 2012, at 11:00 AM, Vincent Lejeune <vljn at ovi.com> wrote:

> Ok.
>
> I tried to do it using a pass after register allocation, lowering NEG/ABS
instructions.
> However I met a problem : apparently getNextOperandForReg() can returns a
MachineOperand before the one I'm processing.
>
> The following code snippet :
>
>
> void R600ModifiersPropagation::substituteReg(MachineOperand &def_MO,
unsigned new_reg, unsigned char flag) {
>   MachineOperand * MO = def_MO.getNextOperandForReg();
>   while (MO && MO->isUse()) {
>     MachineOperand *next_MO = MO->getNextOperandForReg();
>     MO->dump();
>
>     MO = next_MO;
>   }
> }
>
> displays instructions that are before the one I'm passing as def_MO.
I'm not sure if I should call some Analysis pass to enforce MachineOperand
order or not.

We make no guarantees about the order of operands in the use-def chains, and
there are no analyses that can reorder them.

I would suggest that you read the code in other targets to see how things are
usually done.

/jakob