[llvm-dev] Undef physical registers?

Jesper Antonsson via llvm-dev llvm-dev at lists.llvm.org
Tue Feb 13 01:11:15 PST 2018


Hi,

I'm a bit unsure of the semantics of undef physical registers. The explanations I've seen in the code and in the langref seems to
pertain more to constant values and virtual registers.

What I really want to achieve is a push-pop of a register to have a temporary to work with, without having to check if this
register is defined or not. However, whenever the reg is not defined before the push, the MachineVerifier complains about that.

If I add RegState::Undef to the push, the verifier complaint goes away, but I worry that this might be unsafe. I would like
"Undef" for physical registers to mean "we don't care if this register has been defined or not", but perhaps it means "this
register can now have any bits set", so it'd be allowed to optimize the push away?

So, is the latter interpretation true, and if so, is there some other idiom that would allow me to push-pop a possibly undefined
physical register?

Thanks, Jesper


More information about the llvm-dev mailing list