This is an archive of the discontinued LLVM Phabricator instance.

TII: Generalize X86's isSafeToClobberEFLAGs
AbandonedPublic

Authored by arsenm on Jul 16 2018, 1:50 PM.

Details

Reviewers
MatzeB

Diff Detail

Event Timeline

arsenm created this revision.Jul 16 2018, 1:50 PM
arsenm updated this revision to Diff 155767.Jul 16 2018, 2:43 PM

Fix handling of sub registers and live ins

Is this different from MachineBasicBlock::computeRegisterLiveness(TRI, Reg, I, 4) == LQR_Dead?
The implementations looks the same to me except that this one here has one more case where it checks the successor blocks live in lists...

Also I'd generally recommend to rather look at LivePhysReg/LiveRegUnits for doing liveness queries post-ra. They can be more expensive but give more consistent results...

Also I'd generally recommend to rather look at LivePhysReg/LiveRegUnits for doing liveness queries post-ra. They can be more expensive but give more consistent results...

I want to use this in an SSA pass, not post-RA

Also I'd generally recommend to rather look at LivePhysReg/LiveRegUnits for doing liveness queries post-ra. They can be more expensive but give more consistent results...

I want to use this in an SSA pass, not post-RA

Fair enough. But MachineBasicBlock::computeRegisterLiveness(TRI, Reg, I, 4) == LQR_Dead? should work in machine SSA, shouldn't it?

Also I'd generally recommend to rather look at LivePhysReg/LiveRegUnits for doing liveness queries post-ra. They can be more expensive but give more consistent results...

I want to use this in an SSA pass, not post-RA

Fair enough. But MachineBasicBlock::computeRegisterLiveness(TRI, Reg, I, 4) == LQR_Dead? should work in machine SSA, shouldn't it?

I tried swapping these and found a few bugs in each.

isSafeToClobber doesn't count debug instruction towards the search count, while computeRegisterLiveness does which is just a bug. I also found another subregister bug in isSafeToClobber. computeRegisterLiveness seems overall nicer, but might need some changes.

The most important difference seems to be the handling of unused defs that might be live out. If a physical register is defined and not used, computeRegisterLiveness says it's alive and doesn't consider that it's not live in to any successors. I suppose this could be solved by searching uses before defs, and adding another liveness type LQR_LiveUnused or something? I suppose other users might care that the register has any value.

With D51348 and D51350 I suspect X86 can switch to just using computeRegisterLiveness but I haven't tried it yet

arsenm abandoned this revision.Feb 13 2019, 10:22 AM

Don't need this anymore, but x86 should probably remove this function