Is there a public function equivalent of calling getIndex I would
like to use some sort of starting slot info of a live interval in some
pass. I need a way of comparing which virtual register is associated
with an earlier source line without relying on any debug info. The
relative order is preserved in my case.


Hi Shrey,

Could you clarify what you’re trying to do?

If there is a single defining instruction for a LiveRange you can get its SlotIndex from the VNInfo structure attached to the live range.
If you want to search through definitions of a virtual register you can do that with the def_iterators in MachineRegisterInfo.

Some things to keep in mind: SlotIndexes do not track source lines, they only provide a full ordering of MachineInstrs for the purpose of register allocation and related passes. There is no public access to the number underlying a SlotIndex. This is by design, as they are intended to provide ordering only.