Liveness of virtual registers

Dear there,

I am trying to use liveness of a variable while writing a machinefunction pass. But it seems that some virtual registers are not marked as dead while they should be (never used by anything else). I get those info by callings isDead or isDef function for that MachineOperand (vreg). Is there a way to get more accurate liveness info?

Thanks,
Xiaochu

The absence of these flags does not mean anything, but if they are present, then they must be correct.

You can always use functions use_empty and use_nodbg_empty, both in MachineRegisterInfo. A precise liveness information is calculated by Live Interval Analysis.

-Krzysztof

The isKill must be correct if present, but a vreg may still be killed even if the operand has no Kill flag.

The isDead and isUndef flags however are required to be correct. We need further details to say anything about your problem, a LiveIntervals::dump() dump for example would be helpful to assess whether the liveness data is correct in your case.

- Matthias

Undef yes, but what relies on isDead being accurate (before live interval computation)?

-Krzysztof

I only remember Andy/Quentin making those conservative correctness claims about the kill flags but not the dead/undef flags. I am also pretty sure the RegisterPressure.cpp / -verify-misched fail on missing dead flags (although -verify-misched fails in several instances anyway at the moment...)

On the other hand I just checked the MachineVerifier which indeed only checks for sonervatively correct dead flags as you say and I can't think of other places being problematic with missing dead flags.
I wonder if that is by accident or by design.

- Matthias

I re-checked the RegisterPressure.cpp code as well and it does not rely on dead-flags either (if there is no dead flag it queries the liveinterval for it). So it seems you are right with the statement of dead flags being optional.

- Matthias

Cool. Thanks for double-checking.

-Krzysztof

My recollection is unlike kill flags, the dead flags are required for something that is dead.
Given it is not enforced in the verifier, this is possible we drifted from that goal or simply I misremember :).