<IsKill> getting from MachineOperand is just <Used> attribute from logic.

Hi,

I have ported LLC to a risc cpu. It can pass benchmark that I have at current.

But I want do some optimization after register alloction by adjusting
register using. I scan MachineBasicBlock to analyze operand's IsKill, IsDead , IsDef attribute to get a physical register's liverange. But I get a strange case at MBB.jpg.

  R4 is marked <kill> at MBB0. If I scan R4's liverange by [MBB0->MBB1->MBB2]. I will find R4 first is killed, then is used. It can not unlogisch. Attually R4 just is <Used>. It will cause my optimization pass crash(Actually, I ingore Live In message of MBB. I recollect live in messges at my pass.).

  1. Does <kill> attribute of R4 at MBB0 is a unimportant and redundancy messages, Or a little bug???
  2. Is it unreliable to get a physical register's liverange by Kill, Dead messages from MachineBasicBlock??

But I want do some optimization after register alloction by adjusting
register using. I scan MachineBasicBlock to analyze operand's IsKill, IsDead , IsDef attribute to get a physical register's liverange. But I get a strange case at MBB.jpg.

You can also look at RegisterScavenging.cpp and MachineVerifier.cpp. They are doing the same thing.

R4 is marked <kill> at MBB0. If I scan R4's liverange by [MBB0->MBB1->MBB2]. I will find R4 first is killed, then is used. It can not unlogisch. Attually R4 just is <Used>. It will cause my optimization pass crash(Actually, I ingore Live In message of MBB. I recollect live in messges at my pass.).

A register should not be used after it is killed, and if it is needed by a successor block, it should be live out.

Note that a register in the live-in list of an MBB is not always live-out from all predecessors. A register defined by IMPLICIT_DEF can be optimized away entirely.

1. Does <kill> attribute of R4 at MBB0 is a unimportant and redundancy messages, Or a little bug???

You have probably found a bug. Can you reproduce it with one of the normal back ends?

2. Is it unreliable to get a physical register's liverange by Kill, Dead messages from MachineBasicBlock??

You also need to use the live-in list for each MBB, but otherwise it should be reliable. Look at how RegisterScavenger is doing it.

/jakob

Hi, Jakob:

  Thanks for your answer.
  I hope to trace all physical register liverange in MachineBasicBlock.
In my test, I find LiveIn message of MBB can not give all livein
physical register. So I write a pass to recollect livein message
by scan MBB.
  
  Current case tell me that just to scan MachineOperand's isDef, isKill, IsDead attribute to rebuild physical register's livein will have bug.

  If I use add missing live-in into <live-in list for each MBB>,
Could I can know which physical register is live at any time?

  If yes, it is easy for my pass.

  If not, I need to treat isKill and isDead as isUse, then implement a pass to anaylze CFG to delete unvalid livein message.

--- 10年1月15日,周五, Jakob Stoklund Olesen <stoklund@2pi.dk> 写道: