I was wondering what MachineInstr::findRegisterUseOperandIdx “means”. I have a situation where an instruction writes R0 and another reads R0lo - the lower half of R0. Using Use::findRegisterUseOperandIdx(R0) returns -1, because it only checks against exact matches and “is-Reg-a-subreg-of-MOReg” matches, of which neither are true.
However, the instruction reads part of R0, so should it return true? It’s really a question of semantics, as either:
- findRegisterUseOperandIdx returns the index if the instruction reads the whole of Reg, or
- findRegisterUseOperandIdx returns the index if the instruction reads any part of Reg
If it’s 2) then it appears as if there’s a bug in there. If it’s 1) by design, then it doesn’t seem to me as though there’s a convenient way of doing 2).
There is another option, namely:
- findRegisterUseOperandIdx can do 1) or 2), depending on a flag
There’s an “Overlap” parameter to MachineInstr::findRegisterDefOperandIdx - would that do the trick, and do we want to add it to findRegisterUseOperandIdx?
What do people think?