Finding versioned and unversioned loops

I’m writing a loop nest pass and want to find any loops in the nest which have been split by a runtime aliasing check. I’ve found the loop versioning class (LLVM: llvm::LoopVersioning Class Reference) which can return the two loops for either side of the inserted conditional, but I’m unsure how to get a hold of a class for this for my own purposes.

The only place that uses the loop versioning class directly is the loop distribution pass, which creates a new instance of LoopVersioning and versions the loop. I’m wondering if I were to do the same on a loop that was already versioned what would happen - would yet another copy be made, or would it essentially find the reference to the other loop for me which I could then retrieve through the class? This is made more confusing by the fact that my pass runs after vectorisation, which does it’s versioning manually outside of the loop versioning class, but still creates an instance of it for the aliasing metadata.

Ultimately I just want to be able to call the getVersionedLoop and getUnversionedLoop methods to find the loops I’m interested in, but I’m very confused on how to get to this point. Any advice would be appreciated, thanks.