Reported in Bug PR52161, there were two issues.
- That IVs with SCEVs containing 'undef' could be selected. This would lead to fruitless salvage attempts.
- Sometimes dbg.value arguments were cached along with a SCEVUnknown type for the value. Effectively this SCEV is a wrapped llvm::value, so no scev-based salvaging can usefully be performed in this case.
While I was in the area I tidied up the IV selection logic a little, extracting a lambda that can be applied to the two sets of IV potentials, each of which has different types (a PHI node or a handle to a PHI).
As ScalarEvolution already contained a static method to traverse SCEVs and find undefs, I changed the visibility so that containsUndefs(SCEV*) was now a public method of ScalarEvolution.
nit: in the comment ; -> .