This is a split patch of D96644.
Explicitly pass both InnerLoop and OuterLoop to function processLoop to remove the need to swap elements in loop list and allow making loop list an ArrayRef.
Also, fix inconsistent spellings of OuterLoopId and Inner Loop Id in debug log.